From: Daniel Kinzler Date: Fri, 2 Oct 2009 09:46:17 +0000 (+0000) Subject: follow-up to r57278: cache all variables untill the next clearState() X-Git-Tag: 1.31.0-rc.0~39414 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/?a=commitdiff_plain;h=9d00a90a218fd2b36bfc27c64547ae25bb5a424b;p=lhc%2Fweb%2Fwiklou.git follow-up to r57278: cache all variables untill the next clearState() --- diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 950ff0eb2d..a076c4789e 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -2340,173 +2340,235 @@ class Parser switch ( $index ) { case 'currentmonth': - return $this->mVarCache[$index] = $wgContLang->formatNum( gmdate( 'm', $ts ) ); + $value = $wgContLang->formatNum( gmdate( 'm', $ts ) ); + break; case 'currentmonth1': - return $this->mVarCache[$index] = $wgContLang->formatNum( gmdate( 'n', $ts ) ); + $value = $wgContLang->formatNum( gmdate( 'n', $ts ) ); + break; case 'currentmonthname': - return $this->mVarCache[$index] = $wgContLang->getMonthName( gmdate( 'n', $ts ) ); + $value = $wgContLang->getMonthName( gmdate( 'n', $ts ) ); + break; case 'currentmonthnamegen': - return $this->mVarCache[$index] = $wgContLang->getMonthNameGen( gmdate( 'n', $ts ) ); + $value = $wgContLang->getMonthNameGen( gmdate( 'n', $ts ) ); + break; case 'currentmonthabbrev': - return $this->mVarCache[$index] = $wgContLang->getMonthAbbreviation( gmdate( 'n', $ts ) ); + $value = $wgContLang->getMonthAbbreviation( gmdate( 'n', $ts ) ); + break; case 'currentday': - return $this->mVarCache[$index] = $wgContLang->formatNum( gmdate( 'j', $ts ) ); + $value = $wgContLang->formatNum( gmdate( 'j', $ts ) ); + break; case 'currentday2': - return $this->mVarCache[$index] = $wgContLang->formatNum( gmdate( 'd', $ts ) ); + $value = $wgContLang->formatNum( gmdate( 'd', $ts ) ); + break; case 'localmonth': - return $this->mVarCache[$index] = $wgContLang->formatNum( $localMonth ); + $value = $wgContLang->formatNum( $localMonth ); + break; case 'localmonth1': - return $this->mVarCache[$index] = $wgContLang->formatNum( $localMonth1 ); + $value = $wgContLang->formatNum( $localMonth1 ); + break; case 'localmonthname': - return $this->mVarCache[$index] = $wgContLang->getMonthName( $localMonthName ); + $value = $wgContLang->getMonthName( $localMonthName ); + break; case 'localmonthnamegen': - return $this->mVarCache[$index] = $wgContLang->getMonthNameGen( $localMonthName ); + $value = $wgContLang->getMonthNameGen( $localMonthName ); + break; case 'localmonthabbrev': - return $this->mVarCache[$index] = $wgContLang->getMonthAbbreviation( $localMonthName ); + $value = $wgContLang->getMonthAbbreviation( $localMonthName ); + break; case 'localday': - return $this->mVarCache[$index] = $wgContLang->formatNum( $localDay ); + $value = $wgContLang->formatNum( $localDay ); + break; case 'localday2': - return $this->mVarCache[$index] = $wgContLang->formatNum( $localDay2 ); + $value = $wgContLang->formatNum( $localDay2 ); + break; case 'pagename': - return wfEscapeWikiText( $this->mTitle->getText() ); + $value = wfEscapeWikiText( $this->mTitle->getText() ); + break; case 'pagenamee': - return $this->mTitle->getPartialURL(); + $value = $this->mTitle->getPartialURL(); + break; case 'fullpagename': - return wfEscapeWikiText( $this->mTitle->getPrefixedText() ); + $value = wfEscapeWikiText( $this->mTitle->getPrefixedText() ); + break; case 'fullpagenamee': - return $this->mTitle->getPrefixedURL(); + $value = $this->mTitle->getPrefixedURL(); + break; case 'subpagename': - return wfEscapeWikiText( $this->mTitle->getSubpageText() ); + $value = wfEscapeWikiText( $this->mTitle->getSubpageText() ); + break; case 'subpagenamee': - return $this->mTitle->getSubpageUrlForm(); + $value = $this->mTitle->getSubpageUrlForm(); + break; case 'basepagename': - return wfEscapeWikiText( $this->mTitle->getBaseText() ); + $value = wfEscapeWikiText( $this->mTitle->getBaseText() ); + break; case 'basepagenamee': - return wfUrlEncode( str_replace( ' ', '_', $this->mTitle->getBaseText() ) ); + $value = wfUrlEncode( str_replace( ' ', '_', $this->mTitle->getBaseText() ) ); + break; case 'talkpagename': if( $this->mTitle->canTalk() ) { $talkPage = $this->mTitle->getTalkPage(); - return wfEscapeWikiText( $talkPage->getPrefixedText() ); + $value = wfEscapeWikiText( $talkPage->getPrefixedText() ); } else { - return ''; + $value = ''; } + break; case 'talkpagenamee': if( $this->mTitle->canTalk() ) { $talkPage = $this->mTitle->getTalkPage(); - return $talkPage->getPrefixedUrl(); + $value = $talkPage->getPrefixedUrl(); } else { - return ''; + $value = ''; } + break; case 'subjectpagename': $subjPage = $this->mTitle->getSubjectPage(); - return wfEscapeWikiText( $subjPage->getPrefixedText() ); + $value = wfEscapeWikiText( $subjPage->getPrefixedText() ); + break; case 'subjectpagenamee': $subjPage = $this->mTitle->getSubjectPage(); - return $subjPage->getPrefixedUrl(); + $value = $subjPage->getPrefixedUrl(); + break; case 'revisionid': // Let the edit saving system know we should parse the page // *after* a revision ID has been assigned. $this->mOutput->setFlag( 'vary-revision' ); wfDebug( __METHOD__ . ": {{REVISIONID}} used, setting vary-revision...\n" ); - return $this->mRevisionId; + $value = $this->mRevisionId; + break; case 'revisionday': // Let the edit saving system know we should parse the page // *after* a revision ID has been assigned. This is for null edits. $this->mOutput->setFlag( 'vary-revision' ); wfDebug( __METHOD__ . ": {{REVISIONDAY}} used, setting vary-revision...\n" ); - return intval( substr( $this->getRevisionTimestamp(), 6, 2 ) ); + $value = intval( substr( $this->getRevisionTimestamp(), 6, 2 ) ); + break; case 'revisionday2': // Let the edit saving system know we should parse the page // *after* a revision ID has been assigned. This is for null edits. $this->mOutput->setFlag( 'vary-revision' ); wfDebug( __METHOD__ . ": {{REVISIONDAY2}} used, setting vary-revision...\n" ); - return substr( $this->getRevisionTimestamp(), 6, 2 ); + $value = substr( $this->getRevisionTimestamp(), 6, 2 ); + break; case 'revisionmonth': // Let the edit saving system know we should parse the page // *after* a revision ID has been assigned. This is for null edits. $this->mOutput->setFlag( 'vary-revision' ); wfDebug( __METHOD__ . ": {{REVISIONMONTH}} used, setting vary-revision...\n" ); - return intval( substr( $this->getRevisionTimestamp(), 4, 2 ) ); + $value = intval( substr( $this->getRevisionTimestamp(), 4, 2 ) ); + break; case 'revisionyear': // Let the edit saving system know we should parse the page // *after* a revision ID has been assigned. This is for null edits. $this->mOutput->setFlag( 'vary-revision' ); wfDebug( __METHOD__ . ": {{REVISIONYEAR}} used, setting vary-revision...\n" ); - return substr( $this->getRevisionTimestamp(), 0, 4 ); + $value = substr( $this->getRevisionTimestamp(), 0, 4 ); + break; case 'revisiontimestamp': // Let the edit saving system know we should parse the page // *after* a revision ID has been assigned. This is for null edits. $this->mOutput->setFlag( 'vary-revision' ); wfDebug( __METHOD__ . ": {{REVISIONTIMESTAMP}} used, setting vary-revision...\n" ); - return $this->getRevisionTimestamp(); + $value = $this->getRevisionTimestamp(); + break; case 'revisionuser': // Let the edit saving system know we should parse the page // *after* a revision ID has been assigned. This is for null edits. $this->mOutput->setFlag( 'vary-revision' ); wfDebug( __METHOD__ . ": {{REVISIONUSER}} used, setting vary-revision...\n" ); - return $this->getRevisionUser(); + $value = $this->getRevisionUser(); + break; case 'namespace': - return str_replace('_',' ',$wgContLang->getNsText( $this->mTitle->getNamespace() ) ); + $value = str_replace('_',' ',$wgContLang->getNsText( $this->mTitle->getNamespace() ) ); + break; case 'namespacee': - return wfUrlencode( $wgContLang->getNsText( $this->mTitle->getNamespace() ) ); + $value = wfUrlencode( $wgContLang->getNsText( $this->mTitle->getNamespace() ) ); + break; case 'talkspace': - return $this->mTitle->canTalk() ? str_replace('_',' ',$this->mTitle->getTalkNsText()) : ''; + $value = $this->mTitle->canTalk() ? str_replace('_',' ',$this->mTitle->getTalkNsText()) : ''; + break; case 'talkspacee': - return $this->mTitle->canTalk() ? wfUrlencode( $this->mTitle->getTalkNsText() ) : ''; + $value = $this->mTitle->canTalk() ? wfUrlencode( $this->mTitle->getTalkNsText() ) : ''; + break; case 'subjectspace': - return $this->mTitle->getSubjectNsText(); + $value = $this->mTitle->getSubjectNsText(); + break; case 'subjectspacee': - return( wfUrlencode( $this->mTitle->getSubjectNsText() ) ); + $value = ( wfUrlencode( $this->mTitle->getSubjectNsText() ) ); + break; case 'currentdayname': - return $this->mVarCache[$index] = $wgContLang->getWeekdayName( gmdate( 'w', $ts ) + 1 ); + $value = $wgContLang->getWeekdayName( gmdate( 'w', $ts ) + 1 ); + break; case 'currentyear': - return $this->mVarCache[$index] = $wgContLang->formatNum( gmdate( 'Y', $ts ), true ); + $value = $wgContLang->formatNum( gmdate( 'Y', $ts ), true ); + break; case 'currenttime': - return $this->mVarCache[$index] = $wgContLang->time( wfTimestamp( TS_MW, $ts ), false, false ); + $value = $wgContLang->time( wfTimestamp( TS_MW, $ts ), false, false ); + break; case 'currenthour': - return $this->mVarCache[$index] = $wgContLang->formatNum( gmdate( 'H', $ts ), true ); + $value = $wgContLang->formatNum( gmdate( 'H', $ts ), true ); + break; case 'currentweek': // @bug 4594 PHP5 has it zero padded, PHP4 does not, cast to // int to remove the padding - return $this->mVarCache[$index] = $wgContLang->formatNum( (int)gmdate( 'W', $ts ) ); + $value = $wgContLang->formatNum( (int)gmdate( 'W', $ts ) ); + break; case 'currentdow': - return $this->mVarCache[$index] = $wgContLang->formatNum( gmdate( 'w', $ts ) ); + $value = $wgContLang->formatNum( gmdate( 'w', $ts ) ); + break; case 'localdayname': - return $this->mVarCache[$index] = $wgContLang->getWeekdayName( $localDayOfWeek + 1 ); + $value = $wgContLang->getWeekdayName( $localDayOfWeek + 1 ); + break; case 'localyear': - return $this->mVarCache[$index] = $wgContLang->formatNum( $localYear, true ); + $value = $wgContLang->formatNum( $localYear, true ); + break; case 'localtime': - return $this->mVarCache[$index] = $wgContLang->time( $localTimestamp, false, false ); + $value = $wgContLang->time( $localTimestamp, false, false ); + break; case 'localhour': - return $this->mVarCache[$index] = $wgContLang->formatNum( $localHour, true ); + $value = $wgContLang->formatNum( $localHour, true ); + break; case 'localweek': // @bug 4594 PHP5 has it zero padded, PHP4 does not, cast to // int to remove the padding - return $this->mVarCache[$index] = $wgContLang->formatNum( (int)$localWeek ); + $value = $wgContLang->formatNum( (int)$localWeek ); + break; case 'localdow': - return $this->mVarCache[$index] = $wgContLang->formatNum( $localDayOfWeek ); + $value = $wgContLang->formatNum( $localDayOfWeek ); + break; case 'numberofarticles': - return $this->mVarCache[$index] = $wgContLang->formatNum( SiteStats::articles() ); + $value = $wgContLang->formatNum( SiteStats::articles() ); + break; case 'numberoffiles': - return $this->mVarCache[$index] = $wgContLang->formatNum( SiteStats::images() ); + $value = $wgContLang->formatNum( SiteStats::images() ); + break; case 'numberofusers': - return $this->mVarCache[$index] = $wgContLang->formatNum( SiteStats::users() ); + $value = $wgContLang->formatNum( SiteStats::users() ); + break; case 'numberofactiveusers': - return $this->mVarCache[$index] = $wgContLang->formatNum( SiteStats::activeUsers() ); + $value = $wgContLang->formatNum( SiteStats::activeUsers() ); + break; case 'numberofpages': - return $this->mVarCache[$index] = $wgContLang->formatNum( SiteStats::pages() ); + $value = $wgContLang->formatNum( SiteStats::pages() ); + break; case 'numberofadmins': - return $this->mVarCache[$index] = $wgContLang->formatNum( SiteStats::numberingroup('sysop') ); + $value = $wgContLang->formatNum( SiteStats::numberingroup('sysop') ); + break; case 'numberofedits': - return $this->mVarCache[$index] = $wgContLang->formatNum( SiteStats::edits() ); + $value = $wgContLang->formatNum( SiteStats::edits() ); + break; case 'numberofviews': - return $this->mVarCache[$index] = $wgContLang->formatNum( SiteStats::views() ); + $value = $wgContLang->formatNum( SiteStats::views() ); + break; case 'currenttimestamp': - return $this->mVarCache[$index] = wfTimestamp( TS_MW, $ts ); + $value = wfTimestamp( TS_MW, $ts ); + break; case 'localtimestamp': - return $this->mVarCache[$index] = $localTimestamp; + $value = $localTimestamp; + break; case 'currentversion': - return $this->mVarCache[$index] = SpecialVersion::getVersion(); + $value = SpecialVersion::getVersion(); + break; case 'sitename': return $wgSitename; case 'server': @@ -2515,8 +2577,6 @@ class Parser return $wgServerName; case 'scriptpath': return $wgScriptPath; - case 'stylepath': - return $wgStylePath; case 'directionmark': return $wgContLang->getDirMark(); case 'contentlanguage': @@ -2529,6 +2589,11 @@ class Parser else return null; } + + if ( $index ) + $this->mVarCache[$index] = $value; + + return $value; } /**