I would like to update the Main_Page of our wiki from a script run by cron.
Apart from the page content itself, in pagecontent.old_text
, what else do I need to update?
If I only update the "old_text" field, the new content is not displayed. I get the previous content, presumably from a cache somewhere. In LocalSettings.php
I have $wgMainCacheType = CACHE_NONE;
. So I guess that I need to also update something else in the Mediawiki database?
(In case it matters, this is with Mediawiki 1.31.10 on Debian 10 with Apache and PostgreSQL)
2
Answers
Updating the timestamp in
page.page_touched
works to have the wiki show the new content.This example is using a PostgreSQL database, so it might need some adjustments if used with the more common MySQL DB.
To update the text of a page identified by it's name, it is necessary to join the
page
,revision
andpagecontent
tables. This example updates a page named "Drafts":And to update the page timestamp so that the wiki shows the new content:
An alternative which avoids tinkering with the database directly, is to use an extension like External Data. There are examples here to embed a text file in a page, and here to embed the output of a database query.
Use
maintenance/edit.php
, the edit API, Pywikibot etc. Trying to do changes via direct DB manipulation is a rather bad idea.