Steps to reproduce:
- Visit a page on which a Lua module with os.date('*t') is run and the current day/month/year is accessed.
- Open the HTML source code and examine NewPP limit report.
Actual Results:
- Observed TTL ("Cache expiry") is too high.
Expected Results:
- Observed TTL corresponds to the time when the HTML output might change.
Example:
Report for Josef Hron (2592000 = 30 * 86400, i.e. 30 days) after the page was purged:
NewPP limit report Parsed by mw1362 Cached time: 20201217111322 Cache expiry: 2592000 Dynamic content: false Complications: [] [...]
The infobox loads the birthdate from Wikidata and uses Module:Wikidata/Formatters/time with the following piece of code to compute the person's age:
local Time = require 'Modul:Time' local osDate = os.date('*t') local currentTime = Time.new{ year = osDate.year, month = osDate.month, day = osDate.day, precision = Time.PRECISION.DAY, calendar = Time.CALENDAR.GREGORIAN, }
The following live code in Scribunto is expected to adjust the TTL, but that doesn't happen:
--- Create a table like the one os.date() returns, but with a metatable that sets TTLs as the values are looked at. local function wrapDateTable( now ) return setmetatable( {}, { __index = function( t, k ) if k == 'sec' then php.setTTL( 1 ) elseif k == 'min' then php.setTTL( 60 - now.sec ) elseif k == 'hour' then php.setTTL( 3600 - now.min * 60 - now.sec ) elseif now[k] ~= nil then php.setTTL( 86400 - now.hour * 3600 - now.min * 60 - now.sec ) end t[k] = now[k] return now[k] end } ) end
This code should have set the TTL to ca. 42398.