Hashar has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/64926


Change subject: deprecate autoloading a class with mismatching case.
......................................................................

deprecate autoloading a class with mismatching case.

PHP 4.x had a bug [26762] which caused unserialize() to produce an
object with a lower cased class name.  To workaround it, we normalized
the class lookup using lowercase() [r15226] / 2ff28872 .

The fix landed in PHP version 5.0.0 beta4 (January 2004).

Whenever a class is not matched directly, we end up doing a foreach with
two lowercase() calls.  Whenever we have registered other autoloader
(such as the PHPUnit one for unit tests), we slightly delay the class
lookup.

This patch deprecates the lowercase() lookup, letting extension authors
update their code.  MediaWiki will output a deprecation notice such as:

  Deprecated: Use of Class 'UnwatchedPagesPage' case  mismatch
  registered 'UnwatchedpagesPage'. Please update your call. was
  deprecated in MediaWiki 1.22.

Patch also fix two such occurences in core.

[26762] https://bugs.php.net/bug.php?id=26762
[r15226] https://www.mediawiki.org/wiki/Special:Code/MediaWiki/15226

Change-Id: I30128e5120b3a5e457a4bafa7b26c3b9babca650
---
M RELEASE-NOTES-1.22
M includes/AutoLoader.php
M includes/QueryPage.php
3 files changed, 17 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/26/64926/1

diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22
index 04861fc..8910911 100644
--- a/RELEASE-NOTES-1.22
+++ b/RELEASE-NOTES-1.22
@@ -170,6 +170,10 @@
   to redirect through Special:Redirect.
 * Monobook: Removed the old conditional stylesheets for Opera 6, 7 and 9.
 * Support for XHTML 1.0 has been removed. MediaWiki now only outputs (X)HTML5.
+* MediaWiki autoloader attempts to find the requested class using a form
+  normalized lower case. That adds unnecessary overhead and is now being
+  deprecated. Make sure your class call match the class name registered in
+  includes/AutoLoader.php or $wgAutoloadClasses.
 
 == Compatibility ==
 
diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php
index 3e08e74..371391e 100644
--- a/includes/AutoLoader.php
+++ b/includes/AutoLoader.php
@@ -1126,12 +1126,23 @@
                } else {
                        # Try a different capitalisation
                        # The case can sometimes be wrong when unserializing 
PHP 4 objects
+                       # https://bugs.php.net/bug.php?id=26762 (fixed in PHP 
v5.0.0 beta4).
+                       #
+                       # We want to eventually get rid of this and are thus 
emitting a
+                       # deprecation warning.
+
                        $filename = false;
                        $lowerClass = strtolower( $className );
 
                        foreach ( $wgAutoloadLocalClasses as $class2 => $file2 
) {
                                if ( strtolower( $class2 ) == $lowerClass ) {
                                        $filename = $file2;
+                                       if ( function_exists( 'wfDeprecated' ) 
) {
+                                               # Fixed in PHP v5.0.0 beta4!
+                                               wfDeprecated( "Class 
'$className' case  mismatch registered '$class2'." .
+                                                       " Please update your 
call.", '1.22' );
+                                       }
+
                                }
                        }
 
diff --git a/includes/QueryPage.php b/includes/QueryPage.php
index a93639a..7ccad27 100644
--- a/includes/QueryPage.php
+++ b/includes/QueryPage.php
@@ -47,7 +47,7 @@
        array( 'MostimagesPage',                'Mostimages'                    
),
        array( 'MostinterwikisPage',            'Mostinterwikis'                
),
        array( 'MostlinkedCategoriesPage',      'Mostlinkedcategories'          
),
-       array( 'MostlinkedtemplatesPage',       'Mostlinkedtemplates'           
),
+       array( 'MostlinkedTemplatesPage',       'Mostlinkedtemplates'           
),
        array( 'MostlinkedPage',                'Mostlinked'                    
),
        array( 'MostrevisionsPage',             'Mostrevisions'                 
),
        array( 'FewestrevisionsPage',           'Fewestrevisions'               
),
@@ -62,7 +62,7 @@
        array( 'WantedFilesPage',               'Wantedfiles'                   
),
        array( 'WantedPagesPage',               'Wantedpages'                   
),
        array( 'WantedTemplatesPage',           'Wantedtemplates'               
),
-       array( 'UnwatchedPagesPage',            'Unwatchedpages'                
),
+       array( 'UnwatchedpagesPage',            'Unwatchedpages'                
),
        array( 'UnusedtemplatesPage',           'Unusedtemplates'               
),
        array( 'WithoutInterwikiPage',          'Withoutinterwiki'              
),
 );

-- 
To view, visit https://gerrit.wikimedia.org/r/64926
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I30128e5120b3a5e457a4bafa7b26c3b9babca650
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Hashar <has...@free.fr>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to