Last modified: 2013-06-18 15:05:26 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T28172, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 26172 - Create pre-commit PHP lint test
Create pre-commit PHP lint test
Status: RESOLVED FIXED
Product: Wikimedia
Classification: Unclassified
Subversion (Other open bugs)
unspecified
All All
: High enhancement (vote)
: ---
Assigned To: Chad H.
: shell
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-11-30 13:14 UTC by Chad H.
Modified: 2013-06-18 15:05 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Chad H. 2010-11-30 13:14:42 UTC
E_PARSE errors are never acceptable. But people don't like to test their code.

So pre-commit should run 'php -l' on php source files so people can't commit if they mess up.

I'll get to this sometime soon-ish.
Comment 1 Chad H. 2010-11-30 14:59:54 UTC
Done, now checks all .php or .inc or .php5 files changed in a commit for syntax validity.

Should output the following on failure:


$ svn ci -m 'Try #2'
Sending        test.php
Transmitting file data .svn: Commit failed (details follow):
svn: Commit blocked by pre-commit hook (exit code 1) with output:
PHP Parse error:  syntax error, unexpected T_STRING in - on line 1

***********************************
PHP error in: test.php:
Errors parsing test.php
***********************************
Comment 2 Sam Reed (reedy) 2010-11-30 15:53:54 UTC
Not that I'm adversed to this, but I thought that we didn't want to do a pre-commit hook as it blocks? And would be especially annoying for large (i18n) etc commits...?

Also, what if the file already had it in...? (Granted, if it was tested, they would've found it..)
Comment 3 Sam Reed (reedy) 2010-11-30 15:54:48 UTC
https://bugzilla.wikimedia.org/show_bug.cgi?id=20069 is technically redundant now...
Comment 4 Platonides 2010-11-30 17:53:12 UTC
Which php version is used?
Comment 5 Max Semenik 2010-11-30 17:55:24 UTC
Can we unleash checkSyntax.php in its fury on files committed?
Comment 6 Ryan Lane 2010-11-30 17:55:38 UTC
PHP 5.3.2-1ubuntu4.5 with Suhosin-Patch (cli) (built: Sep 17 2010 13:49:46) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
Comment 7 Chad H. 2010-11-30 17:56:15 UTC
(In reply to comment #4)
> Which php version is used?

5.3.2.

(In reply to comment #2)
> Not that I'm adversed to this, but I thought that we didn't want to do a
> pre-commit hook as it blocks? 
>

I don't like the idea of doing extensive pre-commit hooks due to that issue. But php -l is typically very fast.

> And would be especially annoying for large (i18n)
> etc commits...?
> 

It may be, we're not sure yet. Gonna test it later with Raymond.

> Also, what if the file already had it in...? (Granted, if it was tested, they
> would've found it..)
>

Then you fix it too, while you're at it ;-)
Comment 8 Chad H. 2010-11-30 17:57:06 UTC
(In reply to comment #5)
> Can we unleash checkSyntax.php in its fury on files committed?

checkSyntax.php is slower and checks lots of non-syntax stuff too. That would be better as a post-commit hook.
Comment 9 Sam Reed (reedy) 2010-11-30 17:57:41 UTC
Commit your script to SVN?

In lint.php..

 * Recursive directory crawling PHP syntax checker
 * Uses parsekit, which is much faster than php -l for lots of files due to the
Comment 10 Chad H. 2010-11-30 17:59:36 UTC
(In reply to comment #9)
> Commit your script to SVN?
> 

I need to clean up the pre/post commit hooks and put them somewhere. Puppet makes more sense than SVN, though.

> In lint.php..
> 
>  * Recursive directory crawling PHP syntax checker
>  * Uses parsekit, which is much faster than php -l for lots of files due to the

Yes, it's faster, but it's horrendously broken on 5.3.x last I played with it.
Comment 11 Platonides 2010-11-30 18:00:19 UTC
(In reply to comment #9)
> Commit your script to SVN?

maintenance/checkSyntax.php ?
Comment 12 Max Semenik 2010-11-30 18:03:34 UTC
(In reply to comment #8)

> checkSyntax.php is slower and checks lots of non-syntax stuff too. That would
> be better as a post-commit hook.

It isn't much slower on a known list of files. A few regexes is faster than php
-l and even parsekit. And some stuff it checks for worth declining on
sight, such as common causes of "headers already sent" errors.

Also, it avoids using parsekit on PHP 5.3 where it's broken.
Comment 13 Chad H. 2010-11-30 18:05:19 UTC
(In reply to comment #12)
> (In reply to comment #8)
> 
> > checkSyntax.php is slower and checks lots of non-syntax stuff too. That would
> > be better as a post-commit hook.
> 
> It isn't much slower on a known list of files. A few regexes is faster than php
> -l and even parsekit. And some stuff it checks for worth declining on
> sight, such as common causes of "headers already sent" errors.
> 
> Also, it avoids using parsekit on PHP 5.3 where it's broken.

We should rewrite it to not depend on MW at all, then it'll be fast :D
Comment 14 Sam Reed (reedy) 2010-12-22 21:18:36 UTC
It brokeded
Comment 15 Sam Reed (reedy) 2011-04-02 01:22:31 UTC
Can we fix plox?
Comment 16 Sam Reed (reedy) 2011-07-27 22:32:39 UTC
This and the empty summary prevention REALLY need fixing :P
Comment 17 Chad H. 2011-08-05 21:33:37 UTC
Fixed and re-deployed. See /trunk/tools/subversion/hooks.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links