skip to Main Content

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


  1. Chosen as BEST ANSWER

    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 and pagecontent tables. This example updates a page named "Drafts":

    UPDATE pagecontent
    SET old_text = 'New page content'
    FROM page, revision
    WHERE page.page_title='Drafts'
      AND pagecontent.old_id=revision.rev_text_id
      AND page.page_latest=revision.rev_id;
    

    And to update the page timestamp so that the wiki shows the new content:

    UPDATE "page"
    SET page_touched = now()
    WHERE page_namespace = '0'
      AND page_title = 'Drafts';
    

    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.


  2. Use maintenance/edit.php, the edit API, Pywikibot etc. Trying to do changes via direct DB manipulation is a rather bad idea.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search