r39124 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r39123‎ | r39124 | r39125 >
Date:09:48, 11 August 2008
Author:minuteelectron
Status:old
Tags:
Comment:
* Avoid E_STRICT warnings when getting a date by attempting to set a timzone and supressing any warnings while generating the date.
Modified paths:
  • /trunk/extensions/LiquidThreads/LqtModel.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/LqtModel.php
@@ -40,7 +40,26 @@
4141 return $this->moved('+1 month');
4242 }
4343 function moved($str) {
44 - return new Date( date('YmdHis', strtotime($this->text() . ' ' . $str)) );
 44+ // Try to set local timezone to attempt to avoid E_STRICT errors.
 45+ global $wgLocaltimezone;
 46+ if ( isset( $wgLocaltimezone ) ) {
 47+ $oldtz = getenv( "TZ" );
 48+ putenv( "TZ=$wgLocaltimezone" );
 49+ }
 50+ // Suppress warnings for installations without a set timezone.
 51+ wfSuppressWarnings();
 52+ // Make the date string.
 53+ $date = date( 'YmdHis', strtotime( $this->text() . ' ' . $str ) );
 54+ // Restore warnings, date no loner an issue.
 55+ wfRestoreWarnings();
 56+ // Generate the date object,
 57+ $date = new Date( $date );
 58+ // Restore the old timezone if needed.
 59+ if ( isset( $wgLocaltimezone ) ) {
 60+ putenv( "TZ=$oldtz" );
 61+ }
 62+ // Return the generated date object.
 63+ return $date;
4564 }
4665 /* function monthString() {
4766 return sprintf( '%04d%02d', $this->year, $this->month );

Status & tagging log