Title: Overzealous subversion pre-commit hook syntax check
Last modified: August 31, 2016

---

# Overzealous subversion pre-commit hook syntax check

 *  [jeffreylicht](https://wordpress.org/support/users/jeffreylicht/)
 * (@jeffreylicht)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/overzealous-subversion-pre-commit-hook-syntax-check/)
 * I’m submitting a plugin that has some optional functionality which requires PHP
   5.5.
 * The plugin only loads the files that require PHP 5.5 once it’s checked the PHP
   version, as per the recommendations here: [https://make.wordpress.org/plugins/2015/06/05/policy-on-php-versions/](https://make.wordpress.org/plugins/2015/06/05/policy-on-php-versions/)
 * However, it appears that the pre-commit hook in SVN does a syntax check on ALL
   files to ensure that they run on PHP 5.2, and does not take into account login
   in the plugin that doesn’t load such files on PHP < 5.5. Therefore, I receive
   errors as follows when trying to commit to the repository:
 * >  Transmitting file data ………………………svn: E165001: Commit failed (details follow):
   > 
   > svn: E165001: Commit blocked by pre-commit hook (exit code 1) with output: 
   > PHP Parse error: syntax error, unexpected ‘$client’ (T_VARIABLE) in – on line
   > 61
   > ***********************************
   >  PHP error in: amberlink/trunk/vendor/aws/
   > Aws/CommandPool.php: Errors parsing amberlink/trunk/vendor/aws/Aws/CommandPool.
   > php ***********************************
 * Any recommendations on how to resolve this issue? And is this the right place
   to raise the question?

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [10 years, 4 months ago](https://wordpress.org/support/topic/overzealous-subversion-pre-commit-hook-syntax-check/#post-6949192)
 * Actually, the pre-commit hook checks for PHP 5.4 syntax, not 5.2. So, whatever
   you’re doing on line 61 isn’t 5.4 compatible.
 * Currently, 72.1% of all WP installs run 5.4 or less. We’d prefer not to have 
   plugin code in our directory that whitescreens the vast majority of WordPress
   installations immediately after activation.
 * You’re welcome to require PHP 5.5. But we require syntax capable of being parsed
   by 5.4. And we’d recommend that your main file be 5.2 compatible, and that the
   PHP version check be in that file, which only loads any other non-5.2 compatible
   files after the version check is complete.
 *  Moderator [Ipstenu (Mika Epstein)](https://wordpress.org/support/users/ipstenu/)
 * (@ipstenu)
 * 🏳️‍🌈 Advisor and Activist
 * [10 years, 4 months ago](https://wordpress.org/support/topic/overzealous-subversion-pre-commit-hook-syntax-check/#post-6949197)
 * FWIW, you can also use the v2 branch of the AWS SDK (that’s what I’m guessing
   you’re using): [https://github.com/aws/aws-sdk-php](https://github.com/aws/aws-sdk-php)
 * [https://github.com/aws/aws-sdk-php/blob/master/src/CommandPool.php#L61](https://github.com/aws/aws-sdk-php/blob/master/src/CommandPool.php#L61)
 * Not sure why that would fail like that. Might be worth asking Amazon.
 *  Thread Starter [jeffreylicht](https://wordpress.org/support/users/jeffreylicht/)
 * (@jeffreylicht)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/overzealous-subversion-pre-commit-hook-syntax-check/#post-6949218)
 * I’m completely on board with ensuring that all plugins are compatible with with
   older versions of PHP. My actual concern is that the advice being given in the
   most “official” word on the subject is not consistent with the rules that are
   being enforced by the Subversion validation.
 * From [https://make.wordpress.org/plugins/2015/06/05/policy-on-php-versions/](https://make.wordpress.org/plugins/2015/06/05/policy-on-php-versions/):
 * >  Sometimes though, you need more complicated checks. Let’s say your plugin 
   > uses PHP namespaces. Those are not supported in PHP 5.2, and will cause a syntax
   > error just from having them in the file, before any of your code runs.
   > So, your main plugin file needs to not have namespaces and basically only be
   > a shiv to load the rest of the plugin from another file if the requirements
   > are met:
 *     ```
       if ( version_compare( PHP_VERSION, '5.3', '<' ) ) {
           add_action( 'admin_notices', create_function( '', "echo '<div class=\"error\"><p>".__('Plugin Name requires PHP 5.3 to function properly. Please upgrade PHP or deactivate Plugin Name.', 'plugin-name') ."</p></div>';" ) );
           return;
       } else {
           include 'rest-of-plugin.php';
       }
       ```
   
 * >  Here, the plugin does not load the files that can cause errors unless the 
   > requirements are met.
 * The recommendation in that blog post is to **conditionally load** PHP files containing
   code which is not syntactically valid in older versions of PHP. The implication
   is that those files can be included in the plugin, as long as they aren’t loaded
   when they wouldn’t be valid. However, the Subversion pre-commit hook is validating**
   every** file, whether or not there is logic to prevent it from being loaded on
   older versions of PHP.
 * I’ve worked around the immediate problem by using v2 of the AWS library – thanks
   Ipstenu! – but still think there’s an issue here to be addressed, either by updating
   the documentation or changing the validation behavior.
 *  [Lee Willis](https://wordpress.org/support/users/leewillis77/)
 * (@leewillis77)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/overzealous-subversion-pre-commit-hook-syntax-check/#post-6949452)
 * Hi;
 * Just wondering if there’s any update on this as I’m hitting the exact same problem.
   I have a plugin that requires PHP 5.5. It duly checks (In a 5.2 compatible main
   plugin file) the PHP version, and if the requirements aren’t met shows a message,
   doesn’t load any other files, and deactivates itself.
 * So – it’s not going to break sites, but at the minute I can’t actually publish
   it due to the pre-commit hook validation.
 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [10 years, 3 months ago](https://wordpress.org/support/topic/overzealous-subversion-pre-commit-hook-syntax-check/#post-6949453)
 * I still don’t understand why you would want to publish a plugin that won’t work
   for 3/4’ths of the userbase.
 *  [Lee Willis](https://wordpress.org/support/users/leewillis77/)
 * (@leewillis77)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/overzealous-subversion-pre-commit-hook-syntax-check/#post-6949454)
 * Hi;
 * A particular plugin isn’t necessarily aimed at the whole of WordPress’ userbase.
   So the % of users who are likely to use any given plugin and are on PHP < 5.5
   isn’t necessarily the same as the % of the total WP userbase.
 * Having a plugin that tells you that you’re out of date, might motivate you to
   upgrade to run it. I’d agree it’s important to do so in a way that doesn’t just
   whitescreen and makes you think the plugin / WordPress is at fault.
 * Think of it as BrowseHappy for PHP 🙂
 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [10 years, 3 months ago](https://wordpress.org/support/topic/overzealous-subversion-pre-commit-hook-syntax-check/#post-6949455)
 * Well, regardless, we’re looking into raising that syntax check limitation, but
   it’s not something we have direct control over nor is it something that I can
   just flip-a-switch to change. So, it may take some time.
 *  [Lee Willis](https://wordpress.org/support/users/leewillis77/)
 * (@leewillis77)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/overzealous-subversion-pre-commit-hook-syntax-check/#post-6949456)
 * Thanks!
 *  [Marco Castelluccio](https://wordpress.org/support/users/marco-c-1/)
 * (@marco-c-1)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/overzealous-subversion-pre-commit-hook-syntax-check/#post-6949466)
 * > I still don’t understand why you would want to publish a plugin that won’t 
   > work for 3/4’ths of the userbase.
 * Samuel, often a plugin might include **optional** code that only works with PHP
   5.5+.
    The plugin would still work with older versions of PHP, but would offer
   the optional functionality to users with PHP 5.5+.
 * An example is [https://wordpress.org/support/topic/svn-commit-fails-because-of-yield-keyword](https://wordpress.org/support/topic/svn-commit-fails-because-of-yield-keyword).

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Overzealous subversion pre-commit hook syntax check’ is closed to new
replies.

## Tags

 * [plugin directory](https://wordpress.org/support/topic-tag/plugin-directory/)
 * [subversion](https://wordpress.org/support/topic-tag/subversion/)

 * In: [Everything else WordPress](https://wordpress.org/support/forum/miscellaneous/)
 * 9 replies
 * 5 participants
 * Last reply from: [Marco Castelluccio](https://wordpress.org/support/users/marco-c-1/)
 * Last activity: [10 years, 1 month ago](https://wordpress.org/support/topic/overzealous-subversion-pre-commit-hook-syntax-check/#post-6949466)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
