Umherirrender has uploaded a new change for review.
https://gerrit.wikimedia.org/r/69971
Change subject: date_default_timezone_set unnneeded in Parser::getVariableValue
......................................................................
date_default_timezone_set unnneeded in Parser::getVariableValue
Since r88178 the global $wgLocaltimezone is always set and
date_default_timezone_set is always called, makes the second call
unneeded.
Change-Id: I7559c3699920837849696eabe6fee16179159697
---
M includes/parser/Parser.php
1 file changed, 14 insertions(+), 35 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/71/69971/1
diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php
index 28cde7f..4d80a0e 100644
--- a/includes/parser/Parser.php
+++ b/includes/parser/Parser.php
@@ -2682,27 +2682,6 @@
$ts = wfTimestamp( TS_UNIX, $this->mOptions->getTimestamp() );
wfRunHooks( 'ParserGetVariableValueTs', array( &$this, &$ts ) );
- # Use the time zone
- global $wgLocaltimezone;
- if ( isset( $wgLocaltimezone ) ) {
- $oldtz = date_default_timezone_get();
- date_default_timezone_set( $wgLocaltimezone );
- }
-
- $localTimestamp = date( 'YmdHis', $ts );
- $localMonth = date( 'm', $ts );
- $localMonth1 = date( 'n', $ts );
- $localMonthName = date( 'n', $ts );
- $localDay = date( 'j', $ts );
- $localDay2 = date( 'd', $ts );
- $localDayOfWeek = date( 'w', $ts );
- $localWeek = date( 'W', $ts );
- $localYear = date( 'Y', $ts );
- $localHour = date( 'H', $ts );
- if ( isset( $wgLocaltimezone ) ) {
- date_default_timezone_set( $oldtz );
- }
-
$pageLang = $this->getFunctionLang();
switch ( $index ) {
@@ -2728,25 +2707,25 @@
$value = $pageLang->formatNum( gmdate( 'd', $ts
) );
break;
case 'localmonth':
- $value = $pageLang->formatNum( $localMonth );
+ $value = $pageLang->formatNum( date( 'm', $ts )
);
break;
case 'localmonth1':
- $value = $pageLang->formatNum( $localMonth1 );
+ $value = $pageLang->formatNum( date( 'n', $ts )
);
break;
case 'localmonthname':
- $value = $pageLang->getMonthName(
$localMonthName );
+ $value = $pageLang->getMonthName( date( 'n',
$ts ) );
break;
case 'localmonthnamegen':
- $value = $pageLang->getMonthNameGen(
$localMonthName );
+ $value = $pageLang->getMonthNameGen( date( 'n',
$ts ) );
break;
case 'localmonthabbrev':
- $value = $pageLang->getMonthAbbreviation(
$localMonthName );
+ $value = $pageLang->getMonthAbbreviation( date(
'n', $ts ) );
break;
case 'localday':
- $value = $pageLang->formatNum( $localDay );
+ $value = $pageLang->formatNum( date( 'j', $ts )
);
break;
case 'localday2':
- $value = $pageLang->formatNum( $localDay2 );
+ $value = $pageLang->formatNum( date( 'd', $ts )
);
break;
case 'pagename':
$value = wfEscapeWikiText(
$this->mTitle->getText() );
@@ -2912,24 +2891,24 @@
$value = $pageLang->formatNum( gmdate( 'w', $ts
) );
break;
case 'localdayname':
- $value = $pageLang->getWeekdayName(
$localDayOfWeek + 1 );
+ $value = $pageLang->getWeekdayName( date( 'w',
$ts ) + 1 );
break;
case 'localyear':
- $value = $pageLang->formatNum( $localYear, true
);
+ $value = $pageLang->formatNum( date( 'Y', $ts
), true );
break;
case 'localtime':
- $value = $pageLang->time( $localTimestamp,
false, false );
+ $value = $pageLang->time( date( 'YmdHis', $ts
), false, false );
break;
case 'localhour':
- $value = $pageLang->formatNum( $localHour, true
);
+ $value = $pageLang->formatNum( date( 'H', $ts
), true );
break;
case 'localweek':
# @bug 4594 PHP5 has it zero padded, PHP4 does
not, cast to
# int to remove the padding
- $value = $pageLang->formatNum( (int)$localWeek
);
+ $value = $pageLang->formatNum( (int)date( 'W',
$ts ) );
break;
case 'localdow':
- $value = $pageLang->formatNum( $localDayOfWeek
);
+ $value = $pageLang->formatNum( date( 'w', $ts )
);
break;
case 'numberofarticles':
$value = $pageLang->formatNum(
SiteStats::articles() );
@@ -2960,7 +2939,7 @@
$value = wfTimestamp( TS_MW, $ts );
break;
case 'localtimestamp':
- $value = $localTimestamp;
+ $value = date( 'YmdHis', $ts );
break;
case 'currentversion':
$value = SpecialVersion::getVersion();
--
To view, visit https://gerrit.wikimedia.org/r/69971
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7559c3699920837849696eabe6fee16179159697
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits