Rowan Collins wrote:
On 25/04/05, Tim Starling timstarling@users.sourceforge.net wrote:
Modified Files: Parser.php Log Message: Cleared $wgLinkHolders after they are used. This fixes bug 1770 and probably improves performance too.
This change has the unfortunate side-effect that one can no longer replace the link holders from just one part of the page, as this will cause all the link targets to be effectively thrown away (with some rather amusing effects).
The only place I know that does this is the hack to make links within image captions not disappear. This is very hacky at the moment anyway, as it uses the $wgParser global from Linker.php, but I'm just about done rewriting that code such that that part (i.e. the parsing part) will be in Parser.php anyway.
Would it be ugly to add a parameter to switch off this clearing out, so that that approach could still be used?
As I said on #mediawiki when I was whinging about bug 1770, if a solution involves globals, it's the wrong solution. I'm not surprised that my quick hack caused side-effects, but I really hate link table corruption so I wanted to fix that first.
Perhaps a better solution would be to break up Skin::makeLinkObj() to the point where a workalike function can be put in Parser with minimal code duplication. The function in Parser would add link holders to a Parser member variable, and the Skin::makeLinkObj() would just resolve links immediately. Skin::makeLinkObj() would mainly be called for navigation links and special pages.
Note that in 1.5 I have added a LinkBatch class, which makes it easy for special pages to add batches of links to the link cache with a single DB query.
-- Tim Starling