MediaWiki REL1_30
AutoLoader.php
Go to the documentation of this file.
1<?php
28require_once __DIR__ . '/../autoload.php';
29
31 static protected $autoloadLocalClassesLower = null;
32
38 static function autoload( $className ) {
41
42 $filename = false;
43
44 if ( isset( $wgAutoloadLocalClasses[$className] ) ) {
45 $filename = $wgAutoloadLocalClasses[$className];
46 } elseif ( isset( $wgAutoloadClasses[$className] ) ) {
47 $filename = $wgAutoloadClasses[$className];
48 } elseif ( $wgAutoloadAttemptLowercase ) {
49 /*
50 * Try a different capitalisation.
51 *
52 * PHP 4 objects are always serialized with the classname coerced to lowercase,
53 * and we are plagued with several legacy uses created by MediaWiki < 1.5, see
54 * https://wikitech.wikimedia.org/wiki/Text_storage_data
55 */
56 $lowerClass = strtolower( $className );
57
58 if ( self::$autoloadLocalClassesLower === null ) {
59 self::$autoloadLocalClassesLower = array_change_key_case( $wgAutoloadLocalClasses, CASE_LOWER );
60 }
61
62 if ( isset( self::$autoloadLocalClassesLower[$lowerClass] ) ) {
63 if ( function_exists( 'wfDebugLog' ) ) {
64 wfDebugLog( 'autoloader', "Class {$className} was loaded using incorrect case" );
65 }
66 $filename = self::$autoloadLocalClassesLower[$lowerClass];
67 }
68 }
69
70 if ( !$filename ) {
71 // Class not found; let the next autoloader try to find it
72 return;
73 }
74
75 // Make an absolute path, this improves performance by avoiding some stat calls
76 if ( substr( $filename, 0, 1 ) != '/' && substr( $filename, 1, 1 ) != ':' ) {
77 global $IP;
78 $filename = "$IP/$filename";
79 }
80
81 require $filename;
82 }
83
89 self::$autoloadLocalClassesLower = null;
90 }
91}
92
93spl_autoload_register( [ 'AutoLoader', 'autoload' ] );
$wgAutoloadAttemptLowercase
Switch controlling legacy case-insensitive classloading.
$wgAutoloadClasses
Array mapping class names to filenames, for autoloading.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
global $wgAutoloadLocalClasses
Definition autoload.php:4
Locations of core classes Extension classes are specified with $wgAutoloadClasses This array is a glo...
static $autoloadLocalClassesLower
static autoload( $className)
autoload - take a class name and attempt to load it
static resetAutoloadLocalClassesLower()
Method to clear the protected class property $autoloadLocalClassesLower.
$IP
Definition update.php:3