On 07/12/11 09:52, Daniel Barrett wrote:
Tim Starling writes:
You can add or modify messages when the cache is built by hooking LocalisationCacheRecache, and you can add a cache dependency to trigger a rebuild by adding elements to $allData['deps'].
Thanks. Do I need to do both, or is this an either/or choice?
You don't need to add the cache dependency if the message only changes when the *.i18n.php or Messages*.php files change. It sounds like that's the case for your extension.
What extension is this for?
A parser tag extension (unreleased) that hits a SQL Server database to retrieve data. The parser tag dynamically categorizes its calling articles in "Category:Pages that hit SQL Server databases" for our bookkeeping purposes (and our DBA staff). To make this flexible, the extension doesn't insert a category tag directly, but transcludes a system message that contains the category tag. (This way we can change the category tag by editing the system message, rather than modifying PHP code.) That's where we're calling $wgMessageCache->addMessage().
You should have a look at how tracking categories work in the core, see Parser::addTrackingCategory(). It's not necessary to add any text to the page if there's a parser function on the page, the parser function can register the category directly in the output object.
-- Tim Starling