Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F4579
findhooks.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
•
bzimport
Nov 21 2014, 10:01 PM
2014-11-21 22:01:04 (UTC+0)
Size
2 KB
Referenced Files
None
Subscribers
None
findhooks.patch
View Options
Index: ../phase3-work/maintenance/findhooks.php
===================================================================
--- ../phase3-work/maintenance/findhooks.php (revision 30827)
+++ ../phase3-work/maintenance/findhooks.php (working copy)
@@ -23,12 +23,8 @@
# GLOBALS
$doc = $IP . '/docs/hooks.txt';
-$pathinc = $IP . '/includes/';
-$pathfile = $IP . '/includes/filerepo/LocalFile.php';
-$pathlang = $IP . '/languages/Language.php';
-$pathskin = $IP . '/skins/MonoBook.php';
+$pathinc = array( $IP.'/includes/', $IP.'/includes/api/', $IP.'/includes/filerepo/', $IP.'/languages/', $IP.'/maintenance/', $IP.'/skins/' );
-
# FUNCTIONS
/**
@@ -82,7 +78,11 @@
$m = array();
# We want to skip the "function wfRunHooks()" one. :)
preg_match_all( '/(?<!function )wfRunHooks\(\s*[^\s\'"].*/', $content, $m);
- return $m[0];
+ $list = array();
+ foreach( $m[0] as $match ){
+ $list[] = $match . "(" . $file . ")";
+ }
+ return $list;
}
/**
@@ -94,7 +94,8 @@
$hooks = array();
if( $dh = opendir($path) ) {
while(($file = readdir($dh)) !== false) {
- if( filetype($path.$file) == 'file' ) {
+ # We don't want to read this file as it contains bad calls to wfRunHooks()
+ if( filetype( $path.$file ) == 'file' && !$path.$file == __FILE__ ) {
$hooks = array_merge( $hooks, getBadHooksFromFile($path.$file) );
}
}
@@ -111,33 +112,30 @@
*/
function printArray( $msg, $arr, $sort = true ) {
if($sort) asort($arr);
- foreach($arr as $v) print "$msg: $v\n";
+ foreach($arr as $v) echo "$msg: $v\n";
}
# MAIN
$documented = getHooksFromDoc($doc);
+$potential = array();
+$bad = array();
+foreach( $pathinc as $dir ) {
+ $potential = array_merge( $potential, getHooksFromPath( $dir ) );
+ $bad = array_merge( $bad, getBadHooksFromPath( $dir ) );
+}
-$potenial_inc = getHooksFromPath($pathinc);
-$potential_file = getHooksFromFile($pathfile);
-$potential_lang = getHooksFromFile($pathlang);
-$potential_skin = getHooksFromFile($pathskin);
+$potential = array_unique( $potential );
+$bad = array_unique( $bad );
+$todo = array_diff( $potential, $documented );
+$deprecated = array_diff( $documented, $potential );
-$bad_inc = getBadHooksFromPath($pathinc);
-$bad_file = getBadHooksFromFile($pathfile);
-$bad_lang = getBadHooksFromFile($pathlang);
-$bad_skin = getBadHooksFromFile($pathskin);
-
-$potential = array_merge($potenial_inc, $potential_file, $potential_lang, $potential_skin);
-$bad = array_merge($bad_inc, $bad_file, $bad_lang, $bad_skin);
-
-$todo = array_diff($potential, $documented);
-$deprecated = array_diff($documented, $potential);
-
// let's show the results:
printArray('undocumented', $todo );
printArray('not found', $deprecated );
printArray('unclear hook calls', $bad );
+if ( count( $todo ) == 0 && count( $deprecated ) == 0 && count( $bad ) == 0 )
+ echo "Looks good!\n";
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4144
Default Alt Text
findhooks.patch (2 KB)
Attached To
Mode
T14301: Allow maintenance/findhooks.php to search hooks in multiple directories
Attached
Detach File
Event Timeline
Log In to Comment