Author: rowan.collins
Description:
If a page ([[A]]) includes a template ("{{B}}"), and that template includes
another template ("{{C}}"), (so the content of [[Template:C]] is visible when
viewing [[A]]), a change to [[Template:C]] will not be visible on [[A]] until
the cache is manually purged. This is because the Template code only purges the
cache for pages which have 'links' entries pointing to [[Template:C]], and [[A]]
is not listed there.
If, as suggested at bug 734, there was a seperate database table for inclusions,
the section of Article.php that handles the purging (in updateArticle()) could
be made to do the purging "recursively". In fact, actual recursion is
unnecessary, we just need 2 lists: "$open" and "$closed"; pseudo-code follows
(omitting boring bits like converting objects to and from strings):
$open = $this->getInclusionsTo();
while(! is_empty($open) ) {
$next=pop($open); if(isset(($closed[$next])) { continue; } # do each only once $closed[$next] = true; array_merge($open, $next->getInclusionsTo()); $pages_to_purge[] = $next; # actually, the array is called "$urls" currently
}
An alternative solution is to record a link in the database [again, preferably
in an 'inclusionlinks' table] between [[A]] and [[Template:C]] when [[A]]
includes {{B}} and [[Template:B]] includes {{C}}. (I tried to work out what it
is that stops this happening already; but I couldn't understand the code well
enough, and gave up. Is it a deliberate behaviour, or just a product of the way
recursive templates are handled?) This would of course have the side-effect of
[[A]] appearing on a Whatlinkshere-type list of "pages which include
[[Template:C]]", but perhaps this would be a good thing, since, visually, it does.
Version: unspecified
Severity: normal