X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FfindHooks.php;h=66e8da0a5b8ed7a6ae26445a7f3467ecfa7027a7;hb=2700298740509a3f98a9e2cd81cfbce4f67ed114;hp=074388f68d8a065f57bc6bae5397b2298de5294f;hpb=552125ee3880f1341b96fe828771847174550538;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/findHooks.php b/maintenance/findHooks.php index 074388f68d..66e8da0a5b 100644 --- a/maintenance/findHooks.php +++ b/maintenance/findHooks.php @@ -99,6 +99,7 @@ class FindHooks extends Maintenance { $IP . '/includes/revisiondelete/', $IP . '/includes/search/', $IP . '/includes/site/', + $IP . '/includes/skins/', $IP . '/includes/specialpage/', $IP . '/includes/specials/', $IP . '/includes/upload/', @@ -109,9 +110,6 @@ class FindHooks extends Maintenance { $IP . '/tests/', $IP . '/tests/parser/', $IP . '/tests/phpunit/suites/', - $IP . '/skins/', - $IP . '/skins/MonoBook/', - $IP . '/skins/Vector/', ); foreach ( $pathinc as $dir ) { @@ -136,7 +134,8 @@ class FindHooks extends Maintenance { /** * Get the hook documentation, either locally or from MediaWiki.org - * @return Array of documented hooks + * @param string $doc + * @return array Array of documented hooks */ private function getHooksFromDoc( $doc ) { if ( $this->hasOption( 'online' ) ) { @@ -149,7 +148,7 @@ class FindHooks extends Maintenance { /** * Get hooks from a local file (for example docs/hooks.txt) * @param string $doc Filename to look in - * @return Array of documented hooks + * @return array Array of documented hooks */ private function getHooksFromLocalDoc( $doc ) { $m = array(); @@ -161,45 +160,48 @@ class FindHooks extends Maintenance { /** * Get hooks from www.mediawiki.org using the API - * @return Array of documented hooks + * @return array 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' + $allhooks = $this->getHooksFromOnlineDocCategory( 'MediaWiki_hooks' ); + $removed = $this->getHooksFromOnlineDocCategory( 'Removed_hooks' ); + return array_diff( $allhooks, $removed ); + } + + /** + * @param string $title + * @return array + */ + private function getHooksFromOnlineDocCategory( $title ) { + $params = array( + 'action' => 'query', + 'list' => 'categorymembers', + 'cmtitle' => "Category:$title", + 'cmlimit' => 500, + 'format' => 'json', + 'continue' => '', ); - $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; + + $retval = array(); + while ( true ) { + $json = Http::get( wfAppendQuery( 'http://www.mediawiki.org/w/api.php', $params ) ); + $data = FormatJson::decode( $json, true ); + foreach ( $data['query']['categorymembers'] as $page ) { + if ( preg_match( '/Manual\:Hooks\/([a-zA-Z0-9- :]+)/', $page['title'], $m ) ) { + $retval[] = str_replace( ' ', '_', $m[1] ); + } } - } - // 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; + if ( !isset( $data['continue'] ) ) { + return $retval; } + $params = array_replace( $params, $data['continue'] ); } - - return array_diff( $allhooks, $removed ); } /** * Get hooks from a PHP file * @param string $file Full filename to the PHP file. - * @return Array of hooks found. + * @return array Array of hooks found */ private function getHooksFromFile( $file ) { $content = file_get_contents( $file ); @@ -216,7 +218,7 @@ class FindHooks extends Maintenance { /** * Get hooks from the source code. * @param string $path Directory where the include files can be found - * @return Array of hooks found. + * @return array Array of hooks found */ private function getHooksFromPath( $path ) { $hooks = array(); @@ -236,7 +238,7 @@ class FindHooks extends Maintenance { /** * Get bad hooks (where the hook name could not be determined) from a PHP file * @param string $file Full filename to the PHP file. - * @return Array of bad wfRunHooks() lines + * @return array Array of bad wfRunHooks() lines */ private function getBadHooksFromFile( $file ) { $content = file_get_contents( $file ); @@ -254,7 +256,7 @@ class FindHooks extends Maintenance { /** * Get bad hooks from the source code. * @param string $path Directory where the include files can be found - * @return Array of bad wfRunHooks() lines + * @return array Array of bad wfRunHooks() lines */ private function getBadHooksFromPath( $path ) { $hooks = array();