WordPress Plugin Repository Now Rejects Commits With PHP Errors

blocked

In case you missed it over the holidays, an important notice was issued to WordPress.org plugin developers. The WordPress Plugin Repository will no longer allow developers to commit files with PHP syntax errors in them. Mika Epstein, one of the developers who helps to review incoming plugins, posted an example of what the kick-back error notice will look like:

Error: Commit failed (details follow):
Error: Commit blocked by pre-commit hook (exit code 1) with output:
Error: PHP Parse error: syntax error, unexpected end of file in – on line 1234
Error:
Error: ***********************************
Error: PHP error in: really-cool/tags/1.0/really-cool.php:
Error: Errors parsing really-cool/tags/1.0/really-cool.php
Error: ***********************************
Error: This error was generated by a custom hook script on the Subversion server.
Error: Please contact your server administrator for help with resolving this issue.
Completed!:

As you can see here, if your commit is blocked, you’ll be notified of the file and line containing the error.

It’s important to note that the script performs a PHP 5.4 syntax check. In the comments on the notice, Andrew Nacin warns, “Please be careful if you are using 5.3 or 5.4-specific language features, like namespaces, closures, short array or ternary syntaxes, etc. These will break sites running PHP 5.2 (which is a majority of sites).”

Reasons for Rejecting Commits With PHP Errors

This new policy makes a lot of sense, not only for plugin developers but also for the millions of people who install these extensions and expect them to work. Epstein says, “Such an error would make the plugin fail when it tried to load the file anyway, so think of this as a ‘for your own protection’ kind of thing.” If somehow the errors were missed during testing, the script in place on the Subversion server is like a second checkpoint to help developers commit error free files.

Over time the plugin repository should improve for users as a result of having this policy in place. All new plugins and newly committed files will be free from PHP syntax errors. That means fewer plugin failures out in the wild. When hunting through the repo for a WordPress plugin to perform a specific function, it’s very disappointing to install the plugin only to find that there are errors that prevent it from working at all. Eventually, this new policy will help create a better experience for users installing plugins from the official WordPress.org repository.

6

6 responses to “WordPress Plugin Repository Now Rejects Commits With PHP Errors”

Newsletter

Subscribe Via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.