Page MenuHomePhabricator

wrong timezone offset calculation with $wgLocalTZoffset
Closed, ResolvedPublic

Description

Author: aoyagi

Description:
XAMPP Apache server crashes when I set $wgLocalTZoffset to 540. I found a bug in
Language.php. See below.

$ diff -c languages/Language.php languages/Language.php.org

  • languages/Language.php Wed Feb 28 09:48:57 2007
  • languages/Language.php.org Wed Feb 21 11:20:42 2007 ***
  • 394,401 **** if ( $tz === '' ) { #ツGlobal offset in minutes. if( isset($wgLocalTZoffset) ) {

! $hrDiff = $wgLocalTZoffset / 60;
! $minDiff = $wgLocalTZoffset % 60;

        }
} elseif ( strpos( $tz, ':' ) !== false ) {
        $tzArray = explode( ':', $tz );
  • 394,401 ---- if ( $tz === '' ) { #ツGlobal offset in minutes. if( isset($wgLocalTZoffset) ) {

! $hrDiff = $wgLocalTZoffset % 60;
! $minDiff = $wgLocalTZoffset - ($hrDiff * 60);

        }
} elseif ( strpos( $tz, ':' ) !== false ) {
        $tzArray = explode( ':', $tz );

Version: 1.9.x
Severity: normal
OS: Windows XP
Platform: PC

Details

Reference
bz9123

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:40 PM
bzimport set Reference to bz9123.
bzimport added a subscriber: Unknown Object (MLST).

Er, what's wrong with it?

If your server is *crashing* on basic arithmetic, I think you've got bigger
problems.

aoyagi wrote:

I've not yet tracked down the reason of the server crash. Aside from the server
crash, the calculation of $hrDiff and $minDiff in the original source seems
wrong. For example, when $wgLocalTZoffset is 30(min), $hrDiff becomes 30(hour)
and $minDiff becomes -1770(min).

Internally adding 5 minutes was considered +5 hours then - 295 minutes.
I changed it with r22142. Thanks!