X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=maintenance%2FfindHooks.php;h=9929cf9b67a817a9ef8c9aa2c3bdfc096c036763;hb=64ca212514d48330ff02fdaed34563e0b75e22c4;hp=7c6c824282372c0775160eec7aea74fef03c12f5;hpb=229e1f4fdbda91f10f5ce78f0d35db973c714b1d;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/findHooks.php b/maintenance/findHooks.php index 7c6c824282..9929cf9b67 100644 --- a/maintenance/findHooks.php +++ b/maintenance/findHooks.php @@ -63,6 +63,8 @@ class FindHooks extends Maintenance { $documented = $this->getHooksFromDoc( $IP . '/docs/hooks.txt' ); $potential = array(); $bad = array(); + + // TODO: Don't hardcode the list of directories $pathinc = array( $IP . '/', $IP . '/includes/', @@ -90,6 +92,7 @@ class FindHooks extends Maintenance { $IP . '/includes/json/', $IP . '/includes/logging/', $IP . '/includes/media/', + $IP . '/includes/page/', $IP . '/includes/parser/', $IP . '/includes/rcfeed/', $IP . '/includes/resourceloader/', @@ -99,6 +102,7 @@ class FindHooks extends Maintenance { $IP . '/includes/specialpage/', $IP . '/includes/specials/', $IP . '/includes/upload/', + $IP . '/includes/utils/', $IP . '/languages/', $IP . '/maintenance/', $IP . '/maintenance/language/', @@ -106,6 +110,8 @@ class FindHooks extends Maintenance { $IP . '/tests/parser/', $IP . '/tests/phpunit/suites/', $IP . '/skins/', + $IP . '/skins/MonoBook/', + $IP . '/skins/Vector/', ); foreach ( $pathinc as $dir ) { @@ -146,10 +152,11 @@ class FindHooks extends Maintenance { * @return array Array of documented hooks */ private function getHooksFromLocalDoc( $doc ) { - $m = array(); - $content = file_get_contents( $doc ); - preg_match_all( "/\n'(.*?)':/", $content, $m ); - return array_unique( $m[1] ); + $m = array(); + $content = file_get_contents( $doc ); + preg_match_all( "/\n'(.*?)':/", $content, $m ); + + return array_unique( $m[1] ); } /** @@ -157,35 +164,36 @@ class FindHooks extends Maintenance { * @return array of documented hooks */ private function getHooksFromOnlineDoc() { - // All hooks - $allhookdata = Http::get( - 'http://www.mediawiki.org/w/api.php?action=query&list=categorymembers&' - . 'cmtitle=Category:MediaWiki_hooks&cmlimit=500&format=php' - ); - $allhookdata = unserialize( $allhookdata ); - $allhooks = array(); - foreach ( $allhookdata['query']['categorymembers'] as $page ) { - $found = preg_match( '/Manual\:Hooks\/([a-zA-Z0-9- :]+)/', $page['title'], $matches ); - if ( $found ) { - $hook = str_replace( ' ', '_', $matches[1] ); - $allhooks[] = $hook; - } + // All hooks + $allhookdata = Http::get( + 'http://www.mediawiki.org/w/api.php?action=query&list=categorymembers&' + . 'cmtitle=Category:MediaWiki_hooks&cmlimit=500&format=php' + ); + $allhookdata = unserialize( $allhookdata ); + $allhooks = array(); + foreach ( $allhookdata['query']['categorymembers'] as $page ) { + $found = preg_match( '/Manual\:Hooks\/([a-zA-Z0-9- :]+)/', $page['title'], $matches ); + if ( $found ) { + $hook = str_replace( ' ', '_', $matches[1] ); + $allhooks[] = $hook; } - // Removed hooks - $oldhookdata = Http::get( - 'http://www.mediawiki.org/w/api.php?action=query&list=categorymembers&' - . 'cmtitle=Category:Removed_hooks&cmlimit=500&format=php' - ); - $oldhookdata = unserialize( $oldhookdata ); - $removed = array(); - foreach ( $oldhookdata['query']['categorymembers'] as $page ) { - $found = preg_match( '/Manual\:Hooks\/([a-zA-Z0-9- :]+)/', $page['title'], $matches ); - if ( $found ) { - $hook = str_replace( ' ', '_', $matches[1] ); - $removed[] = $hook; - } + } + // Removed hooks + $oldhookdata = Http::get( + 'http://www.mediawiki.org/w/api.php?action=query&list=categorymembers&' + . 'cmtitle=Category:Removed_hooks&cmlimit=500&format=php' + ); + $oldhookdata = unserialize( $oldhookdata ); + $removed = array(); + foreach ( $oldhookdata['query']['categorymembers'] as $page ) { + $found = preg_match( '/Manual\:Hooks\/([a-zA-Z0-9- :]+)/', $page['title'], $matches ); + if ( $found ) { + $hook = str_replace( ' ', '_', $matches[1] ); + $removed[] = $hook; } - return array_diff( $allhooks, $removed ); + } + + return array_diff( $allhooks, $removed ); } /** @@ -221,6 +229,7 @@ class FindHooks extends Maintenance { } closedir( $dh ); } + return $hooks; } @@ -238,6 +247,7 @@ class FindHooks extends Maintenance { foreach ( $m[0] as $match ) { $list[] = $match . "(" . $file . ")"; } + return $list; } @@ -258,6 +268,7 @@ class FindHooks extends Maintenance { } closedir( $dh ); } + return $hooks; }