* (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!
This commit is contained in:
Brion Vibber 2008-03-21 23:13:34 +00:00
parent 0924a30333
commit deb2045611
15 changed files with 36 additions and 27 deletions

View 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 ===

View 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',

View 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;

View 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 );
}
}

View 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;

View 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];

View 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?

View file

@ -0,0 +1,10 @@
<?php
// For compatibility with extensions...
// Will still die on PHP 5.3, of course. :P
class Namespace extends MWNamespace {
// ..
}
?>

View 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 );
}
}

View 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();
}

View 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();

View 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() );
}
}

View 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();

View 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;
}

View 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];
}
/**