http://www.mediawiki.org/wiki/Special:Code/MediaWiki/90707

Revision: 90707
Author:   siebrand
Date:     2011-06-24 10:00:35 +0000 (Fri, 24 Jun 2011)
Log Message:
-----------
Reduce calls to wfTimestampNow() by using temporary variable. Inspired by CR on 
r88278.

Modified Paths:
--------------
    trunk/phase3/includes/Block.php
    trunk/phase3/includes/specials/SpecialRecentchanges.php
    trunk/phase3/includes/specials/SpecialWatchlist.php

Modified: trunk/phase3/includes/Block.php
===================================================================
--- trunk/phase3/includes/Block.php     2011-06-24 09:54:06 UTC (rev 90706)
+++ trunk/phase3/includes/Block.php     2011-06-24 10:00:35 UTC (rev 90707)
@@ -613,7 +613,8 @@
                $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 @@
                $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 @@
         * @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;
                }
        }
 

Modified: trunk/phase3/includes/specials/SpecialRecentchanges.php
===================================================================
--- trunk/phase3/includes/specials/SpecialRecentchanges.php     2011-06-24 
09:54:06 UTC (rev 90706)
+++ trunk/phase3/includes/specials/SpecialRecentchanges.php     2011-06-24 
10:00:35 UTC (rev 90707)
@@ -827,9 +827,10 @@
                }
 
                // 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' ),

Modified: trunk/phase3/includes/specials/SpecialWatchlist.php
===================================================================
--- trunk/phase3/includes/specials/SpecialWatchlist.php 2011-06-24 09:54:06 UTC 
(rev 90706)
+++ trunk/phase3/includes/specials/SpecialWatchlist.php 2011-06-24 10:00:35 UTC 
(rev 90707)
@@ -299,12 +299,13 @@
 
                $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',


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to