89 ConvertibleTimestamp $ts,
91 LoggerInterface $logger
93 $pageLang = $parser->getTargetLanguage();
95 $cacheTTL = self::CACHE_TTL_BY_ID[$id] ?? -1;
96 if ( $cacheTTL > -1 ) {
97 $parser->
getOutput()->updateCacheExpiry( $cacheTTL );
106 self::applyUnitTimestampDeadline( $parser, $ts,
'M' );
108 return $pageLang->formatNumNoSeparators( $ts->format(
'm' ) );
109 case 'currentmonth1':
110 self::applyUnitTimestampDeadline( $parser, $ts,
'M' );
112 return $pageLang->formatNumNoSeparators( $ts->format(
'n' ) );
113 case 'currentmonthname':
114 self::applyUnitTimestampDeadline( $parser, $ts,
'M' );
116 return $pageLang->getMonthName( (
int)$ts->format(
'n' ) );
117 case 'currentmonthnamegen':
118 self::applyUnitTimestampDeadline( $parser, $ts,
'M' );
120 return $pageLang->getMonthNameGen( (
int)$ts->format(
'n' ) );
121 case 'currentmonthabbrev':
122 self::applyUnitTimestampDeadline( $parser, $ts,
'M' );
124 return $pageLang->getMonthAbbreviation( (
int)$ts->format(
'n' ) );
126 self::applyUnitTimestampDeadline( $parser, $ts,
'D' );
128 return $pageLang->formatNumNoSeparators( $ts->format(
'j' ) );
130 self::applyUnitTimestampDeadline( $parser, $ts,
'D' );
132 return $pageLang->formatNumNoSeparators( $ts->format(
'd' ) );
134 $localTs = self::makeTsLocal( $svcOptions, $ts );
135 self::applyUnitTimestampDeadline( $parser, $localTs,
'M' );
137 return $pageLang->formatNumNoSeparators( $localTs->format(
'm' ) );
139 $localTs = self::makeTsLocal( $svcOptions, $ts );
140 self::applyUnitTimestampDeadline( $parser, $localTs,
'M' );
142 return $pageLang->formatNumNoSeparators( $localTs->format(
'n' ) );
143 case 'localmonthname':
144 $localTs = self::makeTsLocal( $svcOptions, $ts );
145 self::applyUnitTimestampDeadline( $parser, $localTs,
'M' );
147 return $pageLang->getMonthName( (
int)$localTs->format(
'n' ) );
148 case 'localmonthnamegen':
149 $localTs = self::makeTsLocal( $svcOptions, $ts );
150 self::applyUnitTimestampDeadline( $parser, $localTs,
'M' );
152 return $pageLang->getMonthNameGen( (
int)$localTs->format(
'n' ) );
153 case 'localmonthabbrev':
154 $localTs = self::makeTsLocal( $svcOptions, $ts );
155 self::applyUnitTimestampDeadline( $parser, $localTs,
'M' );
157 return $pageLang->getMonthAbbreviation( (
int)$localTs->format(
'n' ) );
159 $localTs = self::makeTsLocal( $svcOptions, $ts );
160 self::applyUnitTimestampDeadline( $parser, $localTs,
'D' );
162 return $pageLang->formatNumNoSeparators( $localTs->format(
'j' ) );
164 $localTs = self::makeTsLocal( $svcOptions, $ts );
165 self::applyUnitTimestampDeadline( $parser, $localTs,
'D' );
167 return $pageLang->formatNumNoSeparators( $localTs->format(
'd' ) );
171 case 'fullpagenamee':
175 case 'rootpagenamee':
177 case 'basepagenamee':
179 case 'talkpagenamee':
180 case 'subjectpagename':
181 case 'subjectpagenamee':
187 case 'revisionmonth':
188 case 'revisionmonth1':
190 case 'revisiontimestamp':
193 case 'namespacenumber':
197 case 'subjectspacee':
198 case 'cascadingsources':
199 # First argument of the corresponding parser function
200 # (second argument of the PHP implementation) is
203 # Note that for many of these {{FOO}} is subtly different
204 # from {{FOO:{{PAGENAME}}}}, so we can't pass $title here
205 # we have to explicitly use the "no arguments" form of the
206 # parser function by passing `null` to indicate a missing
207 # argument (which then defaults to the current page title).
208 return CoreParserFunctions::$id( $parser,
null );
211 case 'currentdayname':
212 self::applyUnitTimestampDeadline( $parser, $ts,
'D' );
214 return $pageLang->getWeekdayName( (
int)$ts->format(
'w' ) + 1 );
216 self::applyUnitTimestampDeadline( $parser, $ts,
'Y' );
218 return $pageLang->formatNumNoSeparators( $ts->format(
'Y' ) );
220 return $pageLang->time( $ts->getTimestamp( TS_MW ),
false,
false );
222 self::applyUnitTimestampDeadline( $parser, $ts,
'H' );
224 return $pageLang->formatNumNoSeparators( $ts->format(
'H' ) );
226 self::applyUnitTimestampDeadline( $parser, $ts,
'D' );
229 return $pageLang->formatNum( (
int)$ts->format(
'W' ) );
231 self::applyUnitTimestampDeadline( $parser, $ts,
'D' );
233 return $pageLang->formatNum( $ts->format(
'w' ) );
235 $localTs = self::makeTsLocal( $svcOptions, $ts );
236 self::applyUnitTimestampDeadline( $parser, $localTs,
'D' );
238 return $pageLang->getWeekdayName( (
int)$localTs->format(
'w' ) + 1 );
240 $localTs = self::makeTsLocal( $svcOptions, $ts );
241 self::applyUnitTimestampDeadline( $parser, $localTs,
'Y' );
243 return $pageLang->formatNumNoSeparators( $localTs->format(
'Y' ) );
245 $localTs = self::makeTsLocal( $svcOptions, $ts );
247 return $pageLang->time(
248 $localTs->format(
'YmdHis' ),
253 $localTs = self::makeTsLocal( $svcOptions, $ts );
254 self::applyUnitTimestampDeadline( $parser, $localTs,
'H' );
256 return $pageLang->formatNumNoSeparators( $localTs->format(
'H' ) );
258 $localTs = self::makeTsLocal( $svcOptions, $ts );
259 self::applyUnitTimestampDeadline( $parser, $localTs,
'D' );
262 return $pageLang->formatNum( (
int)$localTs->format(
'W' ) );
264 $localTs = self::makeTsLocal( $svcOptions, $ts );
265 self::applyUnitTimestampDeadline( $parser, $localTs,
'D' );
267 return $pageLang->formatNum( $localTs->format(
'w' ) );
268 case 'numberofarticles':
269 case 'numberoffiles':
270 case 'numberofusers':
271 case 'numberofactiveusers':
272 case 'numberofpages':
273 case 'numberofadmins':
274 case 'numberofedits':
275 # second argument is 'raw'; magic variables are "not raw"
276 return CoreParserFunctions::$id( $parser,
null );
277 case 'currenttimestamp':
278 return $ts->getTimestamp( TS_MW );
279 case 'localtimestamp':
280 $localTs = self::makeTsLocal( $svcOptions, $ts );
282 return $localTs->format(
'YmdHis' );
283 case 'currentversion':
284 return SpecialVersion::getVersion();
286 return (
string)$svcOptions->
get( MainConfigNames::ArticlePath );
288 return (
string)$svcOptions->
get( MainConfigNames::Sitename );
290 return (
string)$svcOptions->
get( MainConfigNames::Server );
292 return (
string)$svcOptions->
get( MainConfigNames::ServerName );
294 return (
string)$svcOptions->
get( MainConfigNames::ScriptPath );
296 return (
string)$svcOptions->
get( MainConfigNames::StylePath );
297 case 'directionmark':
298 return $pageLang->getDirMark();
299 case 'contentlanguage':
302 return $pageLang->getCode();
304 if ( $svcOptions->
get( MainConfigNames::ParserEnableUserLanguage ) ) {
307 return $pageLang->getCode();
312 # magic variables are the same as empty/default first argument
313 return CoreParserFunctions::$id( $parser );