Go to the documentation of this file.
37 require_once __DIR__ .
'/Maintenance.php';
51 parent::__construct();
52 $this->mDescription =
'Find hooks that are undocumented, missing, or just plain wrong';
53 $this->
addOption(
'online',
'Check against MediaWiki.org hook documentation' );
69 $IP .
'/includes/actions/',
70 $IP .
'/includes/api/',
71 $IP .
'/includes/cache/',
72 $IP .
'/includes/changes/',
73 $IP .
'/includes/clientpool/',
74 $IP .
'/includes/content/',
75 $IP .
'/includes/context/',
76 $IP .
'/includes/dao/',
77 $IP .
'/includes/db/',
78 $IP .
'/includes/debug/',
79 $IP .
'/includes/deferred/',
80 $IP .
'/includes/diff/',
81 $IP .
'/includes/externalstore/',
82 $IP .
'/includes/filebackend/',
83 $IP .
'/includes/filerepo/',
84 $IP .
'/includes/filerepo/file/',
85 $IP .
'/includes/gallery/',
86 $IP .
'/includes/htmlform/',
87 $IP .
'/includes/installer/',
88 $IP .
'/includes/interwiki/',
89 $IP .
'/includes/jobqueue/',
90 $IP .
'/includes/json/',
91 $IP .
'/includes/logging/',
92 $IP .
'/includes/media/',
93 $IP .
'/includes/parser/',
94 $IP .
'/includes/rcfeed/',
95 $IP .
'/includes/resourceloader/',
96 $IP .
'/includes/revisiondelete/',
97 $IP .
'/includes/search/',
98 $IP .
'/includes/site/',
99 $IP .
'/includes/specialpage/',
100 $IP .
'/includes/specials/',
101 $IP .
'/includes/upload/',
103 $IP .
'/maintenance/',
104 $IP .
'/maintenance/language/',
106 $IP .
'/tests/parser/',
107 $IP .
'/tests/phpunit/suites/',
111 foreach ( $pathinc
as $dir ) {
116 $potential = array_unique( $potential );
117 $bad = array_unique( $bad );
118 $todo = array_diff( $potential, $documented );
119 $deprecated = array_diff( $documented, $potential );
123 $this->
printArray(
'Documented and not found', $deprecated );
124 $this->
printArray(
'Unclear hook calls', $bad );
126 if ( count( $todo ) == 0 && count( $deprecated ) == 0 && count( $bad ) == 0 ) {
127 $this->
output(
"Looks good!\n" );
150 $content = file_get_contents( $doc );
151 preg_match_all(
"/\n'(.*?)':/", $content, $m );
152 return array_unique( $m[1] );
161 $allhookdata =
Http::get(
'http://www.mediawiki.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:MediaWiki_hooks&cmlimit=500&format=php' );
162 $allhookdata = unserialize( $allhookdata );
164 foreach ( $allhookdata[
'query'][
'categorymembers']
as $page ) {
165 $found = preg_match(
'/Manual\:Hooks\/([a-zA-Z0-9- :]+)/', $page[
'title'],
$matches );
167 $hook = str_replace(
' ',
'_',
$matches[1] );
172 $oldhookdata =
Http::get(
'http://www.mediawiki.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Removed_hooks&cmlimit=500&format=php' );
173 $oldhookdata = unserialize( $oldhookdata );
175 foreach ( $oldhookdata[
'query'][
'categorymembers']
as $page ) {
176 $found = preg_match(
'/Manual\:Hooks\/([a-zA-Z0-9- :]+)/', $page[
'title'],
$matches );
178 $hook = str_replace(
' ',
'_',
$matches[1] );
182 return array_diff( $allhooks, $removed );
191 $content = file_get_contents(
$file );
193 preg_match_all(
'/(?:wfRunHooks|Hooks\:\:run|ContentHandler\:\:runLegacyHooks)\(\s*([\'"])(.*?)\1/', $content, $m );
204 $dh = opendir(
$path );
206 while ( (
$file = readdir( $dh ) ) !==
false ) {
222 $content = file_get_contents(
$file );
224 # We want to skip the "function wfRunHooks()" one. :)
225 preg_match_all(
'/(?<!function )wfRunHooks\(\s*[^\s\'"].*/', $content, $m );
227 foreach ( $m[0]
as $match ) {
228 $list[] = $match .
"(" .
$file .
")";
240 $dh = opendir(
$path );
242 while ( (
$file = readdir( $dh ) ) !==
false ) {
243 # We don't want to read this file as it contains bad calls to wfRunHooks()
264 foreach ( $arr
as $v ) {
266 $this->
output(
"$msg: $v\n" );
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
addOption( $name, $description, $required=false, $withArg=false, $shortName=false)
Add a parameter to the script.
getHooksFromDoc( $doc)
Get the hook documentation, either locally or from MediaWiki.org.
require_once RUN_MAINTENANCE_IF_MAIN
Maintenance script that compares documented and actually present mismatches.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
getHooksFromOnlineDoc()
Get hooks from www.mediawiki.org using the API.
__construct()
Default constructor.
getHooksFromLocalDoc( $doc)
Get hooks from a local file (for example docs/hooks.txt)
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
getBadHooksFromPath( $path)
Get bad hooks from the source code.
when a variable name is used in a it is silently declared as a new masking the global
static get( $url, $timeout='default', $options=array())
Simple wrapper for Http::request( 'GET' )
while(false !==( $line=fgets( $in))) if(! $columns) $ignore
if(!defined( 'MEDIAWIKI')) if(!isset( $wgVersion)) $matches
printArray( $msg, $arr, $sort=true)
Nicely output the array.
const DB_NONE
Constants for DB access type.
if(PHP_SAPI !='cli') $file
getHooksFromPath( $path)
Get hooks from the source code.
if(count( $args)==0) $dir
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
getHooksFromFile( $file)
Get hooks from a PHP file.
output( $out, $channel=null)
Throw some output to the user.
hasOption( $name)
Checks to see if a particular param exists.
getDbType()
Does the script need different DB access? By default, we give Maintenance scripts normal rights to th...
execute()
Do the actual work.
getBadHooksFromFile( $file)
Get bad hooks (where the hook name could not be determined) from a PHP file.