r32309 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r32308‎ | r32309 | r32310 >
Date:23:13, 21 March 2008
Author:brion
Status:old
Tags:
Comment:
* (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!
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/AutoLoader.php (modified) (history)
  • /trunk/phase3/includes/CoreParserFunctions.php (modified) (history)
  • /trunk/phase3/includes/Export.php (modified) (history)
  • /trunk/phase3/includes/Hooks.php (modified) (history)
  • /trunk/phase3/includes/Linker.php (modified) (history)
  • /trunk/phase3/includes/Namespace.php (modified) (history)
  • /trunk/phase3/includes/NamespaceCompat.php (added) (history)
  • /trunk/phase3/includes/Parser_OldPP.php (modified) (history)
  • /trunk/phase3/includes/RecentChange.php (modified) (history)
  • /trunk/phase3/includes/SkinTemplate.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/includes/filerepo/FileRepo.php (modified) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)
  • /trunk/phase3/maintenance/generateSitemap.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/generateSitemap.php
@@ -200,7 +200,7 @@
201201 * @return string
202202 */
203203 function guessPriority( $namespace ) {
204 - return Namespace::isMain( $namespace ) ? $this->priorities[GS_MAIN] : $this->priorities[GS_TALK];
 204+ return MWNamespace::isMain( $namespace ) ? $this->priorities[GS_MAIN] : $this->priorities[GS_TALK];
205205 }
206206
207207 /**
Index: trunk/phase3/includes/RecentChange.php
@@ -547,7 +547,7 @@
548548
549549 $titleObj =& $this->getTitle();
550550 if ( $rc_type == RC_LOG ) {
551 - $title = Namespace::getCanonicalName( $titleObj->getNamespace() ) . $titleObj->getText();
 551+ $title = MWNamespace::getCanonicalName( $titleObj->getNamespace() ) . $titleObj->getText();
552552 } else {
553553 $title = $titleObj->getPrefixedText();
554554 }
Index: trunk/phase3/includes/NamespaceCompat.php
@@ -0,0 +1,10 @@
 2+<?php
 3+
 4+// For compatibility with extensions...
 5+// Will still die on PHP 5.3, of course. :P
 6+
 7+class Namespace extends MWNamespace {
 8+ // ..
 9+}
 10+
 11+?>
\ No newline at end of file
Property changes on: trunk/phase3/includes/NamespaceCompat.php
___________________________________________________________________
Added: svn:eol-style
112 + native
Index: trunk/phase3/includes/Linker.php
@@ -1065,7 +1065,7 @@
10661066 protected function formatLinksInCommentCallback( $match ) {
10671067 global $wgContLang;
10681068
1069 - $medians = '(?:' . preg_quote( Namespace::getCanonicalName( NS_MEDIA ), '/' ) . '|';
 1069+ $medians = '(?:' . preg_quote( MWNamespace::getCanonicalName( NS_MEDIA ), '/' ) . '|';
10701070 $medians .= preg_quote( $wgContLang->getNsText( NS_MEDIA ), '/' ) . '):';
10711071
10721072 $comment = $match[0];
Index: trunk/phase3/includes/filerepo/FileRepo.php
@@ -169,10 +169,10 @@
170170 if ( is_null( $this->descBaseUrl ) ) {
171171 if ( !is_null( $this->articleUrl ) ) {
172172 $this->descBaseUrl = str_replace( '$1',
173 - wfUrlencode( Namespace::getCanonicalName( NS_IMAGE ) ) . ':', $this->articleUrl );
 173+ wfUrlencode( MWNamespace::getCanonicalName( NS_IMAGE ) ) . ':', $this->articleUrl );
174174 } elseif ( !is_null( $this->scriptDirUrl ) ) {
175175 $this->descBaseUrl = $this->scriptDirUrl . '/index.php?title=' .
176 - wfUrlencode( Namespace::getCanonicalName( NS_IMAGE ) ) . ':';
 176+ wfUrlencode( MWNamespace::getCanonicalName( NS_IMAGE ) ) . ':';
177177 } else {
178178 $this->descBaseUrl = false;
179179 }
@@ -207,7 +207,7 @@
208208 function getDescriptionRenderUrl( $name ) {
209209 if ( isset( $this->scriptDirUrl ) ) {
210210 return $this->scriptDirUrl . '/index.php?title=' .
211 - wfUrlencode( Namespace::getCanonicalName( NS_IMAGE ) . ':' . $name ) .
 211+ wfUrlencode( MWNamespace::getCanonicalName( NS_IMAGE ) . ':' . $name ) .
212212 '&action=render';
213213 } else {
214214 $descBase = $this->getDescBaseUrl();
Index: trunk/phase3/includes/Export.php
@@ -668,7 +668,7 @@
669669 */
670670 class DumpNotalkFilter extends DumpFilter {
671671 function pass( $page ) {
672 - return !Namespace::isTalk( $page->page_namespace );
 672+ return !MWNamespace::isTalk( $page->page_namespace );
673673 }
674674 }
675675
Index: trunk/phase3/includes/Hooks.php
@@ -27,7 +27,7 @@
2828 * careful about its contents. So, there's a lot more error-checking
2929 * in here than would normally be necessary.
3030 */
31 -function wfRunHooks($event, $args = null) {
 31+function wfRunHooks($event, $args = array()) {
3232
3333 global $wgHooks;
3434
Index: trunk/phase3/includes/Parser_OldPP.php
@@ -4156,7 +4156,7 @@
41574157 $colours[$pdbk] = ( $threshold == 0 || (
41584158 $s->page_len >= $threshold || # always true if $threshold <= 0
41594159 $s->page_is_redirect ||
4160 - !Namespace::isContent( $s->page_namespace ) )
 4160+ !MWNamespace::isContent( $s->page_namespace ) )
41614161 ? 1 : 2 );
41624162 }
41634163 }
Index: trunk/phase3/includes/AutoLoader.php
@@ -156,8 +156,9 @@
157157 'MostrevisionsPage' => 'includes/SpecialMostrevisions.php',
158158 'MovePageForm' => 'includes/SpecialMovepage.php',
159159 'MWException' => 'includes/Exception.php',
 160+ 'MWNamespace' => 'includes/Namespace.php',
