From: Brion Vibber Date: Fri, 21 Mar 2008 23:13:34 +0000 (+0000) Subject: * (bug 12294) Namespace class renamed to MWNamespace for PHP 5.3 compatibility X-Git-Tag: 1.31.0-rc.0~48888 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=deb20456114af0cf3dbe3fe7e858c60727a6f3a4;p=lhc%2Fweb%2Fwiklou.git * (bug 12294) Namespace class renamed to MWNamespace for PHP 5.3 compatibility * 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! --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 218de1b196..fe91194655 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index cd315cd279..dbc697c9c9 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -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', diff --git a/includes/CoreParserFunctions.php b/includes/CoreParserFunctions.php index dbc18a2bd2..58caf51395 100644 --- a/includes/CoreParserFunctions.php +++ b/includes/CoreParserFunctions.php @@ -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; diff --git a/includes/Export.php b/includes/Export.php index 47a8823526..5605b660d3 100644 --- a/includes/Export.php +++ b/includes/Export.php @@ -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 ); } } diff --git a/includes/Hooks.php b/includes/Hooks.php index 20103db406..0ef2743c96 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -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; diff --git a/includes/Linker.php b/includes/Linker.php index 5b87aa40b5..c3081e3267 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -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]; diff --git a/includes/Namespace.php b/includes/Namespace.php index 57a712824a..b31b2404a1 100644 --- a/includes/Namespace.php +++ b/includes/Namespace.php @@ -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 index 0000000000..d9cbf8803f --- /dev/null +++ b/includes/NamespaceCompat.php @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/includes/Parser_OldPP.php b/includes/Parser_OldPP.php index c10de25755..2aa7e44b23 100644 --- a/includes/Parser_OldPP.php +++ b/includes/Parser_OldPP.php @@ -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 ); } } diff --git a/includes/RecentChange.php b/includes/RecentChange.php index ac647b0540..51511807c0 100644 --- a/includes/RecentChange.php +++ b/includes/RecentChange.php @@ -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(); } diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index dd72dbd7d7..fd84b54698 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -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(); diff --git a/includes/Title.php b/includes/Title.php index 8191b2a565..10987a2fd3 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -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() ); } } diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php index bd2caf003b..5956df91a9 100644 --- a/includes/filerepo/FileRepo.php +++ b/includes/filerepo/FileRepo.php @@ -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(); diff --git a/languages/Language.php b/languages/Language.php index d9aa5f52f7..66cb762534 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -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; } diff --git a/maintenance/generateSitemap.php b/maintenance/generateSitemap.php index 657437bcbf..c0f1189d05 100644 --- a/maintenance/generateSitemap.php +++ b/maintenance/generateSitemap.php @@ -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]; } /**