MediaWiki  REL1_19
checkAutoLoader.php
Go to the documentation of this file.
00001 <?php
00024 require_once( dirname( __FILE__ ) . '/Maintenance.php' );
00025 
00026 class CheckAutoLoader extends Maintenance {
00027         public function __construct() {
00028                 parent::__construct();
00029                 $this->mDescription = "AutoLoader sanity checks";
00030         }
00031         public function execute() {
00032                 global $wgAutoloadLocalClasses, $IP;
00033                 $files = array_unique( $wgAutoloadLocalClasses );
00034 
00035                 foreach ( $files as $file ) {
00036                         if ( function_exists( 'parsekit_compile_file' ) ) {
00037                                 $parseInfo = parsekit_compile_file( "$IP/$file" );
00038                                 $classes = array_keys( $parseInfo['class_table'] );
00039                         } else {
00040                                 $contents = file_get_contents( "$IP/$file" );
00041                                 $m = array();
00042                                 preg_match_all( '/\n\s*class\s+([a-zA-Z0-9_]+)/', $contents, $m, PREG_PATTERN_ORDER );
00043                                 $classes = $m[1];
00044                         }
00045                         foreach ( $classes as $class ) {
00046                                 if ( !isset( $wgAutoloadLocalClasses[$class] ) ) {
00047                                         // printf( "%-50s Unlisted, in %s\n", $class, $file );
00048                                         $this->output( "\t'$class' => '$file',\n" );
00049                                 } elseif ( $wgAutoloadLocalClasses[$class] !== $file ) {
00050                                         $this->output( "$class: Wrong file: found in $file, listed in " . $wgAutoloadLocalClasses[$class] . "\n" );
00051                                 }
00052                         }
00053                 }
00054         }
00055 }
00056 
00057 $maintClass = "CheckAutoLoader";
00058 require_once( RUN_MAINTENANCE_IF_MAIN );