Page MenuHomePhabricator

Implement default value replacement for Gregorian calendar date with today's date as per local client wiki timezone.
Closed, ResolvedPublic

Description

Description

Implement in ClientHook and FunctionCallHandler the solution for default value replacement decided in T391019: [Spike] Decide whether to set the date default value in ClientHook or in FunctionCallHandler

Acceptance criteria

  • Functions which take Gregorian calendar date input types should successfully run when called with empty values
  • An input with an empty value should be interpreted as today's date in the client wiki locale.

(see testing wikitext at the bottom)

Implementation details

According to the decisions made for spike T391019: [Spike] Decide whether to set the date default value in ClientHook or in FunctionCallHandler:

We set default values in the client:

  • If we don't encounter any empty argument, we go as normally (zero fetches)
  • If we encounter at least one empty argument, we do:
    • fetch function from cache
    • or, if cache miss, fetch from wikilambda_fetch
    • get empty argument type
    • see if there's any default value callback for this type
    • if there is, generate default value and set instead of empty argument
  • we use the final function call to generate the WikiLambdaClientFunctionCall cache key
  • we proceed normally (check cache, else run WikifunctionsClientRequestJob asynchronously, etc.

Testing Wikitext

== Default Values (T391021) ==

Age:
{{#function:Z20756|31-05-1985|06-05-2025}}

Age with default value:
{{#function:Z20756|31-05-1985|}}

Years to Connect:
{{#function:Z20756|06-05-2025|01-09-2026}}

Years to Connect with default value:
{{#function:Z20756||01-09-2026}}

Distance to the moon today:
{{#function:Z20741|06-05-2025}}

Distance to the moon today with default values:
{{#function:Z20741|}}

Today's date:
{{#function:Z20788|06-05-2025}}

Today's date with default values:
{{#function:Z20788|}}

Fecha de hoy:
{{#function:Z20794|06-05-2025}}

Fecha de hoy with default values:
{{#function:Z20794|}}

Completion checklist

Event Timeline

DSantamaria triaged this task as Medium priority.Apr 9 2025, 4:58 PM

Change #1142700 had a related patch set uploaded (by Genoveva Galarza; author: Genoveva Galarza):

[mediawiki/extensions/WikiLambda@master] [WIP] Implement default value replacement in Fragment Handler for dates

https://gerrit.wikimedia.org/r/1142700

gengh changed the task status from Open to In Progress.May 6 2025, 10:03 PM

Change #1142700 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] Implement default value replacement in Fragment Handler for dates

https://gerrit.wikimedia.org/r/1142700