Index: trunk/phase3/maintenance/findhooks.php |
— | — | @@ -47,15 +47,36 @@ |
48 | 48 | */ |
49 | 49 | function getHooksFromDoc() { |
50 | 50 | global $doc, $options; |
51 | | - $m = array(); |
52 | 51 | 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 ); |
55 | 75 | } else { |
| 76 | + $m = array(); |
56 | 77 | $content = file_get_contents( $doc ); |
57 | 78 | preg_match_all( "/\n'(.*?)'/", $content, $m ); |
| 79 | + return array_unique( $m[1] ); |
58 | 80 | } |
59 | | - return array_unique( $m[1] ); |
60 | 81 | } |
61 | 82 | |
62 | 83 | /** |