r90707 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90706‎ | r90707 | r90708 >
Date:10:00, 24 June 2011
Author:siebrand
Status:ok
Tags:
Comment:
Reduce calls to wfTimestampNow() by using temporary variable. Inspired by CR on r88278.
Modified paths:
  • /trunk/phase3/includes/Block.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialRecentchanges.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialWatchlist.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialRecentchanges.php
@@ -827,9 +827,10 @@
828828 }
829829
830830 // show from this onward link
831 - $now = $wgLang->timeanddate( wfTimestampNow(), true );
 831+ $timestamp = wfTimestampNow();
 832+ $now = $wgLang->timeanddate( $timestamp, true );
832833 $tl = $this->makeOptionsLink(
833 - $now, array( 'from' => wfTimestampNow() ), $nondefaults
 834+ $now, array( 'from' => $timestamp ), $nondefaults
834835 );
835836
836837 $rclinks = wfMsgExt( 'rclinks', array( 'parseinline', 'replaceafter' ),
Index: trunk/phase3/includes/specials/SpecialWatchlist.php
@@ -299,12 +299,13 @@
300300
301301 $wlInfo = '';
302302 if( $values['days'] >= 1 ) {
 303+ $timestamp = wfTimestampNow();
303304 $wlInfo = wfMsgExt( 'rcnote', 'parseinline',
304305 $wgLang->formatNum( $numRows ),
305306 $wgLang->formatNum( $values['days'] ),
306 - $wgLang->timeAndDate( wfTimestampNow(), true ),
307 - $wgLang->date( wfTimestampNow(), true ),
308 - $wgLang->time( wfTimestampNow(), true )
 307+ $wgLang->timeAndDate( $timestamp, true ),
 308+ $wgLang->date( $timestamp, true ),
 309+ $wgLang->time( $timestamp, true )
309310 ) . '<br />';
310311 } elseif( $values['days'] > 0 ) {
311312 $wlInfo = wfMsgExt( 'wlnote', 'parseinline',
Index: trunk/phase3/includes/Block.php
@@ -613,7 +613,8 @@
614614 $autoblock->setTarget( $autoblockIP );
615615 $autoblock->setBlocker( $this->getBlocker() );
616616 $autoblock->mReason = wfMsgForContent( 'autoblocker', $this->getTarget(), $this->mReason );
617 - $autoblock->mTimestamp = wfTimestampNow();
 617+ $timestamp = wfTimestampNow();
 618+ $autoblock->mTimestamp = $timestamp;
618619 $autoblock->mAuto = 1;
619620 $autoblock->prevents( 'createaccount', $this->prevents( 'createaccount' ) );
620621 # Continue suppressing the name if needed
@@ -623,11 +624,11 @@
624625 $dbr = wfGetDB( DB_SLAVE );
625626 if ( $this->mTimestamp == $dbr->getInfinity() ) {
626627 # Original block was indefinite, start an autoblock now
627 - $autoblock->mExpiry = Block::getAutoblockExpiry( wfTimestampNow() );
 628+ $autoblock->mExpiry = Block::getAutoblockExpiry( $timestamp );
628629 } else {
629630 # If the user is already blocked with an expiry date, we don't
630631 # want to pile on top of that.
631 - $autoblock->mExpiry = min( $this->mExpiry, Block::getAutoblockExpiry( wfTimestampNow() ) );
 632+ $autoblock->mExpiry = min( $this->mExpiry, Block::getAutoblockExpiry( $timestamp ) );
632633 }
633634
634635 # Insert the block...
@@ -662,12 +663,13 @@
663664 * @return Boolean
664665 */
665666 public function isExpired() {
666 - wfDebug( "Block::isExpired() checking current " . wfTimestampNow() . " vs $this->mExpiry\n" );
 667+ $timestamp = wfTimestampNow();
 668+ wfDebug( "Block::isExpired() checking current " . $timestamp . " vs $this->mExpiry\n" );
667669
668670 if ( !$this->mExpiry ) {
669671 return false;
670672 } else {
671 - return wfTimestampNow() > $this->mExpiry;
 673+ return $timestamp > $this->mExpiry;
672674 }
673675 }
674676

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r88278(bug 29011) Remove hard coded text from Special:LockDb....siebrand23:21, 16 May 2011

Status & tagging log