r86326 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86325‎ | r86326 | r86327 >
Date:17:39, 18 April 2011
Author:reedy
Status:reverted (Comments)
Tags:
Comment:
Update all core calls of SpecialPage->getName();
Modified paths:
  • /trunk/phase3/includes/QueryPage.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialWithoutinterwiki.php (modified) (history)
  • /trunk/phase3/maintenance/updateSpecialPages.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/updateSpecialPages.php
@@ -93,7 +93,7 @@
9494 $queryPage = new $class;
9595 }
9696
97 - if ( !$this->hasOption( 'only' ) || $this->getOption( 'only' ) == $queryPage->getName() ) {
 97+ if ( !$this->hasOption( 'only' ) || $this->getOption( 'only' ) == $queryPage->name() ) {
9898 $this->output( sprintf( '%-30s ', $special ) );
9999 if ( $queryPage->isExpensive() ) {
100100 $t1 = explode( ' ', microtime() );
Index: trunk/phase3/includes/specials/SpecialWithoutinterwiki.php
@@ -49,7 +49,7 @@
5050 }
5151
5252 $prefix = $this->prefix;
53 - $t = SpecialPage::getTitleFor( $this->getName() );
 53+ $t = SpecialPage::getTitleFor( $this->name() );
5454
5555 return Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) .
5656 Xml::openElement( 'fieldset' ) .
Index: trunk/phase3/includes/QueryPage.php
@@ -277,7 +277,7 @@
278278
279279 $fname = get_class( $this ) . '::recache';
280280 $dbw = wfGetDB( DB_MASTER );
281 - $dbr = wfGetDB( DB_SLAVE, array( $this->getName(), __METHOD__, 'vslow' ) );
 281+ $dbr = wfGetDB( DB_SLAVE, array( $this->name(), __METHOD__, 'vslow' ) );
282282 if ( !$dbw || !$dbr ) {
283283 return false;
284284 }
@@ -288,7 +288,7 @@
289289 }
290290
291291 # Clear out any old cached data
292 - $dbw->delete( 'querycache', array( 'qc_type' => $this->getName() ), $fname );
 292+ $dbw->delete( 'querycache', array( 'qc_type' => $this->name() ), $fname );
293293 # Do query
294294 $res = $this->reallyDoQuery( $limit, false );
295295 $num = false;
@@ -308,7 +308,7 @@
309309 $value = 0;
310310 }
311311
312 - $vals[] = array( 'qc_type' => $this->getName(),
 312+ $vals[] = array( 'qc_type' => $this->name(),
313313 'qc_namespace' => $row->namespace,
314314 'qc_title' => $row->title,
315315 'qc_value' => $value );
@@ -327,8 +327,8 @@
328328 }
329329
330330 # Update the querycache_info record for the page
331 - $dbw->delete( 'querycache_info', array( 'qci_type' => $this->getName() ), $fname );
332 - $dbw->insert( 'querycache_info', array( 'qci_type' => $this->getName(), 'qci_timestamp' => $dbw->timestamp() ), $fname );
 331+ $dbw->delete( 'querycache_info', array( 'qci_type' => $this->name() ), $fname );
 332+ $dbw->insert( 'querycache_info', array( 'qci_type' => $this->name(), 'qci_timestamp' => $dbw->timestamp() ), $fname );
333333
334334 }
335335 return $num;
@@ -416,7 +416,7 @@
417417 'qc_namespace AS namespace',
418418 'qc_title AS title',
419419 'qc_value AS value' ),
420 - array( 'qc_type' => $this->getName() ),
 420+ array( 'qc_type' => $this->name() ),
421421 __METHOD__, $options
422422 );
423423 return $dbr->resultObject( $res );
@@ -427,7 +427,7 @@
428428 $dbr = wfGetDB( DB_SLAVE );
429429 $fname = get_class( $this ) . '::getCachedTimestamp';
430430 $this->cachedTimestamp = $dbr->selectField( 'querycache_info', 'qci_timestamp',
431 - array( 'qci_type' => $this->getName() ), $fname );
 431+ array( 'qci_type' => $this->name() ), $fname );
432432 }
433433 return $this->cachedTimestamp;
434434 }
@@ -483,7 +483,7 @@
484484 # If updates on this page have been disabled, let the user know
485485 # that the data set won't be refreshed for now
486486 global $wgDisableQueryPageUpdate;
487 - if ( is_array( $wgDisableQueryPageUpdate ) && in_array( $this->getName(), $wgDisableQueryPageUpdate ) ) {
 487+ if ( is_array( $wgDisableQueryPageUpdate ) && in_array( $this->name(), $wgDisableQueryPageUpdate ) ) {
488488 $wgOut->addWikiMsg( 'querypage-no-updates' );
489489 }
490490

Follow-up revisions

RevisionCommit summaryAuthorDate
r86334Revert r86236reedy19:00, 18 April 2011

Comments

#Comment by 😂 (talk | contribs)   18:01, 18 April 2011

I don't like this. Function names should begin with an action verb.

#Comment by Nikerabbit (talk | contribs)   18:03, 18 April 2011

I like bunnies.

#Comment by 😂 (talk | contribs)   18:05, 18 April 2011

File an enhancement request for more bunnies then.

#Comment by Reedy (talk | contribs)   18:39, 18 April 2011

Blame Roan...

Fixing it either way is easy

#Comment by 😂 (talk | contribs)   18:40, 18 April 2011

RoanKattouw (yes this is a ping for IRC)...why are we deprecating getName() in favor of name()?

#Comment by Happy-melon (talk | contribs)   18:44, 18 April 2011

The bare parameter name is a sensible naming convention for mutators. What I don't understand is why anyone thinks that changing the name of a special page instance would ever be a good idea...

#Comment by Catrope (talk | contribs)   18:54, 18 April 2011

I had no idea name() even existed. I also agree that getName() is a better name.

Note that this is SpecialPage, not QueryPage, so it's Not My Fault :)

Status & tagging log