r85323 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85322‎ | r85323 | r85324 >
Date:11:48, 4 April 2011
Author:reedy
Status:ok (Comments)
Tags:
Comment:
Type hints to substring used in integer addition
Modified paths:
  • /trunk/phase3/includes/Preferences.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Preferences.php
@@ -539,10 +539,11 @@
540540 }
541541
542542 // Info
 543+ $now = wfTimestampNow();
543544 $nowlocal = Xml::element( 'span', array( 'id' => 'wpLocalTime' ),
544 - $wgLang->time( $now = wfTimestampNow(), true ) );
 545+ $wgLang->time( $now, true ) );
545546 $nowserver = $wgLang->time( $now, false ) .
546 - Html::hidden( 'wpServerTime', substr( $now, 8, 2 ) * 60 + substr( $now, 10, 2 ) );
 547+ Html::hidden( 'wpServerTime', (int)substr( $now, 8, 2 ) * 60 + (int)substr( $now, 10, 2 ) );
547548
548549 $defaultPreferences['nowserver'] = array(
549550 'type' => 'info',

Comments

#Comment by Hashar (talk | contribs)   19:55, 7 June 2011

what is the hint for? Isn't PHP able to handle : "42" * 60 ?

#Comment by Reedy (talk | contribs)   19:55, 7 June 2011

Just more obvious

#Comment by Hashar (talk | contribs)   06:48, 8 June 2011

I got your point. Maybe use meaningful variables instead?

$hour = substr( $now, 8, 2 )
$minute = substr( $now, 10, 2)
Html::hidden( 'wpServerTime',  $hour * 60 + $minute )

Status & tagging log