Last modified: 2007-11-30 17:29:01 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 12146 - maintenance/findhooks.php does not find all hooks
maintenance/findhooks.php does not find all hooks
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
1.12.x
All All
: Lowest trivial (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2007-11-29 11:11 UTC by Thomas Bleher
Modified: 2007-11-30 17:29 UTC (History)
0 users

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


Attachments

Description Thomas Bleher 2007-11-29 11:11:45 UTC
The regex used to find hooks is too strict, as it assumes that strings are enclosed in single quotes,
which is not always true for wfRunHooks in the Mediawiki code base.

The trivial patch:
--- a/maintenance/findhooks.php
+++ b/maintenance/findhooks.php
@@ -45,8 +45,8 @@ function getHooksFromDoc() {
 function getHooksFromFile( $file ) {
        $content = file_get_contents( $file );
        $m = array();
-       preg_match_all( "/wfRunHooks\(\s*\'(.*?)\'/", $content, $m);
-       return $m[1];
+       preg_match_all( '/wfRunHooks\(\s*([\'"])(.*?)\1/', $content, $m);
+       return $m[2];
 }

 /**
Comment 1 Thomas Bleher 2007-11-29 11:18:25 UTC
BTW: The script reports, among others:
undocumented: userCan
not found: UserCan

docs/hooks.txt should be changed as follows:
--- a/docs/hooks.txt
+++ b/docs/hooks.txt
@@ -753,13 +753,13 @@ string &$error: output: HTML error to show if upload canceled by returning false
 'UploadComplete': Upon completion of a file upload
 $image: Image object representing the file that was uploaded

-'UserCan': To interrupt/advise the "user can do X to Y article" check.
+'userCan': To interrupt/advise the "user can do X to Y article" check.
        If you want to display an error message, try getUserPermissionsErrors.
 $title: Title object being checked against
 $user : Current user object
 $action: Action being checked
 $result: Pointer to result returned if hook returns false. If null is returned,
- UserCan checks are continued by internal code.
+ userCan checks are continued by internal code.

 'UserCreateForm': change to manipulate the login form
 $template: SimpleTemplate instance for the form
Comment 2 Thomas Bleher 2007-11-30 17:29:01 UTC
Fixed in r27984.

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


Navigation
Links