From 086ae52d12011746a75f5588e877347bc0457352 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 21 Mar 2008 11:49:34 +0100 Subject: Update auf MediaWiki 1.12.0 --- maintenance/findhooks.php | 98 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 72 insertions(+), 26 deletions(-) (limited to 'maintenance/findhooks.php') diff --git a/maintenance/findhooks.php b/maintenance/findhooks.php index 284e7906..8433571d 100644 --- a/maintenance/findhooks.php +++ b/maintenance/findhooks.php @@ -7,25 +7,26 @@ * - hooks names in hooks.txt are at the beginning of a line and single quoted. * - hooks names in code are the first parameter of wfRunHooks. * + * Any instance of wfRunHooks that doesn't meet these parameters will be noted. + * * @addtogroup Maintenance * * @author Ashar Voultoiz * @copyright Copyright © Ashar voultoiz * @license http://www.gnu.org/copyleft/gpl.html GNU General Public Licence 2.0 or later */ - + /** This is a command line script*/ include('commandLine.inc'); - - + + # GLOBALS - + $doc = $IP . '/docs/hooks.txt'; -$pathinc = $IP . '/includes/'; - - +$pathinc = array( $IP.'/includes/', $IP.'/includes/api/', $IP.'/includes/filerepo/', $IP.'/languages/', $IP.'/maintenance/', $IP.'/skins/' ); + # FUNCTIONS - + /** * @return array of documented hooks */ @@ -36,19 +37,19 @@ function getHooksFromDoc() { preg_match_all( "/\n'(.*?)'/", $content, $m); return $m[1]; } - + /** - * Get hooks from a php file + * Get hooks from a PHP file * @param $file Full filename to the PHP file. * @return array of hooks found. */ 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]; } - + /** * Get hooks from the source code. * @param $path Directory where the include files can be found @@ -66,7 +67,43 @@ function getHooksFromPath( $path ) { } return $hooks; } - + +/** + * Get bad hooks (where the hook name could not be determined) from a PHP file + * @param $file Full filename to the PHP file. + * @return array of bad wfRunHooks() lines + */ +function getBadHooksFromFile( $file ) { + $content = file_get_contents( $file ); + $m = array(); + # We want to skip the "function wfRunHooks()" one. :) + preg_match_all( '/(?