AutoLoader: Drop support for $wgAutoloadAttemptLowercase
This setting has been deprecated since 1.35. Bug: T231412 Change-Id: I88cb45a2dcbb19c2976824279bf95a66ae9afd91
This commit is contained in:
parent
812befc34a
commit
8ae7194fae
11 changed files with 12 additions and 98 deletions
|
|
@ -51,6 +51,8 @@ For notes on 1.39.x and older releases, see HISTORY.
|
|||
set $wgShellboxUrls instead.
|
||||
* $wgParserTestFiles which was deprecated in 1.30 has now been removed;
|
||||
extensions can place their parser test files in `tests/parser` instead.
|
||||
* (T231412) $wgAutoloadAttemptLowercase, which was deprecated in 1.35,
|
||||
no longer has any effect.
|
||||
* …
|
||||
|
||||
=== New user-facing features in 1.40 ===
|
||||
|
|
|
|||
|
|
@ -6747,14 +6747,6 @@ config-schema:
|
|||
special pages to either a class name to be instantiated, or a callback to use for
|
||||
creating the special page object. In both cases, the result must be an instance of
|
||||
SpecialPage.
|
||||
AutoloadAttemptLowercase:
|
||||
default: false
|
||||
deprecated: 'since 1.35'
|
||||
description: |-
|
||||
Switch controlling legacy case-insensitive classloading.
|
||||
Do not disable if your wiki must support data created by PHP4, or by
|
||||
MediaWiki 1.4 or earlier.
|
||||
@deprecated since 1.35
|
||||
ExtensionCredits:
|
||||
default: { }
|
||||
type: object
|
||||
|
|
|
|||
|
|
@ -85,12 +85,6 @@ class AutoLoader {
|
|||
'Wikimedia\\UUID\\' => __DIR__ . '/libs/uuid/',
|
||||
];
|
||||
|
||||
/**
|
||||
* Cache for lower-case version of the content of $wgAutoloadLocalClasses.
|
||||
* @var array|null
|
||||
*/
|
||||
private static $autoloadLocalClassesLower = null;
|
||||
|
||||
/**
|
||||
* @var string[] Namespace (ends with \) => Path (ends with /)
|
||||
* @internal Will become private in 1.40.
|
||||
|
|
@ -166,7 +160,7 @@ class AutoLoader {
|
|||
* @return string|null The path containing the class, not null if not found
|
||||
*/
|
||||
public static function find( $className ): ?string {
|
||||
global $wgAutoloadLocalClasses, $wgAutoloadClasses, $wgAutoloadAttemptLowercase;
|
||||
global $wgAutoloadLocalClasses, $wgAutoloadClasses;
|
||||
|
||||
// NOTE: $wgAutoloadClasses is supported for compatibility with old-style extension
|
||||
// registration files.
|
||||
|
|
@ -176,25 +170,6 @@ class AutoLoader {
|
|||
$wgAutoloadClasses[$className] ??
|
||||
false;
|
||||
|
||||
if ( !$filename && $wgAutoloadAttemptLowercase ) {
|
||||
// Try a different capitalisation.
|
||||
//
|
||||
// PHP 4 objects are always serialized with the classname coerced to lowercase,
|
||||
// and we are plagued with several legacy uses created by MediaWiki < 1.5, see
|
||||
// https://wikitech.wikimedia.org/wiki/Text_storage_data
|
||||
if ( self::$autoloadLocalClassesLower === null ) {
|
||||
self::$autoloadLocalClassesLower = array_change_key_case( $wgAutoloadLocalClasses, CASE_LOWER );
|
||||
}
|
||||
$lowerClass = strtolower( $className );
|
||||
if ( isset( self::$autoloadLocalClassesLower[$lowerClass] ) ) {
|
||||
if ( function_exists( 'wfDebugLog' ) ) {
|
||||
wfDebugLog( 'autoloader', "Class {$className} was loaded using incorrect case" );
|
||||
}
|
||||
// @phan-suppress-next-line PhanTypeArraySuspiciousNullable
|
||||
$filename = self::$autoloadLocalClassesLower[$lowerClass];
|
||||
}
|
||||
}
|
||||
|
||||
if ( !$filename && strpos( $className, '\\' ) !== false ) {
|
||||
// This class is namespaced, so look in the namespace map
|
||||
$prefix = $className;
|
||||
|
|
@ -246,14 +221,6 @@ class AutoLoader {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to clear the protected class property $autoloadLocalClassesLower.
|
||||
* Used in tests.
|
||||
*/
|
||||
public static function resetAutoloadLocalClassesLower() {
|
||||
self::$autoloadLocalClassesLower = null;
|
||||
}
|
||||
|
||||
///// Methods used during testing //////////////////////////////////////////////
|
||||
private static function assertTesting( $method ) {
|
||||
if ( !defined( 'MW_PHPUNIT_TEST' ) ) {
|
||||
|
|
|
|||
|
|
@ -3859,13 +3859,6 @@ class MainConfigNames {
|
|||
*/
|
||||
public const SpecialPages = 'SpecialPages';
|
||||
|
||||
/**
|
||||
* Name constant for the AutoloadAttemptLowercase setting, for use with Config::get()
|
||||
* @see MainConfigSchema::AutoloadAttemptLowercase
|
||||
* @deprecated since 1.35
|
||||
*/
|
||||
public const AutoloadAttemptLowercase = 'AutoloadAttemptLowercase';
|
||||
|
||||
/**
|
||||
* Name constant for the ExtensionCredits setting, for use with Config::get()
|
||||
* @see MainConfigSchema::ExtensionCredits
|
||||
|
|
|
|||
|
|
@ -10851,16 +10851,20 @@ class MainConfigSchema {
|
|||
];
|
||||
|
||||
/**
|
||||
* Switch controlling legacy case-insensitive classloading.
|
||||
* Obsolete switch that controlled legacy case-insensitive classloading.
|
||||
*
|
||||
* Do not disable if your wiki must support data created by PHP4, or by
|
||||
* MediaWiki 1.4 or earlier.
|
||||
* Case-insensitive classloading was needed for loading data that had
|
||||
* been serialized by PHP 4 with the class names converted to lowercase.
|
||||
* It is no longer necessary since 1.31; the lowercase forms in question
|
||||
* are now listed in autoload.php (T166759).
|
||||
*
|
||||
* @deprecated since 1.35
|
||||
*/
|
||||
public const AutoloadAttemptLowercase = [
|
||||
'default' => false,
|
||||
'deprecated' => 'since 1.35',
|
||||
'obsolete' => 'Since 1.40; no longer has any effect.',
|
||||
'description' => 'Has been emitting warnings since 1.39 (LTS). ' .
|
||||
'Can be removed completely in 1.44, assuming 1.43 is an LTS release.'
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2003,7 +2003,6 @@ return [
|
|||
],
|
||||
'SpecialPages' => [
|
||||
],
|
||||
'AutoloadAttemptLowercase' => false,
|
||||
'ExtensionCredits' => [
|
||||
],
|
||||
'Hooks' => [
|
||||
|
|
@ -3216,9 +3215,6 @@ return [
|
|||
'type' => 'boolean',
|
||||
],
|
||||
],
|
||||
'AutoloadAttemptLowercase' => [
|
||||
'deprecated' => 'since 1.35',
|
||||
],
|
||||
'JobBackoffThrottling' => [
|
||||
'additionalProperties' => [
|
||||
'type' => 'number',
|
||||
|
|
@ -3261,5 +3257,6 @@ return [
|
|||
'obsolete-config' => [
|
||||
'MangleFlashPolicy' => 'Since 1.39; no longer has any effect.',
|
||||
'EnableOpenSearchSuggest' => 'Since 1.35, no longer used',
|
||||
'AutoloadAttemptLowercase' => 'Since 1.40; no longer has any effect.',
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -3843,13 +3843,6 @@ $wgValidSkinNames = null;
|
|||
*/
|
||||
$wgSpecialPages = null;
|
||||
|
||||
/**
|
||||
* Config variable stub for the AutoloadAttemptLowercase setting, for use by phpdoc and IDEs.
|
||||
* @see MediaWiki\MainConfigSchema::AutoloadAttemptLowercase
|
||||
* @deprecated since 1.35
|
||||
*/
|
||||
$wgAutoloadAttemptLowercase = null;
|
||||
|
||||
/**
|
||||
* Config variable stub for the ExtensionCredits setting, for use by phpdoc and IDEs.
|
||||
* @see MediaWiki\MainConfigSchema::ExtensionCredits
|
||||
|
|
|
|||
|
|
@ -56,7 +56,6 @@ abstract class MediaWikiUnitTestCase extends TestCase {
|
|||
'wgAutoloadLocalClasses',
|
||||
// Need for LoggerFactory. Default is NullSpi.
|
||||
'wgMWLoggerDefaultSpi',
|
||||
'wgAutoloadAttemptLowercase',
|
||||
'wgLegalTitleChars',
|
||||
'wgDevelopmentWarnings',
|
||||
// Dependency of wfParseUrl()
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
<?php
|
||||
|
||||
class TestAutoloadedCamlClass {
|
||||
}
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
<?php
|
||||
|
||||
class TestAutoloadedSerializedClass {
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\MainConfigNames;
|
||||
use Wikimedia\TestingAccessWrapper;
|
||||
|
||||
/**
|
||||
|
|
@ -14,16 +13,10 @@ class AutoLoaderTest extends MediaWikiIntegrationTestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
// Fancy dance to trigger a rebuild of AutoLoader::$autoloadLocalClassesLower
|
||||
$this->mergeMwGlobalArrayValue( 'wgAutoloadLocalClasses', [
|
||||
'TestAutoloadedLocalClass' =>
|
||||
__DIR__ . '/../data/autoloader/TestAutoloadedLocalClass.php',
|
||||
'TestAutoloadedCamlClass' =>
|
||||
__DIR__ . '/../data/autoloader/TestAutoloadedCamlClass.php',
|
||||
'TestAutoloadedSerializedClass' =>
|
||||
__DIR__ . '/../data/autoloader/TestAutoloadedSerializedClass.php',
|
||||
] );
|
||||
AutoLoader::resetAutoloadLocalClassesLower();
|
||||
$this->mergeMwGlobalArrayValue( 'wgAutoloadClasses', [
|
||||
'TestAutoloadedClass' => __DIR__ . '/../data/autoloader/TestAutoloadedClass.php',
|
||||
] );
|
||||
|
|
@ -63,24 +56,6 @@ class AutoLoaderTest extends MediaWikiIntegrationTestCase {
|
|||
$this->assertTrue( class_exists( 'TestAutoloadedClass' ) );
|
||||
}
|
||||
|
||||
public function testWrongCaseClass() {
|
||||
$this->overrideConfigValue( MainConfigNames::AutoloadAttemptLowercase, true );
|
||||
|
||||
$this->assertTrue( class_exists( 'testautoLoadedcamlCLASS' ) );
|
||||
}
|
||||
|
||||
public function testWrongCaseSerializedClass() {
|
||||
$this->overrideConfigValue( MainConfigNames::AutoloadAttemptLowercase, true );
|
||||
|
||||
$dummySer = 'O:29:"testautoloadedserializedclass":0:{}';
|
||||
$dummy = unserialize( $dummySer );
|
||||
$this->assertSame(
|
||||
get_class( $dummy ),
|
||||
TestAutoloadedSerializedClass::class,
|
||||
'load class case-insensitively'
|
||||
);
|
||||
}
|
||||
|
||||
public function testPsr4() {
|
||||
$this->assertTrue( class_exists( 'Test\\MediaWiki\\AutoLoader\\TestFooBar' ) );
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue