r101680 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101679‎ | r101680 | r101681 >
Date:20:55, 2 November 2011
Author:aaron
Status:ok
Tags:
Comment:
Make use of Title::isSpecialPage() in various places
Modified paths:
  • /trunk/phase3/includes/Linker.php (modified) (history)
  • /trunk/phase3/includes/LogPage.php (modified) (history)
  • /trunk/phase3/includes/Skin.php (modified) (history)
  • /trunk/phase3/includes/SkinLegacy.php (modified) (history)
  • /trunk/phase3/includes/SkinTemplate.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/includes/Wiki.php (modified) (history)
  • /trunk/phase3/includes/WikiPage.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQuery.php (modified) (history)
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)
  • /trunk/phase3/includes/search/SearchEngine.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialRevisiondelete.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/search/SearchEngine.php
@@ -171,7 +171,7 @@
172172 return null;
173173 }
174174
175 - if ( $title->getNamespace() == NS_SPECIAL || $title->isExternal() || $title->exists() ) {
 175+ if ( $title->isSpecialPage() || $title->isExternal() || $title->exists() ) {
176176 return $title;
177177 }
178178
Index: trunk/phase3/includes/parser/Parser.php
@@ -3220,7 +3220,7 @@
32213221 wfProfileIn( $titleProfileIn ); // template in
32223222 wfProfileIn( __METHOD__ . '-loadtpl' );
32233223 if ( !$title->isExternal() ) {
3224 - if ( $title->getNamespace() == NS_SPECIAL
 3224+ if ( $title->isSpecialPage()
32253225 && $this->mOptions->getAllowSpecialInclusion()
32263226 && $this->ot['html'] )
32273227 {
Index: trunk/phase3/includes/Linker.php
@@ -250,7 +250,7 @@
251251 # there's already an action specified, or unless 'edit' makes no sense
252252 # (i.e., for a nonexistent special page).
253253 if ( in_array( 'broken', $options ) && empty( $query['action'] )
254 - && $target->getNamespace() != NS_SPECIAL ) {
 254+ && !$target->isSpecialPage() ) {
255255 $query['action'] = 'edit';
256256 $query['redlink'] = '1';
257257 }
@@ -389,7 +389,7 @@
390390 * @return Title
391391 */
392392 static function normaliseSpecialPage( Title $title ) {
393 - if ( $title->getNamespace() == NS_SPECIAL ) {
 393+ if ( $title->isSpecialPage() ) {
394394 list( $name, $subpage ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
395395 if ( !$name ) {
396396 return $title;
Index: trunk/phase3/includes/api/ApiQuery.php
@@ -443,7 +443,7 @@
444444 $vals = array();
445445 ApiQueryBase::addTitleInfo( $vals, $title );
446446 $vals['special'] = '';
447 - if ( $title->getNamespace() == NS_SPECIAL &&
 447+ if ( $title->isSpecialPage() &&
448448 !SpecialPageFactory::exists( $title->getDbKey() ) ) {
449449 $vals['missing'] = '';
450450 } elseif ( $title->getNamespace() == NS_MEDIA &&
Index: trunk/phase3/includes/Wiki.php
@@ -92,7 +92,7 @@
9393 }
9494 }
9595 // For non-special titles, check for implicit titles
96 - if ( is_null( $ret ) || $ret->getNamespace() != NS_SPECIAL ) {
 96+ if ( is_null( $ret ) || !$ret->isSpecialPage() ) {
9797 // We can have urls with just ?diff=,?oldid= or even just ?diff=
9898 $oldid = $request->getInt( 'oldid' );
9999 $oldid = $oldid ? $oldid : $request->getInt( 'diff' );
@@ -190,7 +190,7 @@
191191 && !count( $request->getValueNames( array( 'action', 'title' ) ) )
192192 && wfRunHooks( 'TestCanonicalRedirect', array( $request, $title, $output ) ) )
193193 {
194 - if ( $title->getNamespace() == NS_SPECIAL ) {
 194+ if ( $title->isSpecialPage() ) {
195195 list( $name, $subpage ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
196196 if ( $name ) {
197197 $title = SpecialPage::getTitleFor( $name, $subpage );
Index: trunk/phase3/includes/Title.php
@@ -1112,7 +1112,7 @@
11131113 $restrictionTypes = $this->getRestrictionTypes();
11141114
11151115 # Special pages have inherent protection
1116 - if( $this->getNamespace() == NS_SPECIAL ) {
 1116+ if( $this->isSpecialPage() ) {
11171117 return true;
11181118 }
11191119
@@ -1863,7 +1863,7 @@
18641864 }
18651865
18661866 # If it's a special page, ditch the subpage bit and check again
1867 - if ( $this->getNamespace() == NS_SPECIAL ) {
 1867+ if ( $this->isSpecialPage() ) {
18681868 $name = $this->getDBkey();
18691869 list( $name, /* $subpage */ ) = SpecialPageFactory::resolveAlias( $name );
18701870 if ( $name === false ) {
@@ -4152,7 +4152,7 @@
41534153 * @return boolean
41544154 */
41554155 public function isSpecial( $name ) {
4156 - if ( $this->getNamespace() == NS_SPECIAL ) {
 4156+ if ( $this->isSpecialPage() ) {
41574157 list( $thisName, /* $subpage */ ) = SpecialPageFactory::resolveAlias( $this->getDBkey() );
41584158 if ( $name == $thisName ) {
41594159 return true;
@@ -4168,7 +4168,7 @@
41694169 * @return Title
41704170 */
41714171 public function fixSpecialName() {
4172 - if ( $this->getNamespace() == NS_SPECIAL ) {
 4172+ if ( $this->isSpecialPage() ) {
41734173 list( $canonicalName, $par ) = SpecialPageFactory::resolveAlias( $this->mDbkeyform );
41744174 if ( $canonicalName ) {
41754175 $localName = SpecialPageFactory::getLocalNameFor( $canonicalName, $par );
@@ -4279,7 +4279,7 @@
42804280 * @return array applicable restriction types
42814281 */
42824282 public function getRestrictionTypes() {
4283 - if ( $this->getNamespace() == NS_SPECIAL ) {
 4283+ if ( $this->isSpecialPage() ) {
42844284 return array();
42854285 }
42864286
@@ -4356,7 +4356,7 @@
43574357 */
43584358 public function getPageLanguage() {
43594359 global $wgLang;
4360 - if ( $this->getNamespace() == NS_SPECIAL ) {
 4360+ if ( $this->isSpecialPage() ) {
43614361 // special pages are in the user language
43624362 return $wgLang;
43634363 } elseif ( $this->isCssOrJsPage() ) {
Index: trunk/phase3/includes/SkinLegacy.php
@@ -238,7 +238,7 @@
239239 $variants = $lang->getVariants();
240240
241241 if ( !$wgDisableLangConversion && sizeof( $variants ) > 1
242 - && $title->getNamespace() != NS_SPECIAL ) {
 242+ && !$title->isSpecialPage() ) {
243243 foreach ( $variants as $code ) {
244244 $varname = $lang->getVariantname( $code );
245245
@@ -770,7 +770,7 @@
771771 global $wgOut;
772772
773773 $title = $this->getSkin()->getTitle();
774 - if ( $title->getNamespace() == NS_SPECIAL ) {
 774+ if ( $title->isSpecialPage() ) {
775775 return '';
776776 }
777777
Index: trunk/phase3/includes/SkinTemplate.php
@@ -275,9 +275,9 @@
276276 $tpl->set( 'printable', $out->isPrintable() );
277277 $tpl->set( 'handheld', $request->getBool( 'handheld' ) );
278278 $tpl->setRef( 'loggedin', $this->loggedin );
279 - $tpl->set( 'notspecialpage', $this->getTitle()->getNamespace() != NS_SPECIAL );
 279+ $tpl->set( 'notspecialpage', !$this->getTitle()->isSpecialPage() );
280280 /* XXX currently unused, might get useful later
281 - $tpl->set( 'editable', ( $this->getTitle()->getNamespace() != NS_SPECIAL ) );
 281+ $tpl->set( 'editable', ( !$this->getTitle()->isSpecialPage() ) );
282282 $tpl->set( 'exists', $this->getTitle()->getArticleID() != 0 );
283283 $tpl->set( 'watch', $this->getTitle()->userIsWatching() ? 'unwatch' : 'watch' );
284284 $tpl->set( 'protect', count( $this->getTitle()->isProtected() ) ? 'unprotect' : 'protect' );
@@ -589,7 +589,7 @@
590590 # thickens, because $wgTitle is altered for special pages, so doesn't
591591 # contain the original alias-with-subpage.
592592 $origTitle = Title::newFromText( $request->getText( 'title' ) );
593 - if( $origTitle instanceof Title && $origTitle->getNamespace() == NS_SPECIAL ) {
 593+ if( $origTitle instanceof Title && $origTitle->isSpecialPage() ) {
594594 list( $spName, $spPar ) = SpecialPageFactory::resolveAlias( $origTitle->getText() );
595595 $active = $spName == 'Contributions'
596596 && ( ( $spPar && $spPar == $this->username )
@@ -814,7 +814,7 @@
815815 wfRunHooks( 'SkinTemplatePreventOtherActiveTabs', array( &$this, &$preventActiveTabs ) );
816816
817817 // Checks if page is some kind of content
818 - if( $title->getNamespace() != NS_SPECIAL ) {
 818+ if( !$title->isSpecialPage() ) {
819819 // Gets page objects for the related namespaces
820820 $subjectPage = $title->getSubjectPage();
821821 $talkPage = $title->getTalkPage();
@@ -1009,7 +1009,7 @@
10101010 array( &$this, &$content_navigation ) );
10111011 }
10121012
1013 - if ( !$wgDisableLangConversion && $title->getNamespace() != NS_SPECIAL ) {
 1013+ if ( !$wgDisableLangConversion && !$title->isSpecialPage() ) {
10141014 $pageLang = $title->getPageLanguage();
10151015 // Gets list of language variants
10161016 $variants = $pageLang->getVariants();
Index: trunk/phase3/includes/WikiPage.php
@@ -205,7 +205,7 @@
206206 return $rt->getFullURL( 'rdfrom=' . urlencode( $source ) );
207207 }
208208 } else {
209 - if ( $rt->getNamespace() == NS_SPECIAL ) {
 209+ if ( $rt->isSpecialPage() ) {
210210 // Gotta handle redirects to special pages differently:
211211 // Fill the HTTP response "Location" header and ignore
212212 // the rest of the page we're on.
Index: trunk/phase3/includes/specials/SpecialRevisiondelete.php
@@ -228,7 +228,7 @@
229229 array(),
230230 array( 'page' => $this->targetObj->getPrefixedText() )
231231 );
232 - if ( $this->targetObj->getNamespace() != NS_SPECIAL ) {
 232+ if ( !$this->targetObj->isSpecialPage() ) {
233233 # Give a link to the page history
234234 $links[] = Linker::linkKnown(
235235 $this->targetObj,
Index: trunk/phase3/includes/Skin.php
@@ -183,7 +183,7 @@
184184 $titles = array( $user->getUserPage(), $user->getTalkPage() );
185185
186186 // Other tab link
187 - if ( $this->getTitle()->getNamespace() == NS_SPECIAL ) {
 187+ if ( $this->getTitle()->isSpecialPage() ) {
188188 // nothing
189189 } elseif ( $this->getTitle()->isTalkPage() ) {
190190 $titles[] = $this->getTitle()->getSubjectPage();
@@ -329,7 +329,7 @@
330330 function getPageClasses( $title ) {
331331 $numeric = 'ns-' . $title->getNamespace();
332332
333 - if ( $title->getNamespace() == NS_SPECIAL ) {
 333+ if ( $title->isSpecialPage() ) {
334334 $type = 'ns-special';
335335 // bug 23315: provide a class based on the canonical special page name without subpages
336336 list( $canonicalName ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
Index: trunk/phase3/includes/LogPage.php
@@ -391,7 +391,7 @@
392392 $params[1] = $lang->timeanddate( $params[1] );
393393 break;
394394 default:
395 - if( $title->getNamespace() == NS_SPECIAL ) {
 395+ if( $title->isSpecialPage() ) {
396396 list( $name, $par ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
397397
398398 # Use the language name for log titles, rather than Log/X

Sign-offs

UserFlagDate
Platonidesinspected15:36, 3 November 2011

Status & tagging log