Page MenuHomePhabricator

Frame::getTTL() appears to be completely unused
Open, Needs TriagePublic

Description

Frame::setTTL() and Frame::getTTL() appear to have been added to support some sort of selective update mechanism/frame cache, but these values are never used in current MediaWiki:

https://codesearch.wmcloud.org/search/?q=getTTL&files=&excludeFiles=&repos=

The only use is in ApiExpandTemplates where the TTL is reported as part of the API output.

Further, the documentation for Frame::getTTL() implies that it should apply up the frame tree: "Set the TTL of the output of this frame and all of its ancestors" but there is no code anywhere which walks the frame tree to compute the TTL in this way. Ie, in theory every Frame::getTTL() should return the minimum of its own local Frame::$ttl and the result of Frame::getTTL() on all child frames, but frames don't even maintain pointers to their child frames (frame pointers point up to the parent, not down to the children).
EDIT: PPTemplateFrame_Hash::setTTL() calls $this->parent->setTTL($ttl); which probably implements the needed frame tree walk, albeit somewhat inefficiently (parents walked even if no change to $ttl is made).

There is a lot of code which carefully computes accurate TTLs for functions involving dates and times, for example ParserFunctions::timeCommon() from Extension:ParserFunctions, the implementation of formatCurrentDate in Scribunto, and Language::sprintfDate in core, but this information appears to be complete unused. The only /effective/ date-related TTL adjustment seems to be in CoreMagicVariables in core, which handles __CURRENTMONTH__ and similar, and directly updates $parser->getOutput()->updateCacheExpiry().

The Frame::getTTL()/::setTTL() methods should probably be deprecated, and the code which uses it should instead change to updating the cache expiry in the ParserOutput, the way that CoreMagicVariables does. This will be compatible with Parsoid (which doesn't export a full Frame stack to clients) and selective update (which handles serializing and merging ParserOutput objects from fragments).

Event Timeline

Change #1128460 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/core@master] Deprecate PPFrame::setTTL()

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

Change #1128460 merged by jenkins-bot:

[mediawiki/core@master] Deprecate PPFrame::setTTL()

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

Change #1201767 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/core@master] WIP: Deprecate Frame::{get,set}TTL() and Frame::{get,set}Volatile()

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

Change #1201829 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/extensions/Scribunto@master] Remove use of Frame::setTTL/getTTL

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

Change #1201835 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/extensions/Cite@master] Remove deprecated use of Frame::setVolatile()

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

Change #1201836 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/core@master] WIP: Deprecate Frame::{get,set}Volatile()

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

Change #1201838 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/extensions/ParserFunctions@master] Replace use of (ineffective) Frame::setTTL()

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

Change #1201839 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/core@master] Export CoreMagicVariables::adjustTTL()

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

Change #1201839 abandoned by C. Scott Ananian:

[mediawiki/core@master] Export CoreMagicVariables::adjustTTL()

Reason:

In favor of I6db458bc05638f744a18a4bcddff0c74bf21d038

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

Change #1202219 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/core@master] Export Language::computeUnitTimestampDeadline()

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

Change #1202219 merged by jenkins-bot:

[mediawiki/core@master] Export Language::computeUnitTimestampDeadline()

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

Change #1201838 merged by jenkins-bot:

[mediawiki/extensions/ParserFunctions@master] Replace use of (ineffective) Frame::setTTL()

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

Change #1201829 merged by jenkins-bot:

[mediawiki/extensions/Scribunto@master] Remove use of Frame::setTTL/getTTL

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

Change #1201767 merged by jenkins-bot:

[mediawiki/core@master] Deprecate Frame::{get,set}TTL()

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