Index: trunk/tools/code-utils/check-vars.php |
— | — | @@ -6,10 +6,12 @@ |
7 | 7 | * Run as: |
8 | 8 | * find phase3/ \( -name \*.php -or -name \*.inc \) -not \( -name importUseModWiki.php -o -name diffLanguage.php -o -name LocalSettings.php -o -name Parser?????.php \) -exec php tools/code-utils/check-vars.php \{\} + |
9 | 9 | */ |
| 10 | +if( ! $IP = getenv( 'MW_INSTALL_PATH' ) ) { |
| 11 | + $IP = dirname( __FILE__ ) . "/../../phase3/"; |
| 12 | +} |
| 13 | +require_once( "$IP/includes/Defines.php" ); # Faster than parsing |
| 14 | +require_once( "$IP/includes/AutoLoader.php" ); |
10 | 15 | |
11 | | -require_once( dirname( __FILE__ ) . "/../../phase3/includes/Defines.php" ); # Faster than parsing |
12 | | -require_once( dirname( __FILE__ ) . "/../../phase3/includes/AutoLoader.php" ); |
13 | | - |
14 | 16 | $mwDeprecatedFunctions = false; |
15 | 17 | @include( dirname( __FILE__ ) . "/deprecated.functions" ); |
16 | 18 | |
— | — | @@ -69,8 +71,8 @@ |
70 | 72 | |
71 | 73 | function __construct() { |
72 | 74 | if ( self::$mDefaultSettingsGlobals == null ) { |
73 | | - $this->load( dirname( dirname( dirname( __FILE__ ) ) ) . "/phase3/includes/DefaultSettings.php", false ); |
74 | | - |
| 75 | + global $IP; |
| 76 | + $this->load( "$IP/includes/DefaultSettings.php", false ); |
75 | 77 | if ( count( $this->mTokens ) > 0 ) { |
76 | 78 | $globals = array ( |
77 | 79 | '$wgArticle', # Setup.php |
— | — | @@ -178,9 +180,17 @@ |
179 | 181 | $this->mFunctionQualifiers = array(); |
180 | 182 | |
181 | 183 | |
| 184 | + // Predefine constant that might not be defined by this file source code |
182 | 185 | $this->mConstants = array( 'PARSEKIT_SIMPLE', 'UNORM_NFC', # Extensions |
183 | 186 | /* Defined in Title.php and GlobalFunctions.php */ |
184 | | - 'GAID_FOR_UPDATE', 'TC_MYSQL', 'TS_UNIX', 'TS_MW', 'TS_DB', 'TS_RFC2822', 'TS_ISO_8601', 'TS_EXIF', 'TS_ORACLE', 'TS_POSTGRES', 'TS_DB2' ) ; |
| 187 | + 'GAID_FOR_UPDATE', 'TC_MYSQL', 'TS_UNIX', 'TS_MW', 'TS_DB', 'TS_RFC2822', |
| 188 | + 'TS_ISO_8601', 'TS_EXIF', 'TS_ORACLE', 'TS_POSTGRES', 'TS_DB2', |
| 189 | + 'TS_ISO_8601_BASIC', |
| 190 | + /* PHP extensions */ |
| 191 | + 'FILEINFO_MIME', 'FILEINFO_MIME_TYPE', 'MHASH_ADLER32', |
| 192 | + 'SIGTERM', 'SIG_DFL', |
| 193 | + 'SVN_REVISION_HEAD', 'SVN_REVISION_INITIAL', |
| 194 | + ) ; |
185 | 195 | } |
186 | 196 | |
187 | 197 | static $functionQualifiers = array( T_ABSTRACT, T_PRIVATE, T_PUBLIC, T_PROTECTED, T_STATIC ); |
— | — | @@ -520,12 +530,16 @@ |
521 | 531 | $requirePath .= trim( $token[1], '\'"' ); |
522 | 532 | } else if ( $token[0] == T_VARIABLE ) { |
523 | 533 | if ( $token[1] == '$IP' || $token[1] == '$mwPath' ) { |
524 | | - $requirePath .= dirname( __FILE__ ) . '/../../phase3'; |
| 534 | + #$requirePath .= dirname( __FILE__ ) . '/../../phase3'; |
| 535 | + global $IP; |
| 536 | + $requirePath .= $IP ; |
525 | 537 | } elseif ( $token[1] == '$dir' ) { |
526 | 538 | // Scripts at phase3/maintenance/language/ |
527 | 539 | $requirePath .= dirname( $this->mFilename ); |
528 | 540 | } elseif ( $token[1] == '$wgStyleDirectory' ) { |
529 | | - $requirePath .= dirname( __FILE__ ) . '/../../phase3/skins'; |
| 541 | + #$requirePath .= dirname( __FILE__ ) . '/../../phase3/skins'; |
| 542 | + global $IP; |
| 543 | + $requirePath .= "$IP/skins/"; |
530 | 544 | } elseif ( in_array( $token[1], array( '$classFile', '$file', '$_fileName', '$fileName', '$filename' ) ) ) { |
531 | 545 | /* Maintenance.php lines 374 and 894 */ |
532 | 546 | /* LocalisationCache.php, MessageCache.php, AutoLoader.php */ |
— | — | @@ -534,7 +548,9 @@ |
535 | 549 | $requirePath .= $token[1]; |
536 | 550 | } |
537 | 551 | } elseif ( $token[0] == T_STRING && $token[1] == 'DO_MAINTENANCE' ) { |
538 | | - $requirePath .= dirname( __FILE__ ) . '/../../phase3/maintenance/doMaintenance.php'; |
| 552 | + #$requirePath .= dirname( __FILE__ ) . '/../../phase3/maintenance/doMaintenance.php'; |
| 553 | + global $IP; |
| 554 | + $requirePath .= "$IP/maintenance/doMaintenance.php"; |
539 | 555 | } else { |
540 | 556 | $requirePath .= $token[1]; |
541 | 557 | } |
— | — | @@ -758,7 +774,9 @@ |
759 | 775 | |
760 | 776 | $cv = new CheckVars(); |
761 | 777 | // $cv->mDebug = true; |
762 | | - |
| 778 | +if( $argc < 2 ) { |
| 779 | + die ("Usage: $argv[0] <PHP_source_file> [--generate-deprecated-list]\n"); |
| 780 | +} |
763 | 781 | array_shift( $argv ); |
764 | 782 | if ( $argv[0] == '--generate-deprecated-list' ) { |
765 | 783 | $cv->setGenerateDeprecatedList( true ); |