r107967 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107966‎ | r107967 | r107968 >
Date:23:55, 3 January 2012
Author:kaldari
Status:ok (Comments)
Tags:
Comment:
follow-up to r107958 - caching data longer
Modified paths:
  • /trunk/extensions/CentralNotice/CentralNotice.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/CentralNotice.php
@@ -311,8 +311,8 @@
312312
313313 }
314314
315 - // Cache the data for 1 day
316 - $wgMemc->set( $cacheKey, $userData, strtotime( '+1 day' ) );
 315+ // Cache the data for 7 days
 316+ $wgMemc->set( $cacheKey, $userData, strtotime( '+7 days' ) );
317317 }
318318
319319 // Set the variable that will be output to the page

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r107958getting rid of temporary Harvard Sciences Po functionality, replacing it with...kaldari23:09, 3 January 2012

Comments

#Comment by Nikerabbit (talk | contribs)   10:01, 4 January 2012

Note:

Using this function for mathematical operations is not advisable. It is better to use DateTime::add() and DateTime::sub() in PHP 5.3 and later, or DateTime::modify() in PHP 5.2.

#Comment by Kaldari (talk | contribs)   18:55, 4 January 2012

I've never heard that before. What's the down side to using strtotime()? Isn't strtotime( '+7 days' ) a lot more readable than:

$date = new DateTime();
$date->add( new DateInterval( 'P7D' ) );
$newTime = $date->format( 'U' );

Status & tagging log