Reduce calls to wfTimestampNow() by using temporary variable. Inspired by CR on r88278.
authorSiebrand Mazeland <siebrand@users.mediawiki.org>
Fri, 24 Jun 2011 10:00:35 +0000 (10:00 +0000)
committerSiebrand Mazeland <siebrand@users.mediawiki.org>
Fri, 24 Jun 2011 10:00:35 +0000 (10:00 +0000)
includes/Block.php
includes/specials/SpecialRecentchanges.php
includes/specials/SpecialWatchlist.php

index cadeabd..e875e9e 100644 (file)
@@ -613,7 +613,8 @@ class Block {
                $autoblock->setTarget( $autoblockIP );
                $autoblock->setBlocker( $this->getBlocker() );
                $autoblock->mReason = wfMsgForContent( 'autoblocker', $this->getTarget(), $this->mReason );
-               $autoblock->mTimestamp = wfTimestampNow();
+               $timestamp = wfTimestampNow();
+               $autoblock->mTimestamp = $timestamp;
                $autoblock->mAuto = 1;
                $autoblock->prevents( 'createaccount', $this->prevents( 'createaccount' ) );
                # Continue suppressing the name if needed
@@ -623,11 +624,11 @@ class Block {
                $dbr = wfGetDB( DB_SLAVE );
                if ( $this->mTimestamp == $dbr->getInfinity() ) {
                        # Original block was indefinite, start an autoblock now
-                       $autoblock->mExpiry = Block::getAutoblockExpiry( wfTimestampNow() );
+                       $autoblock->mExpiry = Block::getAutoblockExpiry( $timestamp );
                } else {
                        # If the user is already blocked with an expiry date, we don't
                        # want to pile on top of that.
-                       $autoblock->mExpiry = min( $this->mExpiry, Block::getAutoblockExpiry( wfTimestampNow() ) );
+                       $autoblock->mExpiry = min( $this->mExpiry, Block::getAutoblockExpiry( $timestamp ) );
                }
 
                # Insert the block...
@@ -662,12 +663,13 @@ class Block {
         * @return Boolean
         */
        public function isExpired() {
-               wfDebug( "Block::isExpired() checking current " . wfTimestampNow() . " vs $this->mExpiry\n" );
+               $timestamp = wfTimestampNow();
+               wfDebug( "Block::isExpired() checking current " . $timestamp . " vs $this->mExpiry\n" );
 
                if ( !$this->mExpiry ) {
                        return false;
                } else {
-                       return wfTimestampNow() > $this->mExpiry;
+                       return $timestamp > $this->mExpiry;
                }
        }
 
index cf24ec1..6f10250 100644 (file)
@@ -827,9 +827,10 @@ class SpecialRecentChanges extends IncludableSpecialPage {
                }
 
                // show from this onward link
-               $now = $wgLang->timeanddate( wfTimestampNow(), true );
+               $timestamp = wfTimestampNow();
+               $now = $wgLang->timeanddate( $timestamp, true );
                $tl = $this->makeOptionsLink(
-                       $now, array( 'from' => wfTimestampNow() ), $nondefaults
+                       $now, array( 'from' => $timestamp ), $nondefaults
                );
 
                $rclinks = wfMsgExt( 'rclinks', array( 'parseinline', 'replaceafter' ),
index 89e9e90..9179a50 100644 (file)
@@ -299,12 +299,13 @@ class SpecialWatchlist extends SpecialPage {
 
                $wlInfo = '';
                if( $values['days'] >= 1 ) {
+                       $timestamp = wfTimestampNow();
                        $wlInfo = wfMsgExt( 'rcnote', 'parseinline',
                                        $wgLang->formatNum( $numRows ),
                                        $wgLang->formatNum( $values['days'] ),
-                                       $wgLang->timeAndDate( wfTimestampNow(), true ),
-                                       $wgLang->date( wfTimestampNow(), true ),
-                                       $wgLang->time( wfTimestampNow(), true )
+                                       $wgLang->timeAndDate( $timestamp, true ),
+                                       $wgLang->date( $timestamp, true ),
+                                       $wgLang->time( $timestamp, true )
                                ) . '<br />';
                } elseif( $values['days'] > 0 ) {
                        $wlInfo = wfMsgExt( 'wlnote', 'parseinline',