160161 'MySQLSearchResultSet' => 'includes/SearchMySQL.php',
161 - 'Namespace' => 'includes/Namespace.php',
 162+ 'Namespace' => 'includes/NamespaceCompat.php', // Compat
162163 'NewbieContributionsPage' => 'includes/SpecialNewbieContributions.php',
163164 'NewPagesPage' => 'includes/SpecialNewpages.php',
164165 'OldChangesList' => 'includes/ChangesList.php',
Index: trunk/phase3/includes/Title.php
@@ -577,7 +577,7 @@
578578 */
579579 public function getSubjectNsText() {
580580 global $wgContLang;
581 - return $wgContLang->getNsText( Namespace::getSubject( $this->mNamespace ) );
 581+ return $wgContLang->getNsText( MWNamespace::getSubject( $this->mNamespace ) );
582582 }
583583
584584 /**
@@ -586,7 +586,7 @@
587587 */
588588 public function getTalkNsText() {
589589 global $wgContLang;
590 - return( $wgContLang->getNsText( Namespace::getTalk( $this->mNamespace ) ) );
 590+ return( $wgContLang->getNsText( MWNamespace::getTalk( $this->mNamespace ) ) );
591591 }
592592
593593 /**
@@ -594,7 +594,7 @@
595595 * @return bool
596596 */
597597 public function canTalk() {
598 - return( Namespace::canTalk( $this->mNamespace ) );
 598+ return( MWNamespace::canTalk( $this->mNamespace ) );
599599 }
600600
601601 /**
@@ -1377,7 +1377,7 @@
13781378 * @return boolean
13791379 */
13801380 public function isMovable() {
1381 - return Namespace::isMovable( $this->getNamespace() )
 1381+ return MWNamespace::isMovable( $this->getNamespace() )
13821382 && $this->getInterwiki() == '';
13831383 }
13841384
@@ -1461,7 +1461,7 @@
14621462 * @return bool
14631463 */
14641464 public function isTalkPage() {
1465 - return Namespace::isTalk( $this->getNamespace() );
 1465+ return MWNamespace::isTalk( $this->getNamespace() );
14661466 }
14671467
14681468 /**
@@ -2140,7 +2140,7 @@
21412141 * @return Title the object for the talk page
21422142 */
21432143 public function getTalkPage() {
2144 - return Title::makeTitle( Namespace::getTalk( $this->getNamespace() ), $this->getDBkey() );
 2144+ return Title::makeTitle( MWNamespace::getTalk( $this->getNamespace() ), $this->getDBkey() );
21452145 }
21462146
21472147 /**
@@ -2150,7 +2150,7 @@
21512151 * @return Title the object for the subject page
21522152 */
21532153 public function getSubjectPage() {
2154 - return Title::makeTitle( Namespace::getSubject( $this->getNamespace() ), $this->getDBkey() );
 2154+ return Title::makeTitle( MWNamespace::getSubject( $this->getNamespace() ), $this->getDBkey() );
21552155 }
21562156
21572157 /**
@@ -2691,7 +2691,7 @@
26922692 */
26932693 public function isWatchable() {
26942694 return !$this->isExternal()
2695 - && Namespace::isWatchable( $this->getNamespace() );
 2695+ && MWNamespace::isWatchable( $this->getNamespace() );
26962696 }
26972697
26982698 /**
@@ -2986,7 +2986,7 @@
29872987 * @return bool
29882988 */
29892989 public function isContentPage() {
2990 - return Namespace::isContent( $this->getNamespace() );
 2990+ return MWNamespace::isContent( $this->getNamespace() );
29912991 }
29922992
29932993 }
Index: trunk/phase3/includes/Namespace.php
@@ -42,12 +42,8 @@
4343 *
4444 */
4545
46 -/*
47 -WARNING: The statement below may fail on some versions of PHP: see bug 12294
48 -*/
 46+class MWNamespace {
4947
50 -class Namespace {
51 -
5248 /**
5349 * Can pages in the given namespace be moved?
5450 *
Index: trunk/phase3/includes/SkinTemplate.php
@@ -596,7 +596,7 @@
597597 $text = wfMsg( $message );
598598 if ( wfEmptyMsg( $message, $text ) ) {
599599 global $wgContLang;
600 - $text = $wgContLang->getFormattedNsText( Namespace::getSubject( $title->getNamespace() ) );
 600+ $text = $wgContLang->getFormattedNsText( MWNamespace::getSubject( $title->getNamespace() ) );
601601 }
602602
603603 $result = array();
Index: trunk/phase3/includes/CoreParserFunctions.php
@@ -68,7 +68,7 @@
6969 $found = true;
7070 } else {
7171 $param = str_replace( ' ', '_', strtolower( $part1 ) );
72 - $index = Namespace::getCanonicalIndex( strtolower( $param ) );
 72+ $index = MWNamespace::getCanonicalIndex( strtolower( $param ) );
7373 if ( !is_null( $index ) ) {
7474 $text = $wgContLang->getNsText( $index );
7575 $found = true;
Index: trunk/phase3/languages/Language.php
@@ -264,7 +264,7 @@
265265 function getNsIndex( $text ) {
266266 $this->load();
267267 $lctext = $this->lc($text);
268 - if( ( $ns = Namespace::getCanonicalIndex( $lctext ) ) !== null ) return $ns;
 268+ if( ( $ns = MWNamespace::getCanonicalIndex( $lctext ) ) !== null ) return $ns;
269269 return isset( $this->mNamespaceIds[$lctext] ) ? $this->mNamespaceIds[$lctext] : false;
270270 }
271271
Index: trunk/phase3/RELEASE-NOTES
@@ -118,6 +118,8 @@
119119 using the "delete and move" option.
120120 * (bug 13466) White space differences not shown in diffs
121121 * (bug 1953) Search form now honors namespace selections more reliably
 122+* (bug 12294) Namespace class renamed to MWNamespace for PHP 5.3 compatibility
 123+* PHP 5.3 compatibility fix for wfRunHooks() called with no parameters
122124
123125
124126 === API changes in 1.13 ===

Follow-up revisions

RevisionCommit summaryAuthorDate
r45025Some PHP 5.3 compatibility fixes for extensions...siebrand13:59, 25 December 2008

Status & tagging log