* (bug 12294) Namespace class renamed to MWNamespace for PHP 5.3 compatibility
authorBrion Vibber <brion@users.mediawiki.org>
Fri, 21 Mar 2008 23:13:34 +0000 (23:13 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Fri, 21 Mar 2008 23:13:34 +0000 (23:13 +0000)
* PHP 5.3 compatibility fix for wfRunHooks() called with no parameters

An autoloaded 'Namespace' class alias is retained for compatibility with
extensions which haven't updated to the new class name... however they too
will break on PHP 5.3. Yay!

15 files changed:
RELEASE-NOTES
includes/AutoLoader.php
includes/CoreParserFunctions.php
includes/Export.php
includes/Hooks.php
includes/Linker.php
includes/Namespace.php
includes/NamespaceCompat.php [new file with mode: 0644]
includes/Parser_OldPP.php
includes/RecentChange.php
includes/SkinTemplate.php
includes/Title.php
includes/filerepo/FileRepo.php
languages/Language.php
maintenance/generateSitemap.php

index 218de1b..fe91194 100644 (file)
@@ -118,6 +118,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   using the "delete and move" option.
 * (bug 13466) White space differences not shown in diffs
 * (bug 1953) Search form now honors namespace selections more reliably
+* (bug 12294) Namespace class renamed to MWNamespace for PHP 5.3 compatibility
+* PHP 5.3 compatibility fix for wfRunHooks() called with no parameters
 
 
 === API changes in 1.13 ===
index cd315cd..dbc697c 100644 (file)
@@ -156,8 +156,9 @@ function __autoload($className) {
                'MostrevisionsPage' => 'includes/SpecialMostrevisions.php',
                'MovePageForm' => 'includes/SpecialMovepage.php',
                'MWException' => 'includes/Exception.php',
+               'MWNamespace' => 'includes/Namespace.php',
                'MySQLSearchResultSet' => 'includes/SearchMySQL.php',
-               'Namespace' => 'includes/Namespace.php',
+               'Namespace' => 'includes/NamespaceCompat.php', // Compat
                'NewbieContributionsPage' => 'includes/SpecialNewbieContributions.php',
                'NewPagesPage' => 'includes/SpecialNewpages.php',
                'OldChangesList' => 'includes/ChangesList.php',
index dbc18a2..58caf51 100644 (file)
@@ -68,7 +68,7 @@ class CoreParserFunctions {
                        $found = true;
                } else {
                        $param = str_replace( ' ', '_', strtolower( $part1 ) );
-                       $index = Namespace::getCanonicalIndex( strtolower( $param ) );
+                       $index = MWNamespace::getCanonicalIndex( strtolower( $param ) );
                        if ( !is_null( $index ) ) {
                                $text = $wgContLang->getNsText( $index );
                                $found = true;
index 47a8823..5605b66 100644 (file)
@@ -668,7 +668,7 @@ class DumpFilter {
  */
 class DumpNotalkFilter extends DumpFilter {
        function pass( $page ) {
-               return !Namespace::isTalk( $page->page_namespace );
+               return !MWNamespace::isTalk( $page->page_namespace );
        }
 }
 
index 20103db..0ef2743 100644 (file)
@@ -27,7 +27,7 @@
  * careful about its contents. So, there's a lot more error-checking
  * in here than would normally be necessary.
  */
-function wfRunHooks($event, $args = null) {
+function wfRunHooks($event, $args = array()) {
 
        global $wgHooks;
 
index 5b87aa4..c3081e3 100644 (file)
@@ -1065,7 +1065,7 @@ class Linker {
        protected function formatLinksInCommentCallback( $match ) {
                global $wgContLang;
 
-               $medians = '(?:' . preg_quote( Namespace::getCanonicalName( NS_MEDIA ), '/' ) . '|';
+               $medians = '(?:' . preg_quote( MWNamespace::getCanonicalName( NS_MEDIA ), '/' ) . '|';
                $medians .= preg_quote( $wgContLang->getNsText( NS_MEDIA ), '/' ) . '):';
                
                $comment = $match[0];
index 57a7128..b31b240 100644 (file)
@@ -42,11 +42,7 @@ if( is_array( $wgExtraNamespaces ) ) {
  *
  */
 
-/*
-WARNING: The statement below may fail on some versions of PHP: see bug 12294
-*/
-
-class Namespace {
+class MWNamespace {
 
        /**
         * Can pages in the given namespace be moved?
diff --git a/includes/NamespaceCompat.php b/includes/NamespaceCompat.php
new file mode 100644 (file)
index 0000000..d9cbf88
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+
+// For compatibility with extensions...
+// Will still die on PHP 5.3, of course. :P
+
+class Namespace extends MWNamespace {
+       // ..
+}
+
+?>
\ No newline at end of file
index c10de25..2aa7e44 100644 (file)
@@ -4156,7 +4156,7 @@ class Parser_OldPP
                                        $colours[$pdbk] = ( $threshold == 0 || (
                                                                $s->page_len >= $threshold || # always true if $threshold <= 0
                                                                $s->page_is_redirect ||
-                                                               !Namespace::isContent( $s->page_namespace ) )
+                                                               !MWNamespace::isContent( $s->page_namespace ) )
                                                            ? 1 : 2 );
                                }
                        }
index ac647b0..5151180 100644 (file)
@@ -547,7 +547,7 @@ class RecentChange
 
                $titleObj =& $this->getTitle();
                if ( $rc_type == RC_LOG ) {
-                       $title = Namespace::getCanonicalName( $titleObj->getNamespace() ) . $titleObj->getText();
+                       $title = MWNamespace::getCanonicalName( $titleObj->getNamespace() ) . $titleObj->getText();
                } else {
                        $title = $titleObj->getPrefixedText();
                }
index dd72dbd..fd84b54 100644 (file)
@@ -596,7 +596,7 @@ class SkinTemplate extends Skin {
                $text = wfMsg( $message );
                if ( wfEmptyMsg( $message, $text ) ) {
                        global $wgContLang;
-                       $text = $wgContLang->getFormattedNsText( Namespace::getSubject( $title->getNamespace() ) );
+                       $text = $wgContLang->getFormattedNsText( MWNamespace::getSubject( $title->getNamespace() ) );
                }
                
                $result = array();
index 8191b2a..10987a2 100644 (file)
@@ -577,7 +577,7 @@ class Title {
         */
        public function getSubjectNsText() {
                global $wgContLang;
-               return $wgContLang->getNsText( Namespace::getSubject( $this->mNamespace ) );
+               return $wgContLang->getNsText( MWNamespace::getSubject( $this->mNamespace ) );
        }
 
        /**
@@ -586,7 +586,7 @@ class Title {
         */
        public function getTalkNsText() {
                global $wgContLang;
-               return( $wgContLang->getNsText( Namespace::getTalk( $this->mNamespace ) ) );
+               return( $wgContLang->getNsText( MWNamespace::getTalk( $this->mNamespace ) ) );
        }
 
        /**
@@ -594,7 +594,7 @@ class Title {
         * @return bool
         */
        public function canTalk() {
-               return( Namespace::canTalk( $this->mNamespace ) );
+               return( MWNamespace::canTalk( $this->mNamespace ) );
        }
 
        /**
@@ -1377,7 +1377,7 @@ class Title {
         * @return boolean
         */
        public function isMovable() {
-               return Namespace::isMovable( $this->getNamespace() )
+               return MWNamespace::isMovable( $this->getNamespace() )
                        && $this->getInterwiki() == '';
        }
 
@@ -1461,7 +1461,7 @@ class Title {
         * @return bool
         */
        public function isTalkPage() {
-               return Namespace::isTalk( $this->getNamespace() );
+               return MWNamespace::isTalk( $this->getNamespace() );
        }
 
        /**
@@ -2140,7 +2140,7 @@ class Title {
         * @return Title the object for the talk page
         */
        public function getTalkPage() {
-               return Title::makeTitle( Namespace::getTalk( $this->getNamespace() ), $this->getDBkey() );
+               return Title::makeTitle( MWNamespace::getTalk( $this->getNamespace() ), $this->getDBkey() );
        }
 
        /**
@@ -2150,7 +2150,7 @@ class Title {
         * @return Title the object for the subject page
         */
        public function getSubjectPage() {
-               return Title::makeTitle( Namespace::getSubject( $this->getNamespace() ), $this->getDBkey() );
+               return Title::makeTitle( MWNamespace::getSubject( $this->getNamespace() ), $this->getDBkey() );
        }
 
        /**
@@ -2691,7 +2691,7 @@ class Title {
         */
        public function isWatchable() {
                return !$this->isExternal()
-                       && Namespace::isWatchable( $this->getNamespace() );
+                       && MWNamespace::isWatchable( $this->getNamespace() );
        }
 
        /**
@@ -2986,7 +2986,7 @@ class Title {
         * @return bool
         */
        public function isContentPage() {
-               return Namespace::isContent( $this->getNamespace() );
+               return MWNamespace::isContent( $this->getNamespace() );
        }
        
 }
index bd2caf0..5956df9 100644 (file)
@@ -169,10 +169,10 @@ abstract class FileRepo {
                if ( is_null( $this->descBaseUrl ) ) {
                        if ( !is_null( $this->articleUrl ) ) {
                                $this->descBaseUrl = str_replace( '$1', 
-                                       wfUrlencode( Namespace::getCanonicalName( NS_IMAGE ) ) . ':', $this->articleUrl );
+                                       wfUrlencode( MWNamespace::getCanonicalName( NS_IMAGE ) ) . ':', $this->articleUrl );
                        } elseif ( !is_null( $this->scriptDirUrl ) ) {
                                $this->descBaseUrl = $this->scriptDirUrl . '/index.php?title=' . 
-                                       wfUrlencode( Namespace::getCanonicalName( NS_IMAGE ) ) . ':';
+                                       wfUrlencode( MWNamespace::getCanonicalName( NS_IMAGE ) ) . ':';
                        } else {
                                $this->descBaseUrl = false;
                        }
@@ -207,7 +207,7 @@ abstract class FileRepo {
        function getDescriptionRenderUrl( $name ) {
                if ( isset( $this->scriptDirUrl ) ) {
                        return $this->scriptDirUrl . '/index.php?title=' . 
-                               wfUrlencode( Namespace::getCanonicalName( NS_IMAGE ) . ':' . $name ) .
+                               wfUrlencode( MWNamespace::getCanonicalName( NS_IMAGE ) . ':' . $name ) .
                                '&action=render';
                } else {
                        $descBase = $this->getDescBaseUrl();
index d9aa5f5..66cb762 100644 (file)
@@ -264,7 +264,7 @@ class Language {
        function getNsIndex( $text ) {
                $this->load();
                $lctext = $this->lc($text);
-               if( ( $ns = Namespace::getCanonicalIndex( $lctext ) ) !== null ) return $ns;
+               if( ( $ns = MWNamespace::getCanonicalIndex( $lctext ) ) !== null ) return $ns;
                return isset( $this->mNamespaceIds[$lctext] ) ? $this->mNamespaceIds[$lctext] : false;
        }
 
index 657437b..c0f1189 100644 (file)
@@ -200,7 +200,7 @@ class GenerateSitemap {
         * @return string
         */
        function guessPriority( $namespace ) {
-               return Namespace::isMain( $namespace ) ? $this->priorities[GS_MAIN] : $this->priorities[GS_TALK];
+               return MWNamespace::isMain( $namespace ) ? $this->priorities[GS_MAIN] : $this->priorities[GS_TALK];
        }
 
        /**