From 4143098b1673727c98ddb4473f6b310da16909cf Mon Sep 17 00:00:00 2001 From: Alex Z Date: Mon, 20 Jul 2009 04:43:22 +0000 Subject: [PATCH] Replace the call to action=raw with a couple API calls for the main hook category and the removed hook category (that I just created) for better results and proper filtering of removed hooks for the online doc check --- maintenance/findhooks.php | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/maintenance/findhooks.php b/maintenance/findhooks.php index debeca1294..e05426c87a 100644 --- a/maintenance/findhooks.php +++ b/maintenance/findhooks.php @@ -47,15 +47,36 @@ $pathinc = array( */ function getHooksFromDoc() { global $doc, $options; - $m = array(); if( isset( $options['online'] ) ){ - $content = Http::get( 'http://www.mediawiki.org/w/index.php?title=Manual:Hooks&action=raw' ); - preg_match_all( '/\[\[\/([a-zA-Z0-9-_:]+)\|/', $content, $m ); + // 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; + } + } + return array_diff( $allhooks, $removed ); } else { + $m = array(); $content = file_get_contents( $doc ); preg_match_all( "/\n'(.*?)'/", $content, $m ); + return array_unique( $m[1] ); } - return array_unique( $m[1] ); } /** -- 2.20.1