r53525 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53524‎ | r53525 | r53526 >
Date:04:43, 20 July 2009
Author:mrzman
Status:ok
Tags:
Comment:
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
Modified paths:
  • /trunk/phase3/maintenance/findhooks.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/findhooks.php
@@ -47,15 +47,36 @@
4848 */
4949 function getHooksFromDoc() {
5050 global $doc, $options;
51 - $m = array();
5251 if( isset( $options['online'] ) ){
53 - $content = Http::get( 'http://www.mediawiki.org/w/index.php?title=Manual:Hooks&action=raw' );
54 - preg_match_all( '/\[\[\/([a-zA-Z0-9-_:]+)\|/', $content, $m );
 52+ // All hooks
 53+ $allhookdata = Http::get( 'http://www.mediawiki.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:MediaWiki_hooks&cmlimit=500&format=php' );
 54+ $allhookdata = unserialize( $allhookdata );
 55+ $allhooks = array();
 56+ foreach( $allhookdata['query']['categorymembers'] as $page ) {
 57+ $found = preg_match( '/Manual\:Hooks\/([a-zA-Z0-9- :]+)/', $page['title'], $matches );
 58+ if( $found ) {
 59+ $hook = str_replace( ' ', '_', $matches[1] );
 60+ $allhooks[] = $hook;
 61+ }
 62+ }
 63+ // Removed hooks
 64+ $oldhookdata = Http::get( 'http://www.mediawiki.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Removed_hooks&cmlimit=500&format=php' );
 65+ $oldhookdata = unserialize( $oldhookdata );
 66+ $removed = array();
 67+ foreach( $oldhookdata['query']['categorymembers'] as $page ) {
 68+ $found = preg_match( '/Manual\:Hooks\/([a-zA-Z0-9- :]+)/', $page['title'], $matches );
 69+ if( $found ) {
 70+ $hook = str_replace( ' ', '_', $matches[1] );
 71+ $removed[] = $hook;
 72+ }
 73+ }
 74+ return array_diff( $allhooks, $removed );
5575 } else {
 76+ $m = array();
5677 $content = file_get_contents( $doc );
5778 preg_match_all( "/\n'(.*?)'/", $content, $m );
 79+ return array_unique( $m[1] );
5880 }
59 - return array_unique( $m[1] );
6081 }
6182
6283 /**

Status & tagging log