PageRegenerate

Summary: Make PmWiki regenerate a page, as if someone had done an edit+save sequence.
Version: 1.0
Prerequisites: None.
Status: Stable
Maintainer: Anno
Categories: Administration, PHP72

Questions answered by this recipe

This section is optional; use it to indicate the types of questions (if any) this recipe is intended to answer.

Description

Make PmWiki regenerate a page, as if someone had done an edit+save sequence.

Installation

Add to your config.php file:

if ($action == 'regen') {
  $action = 'edit';
  $EnablePmToken = 0;
  $_POST = array('post'=>'1');
}

Executing ?action=regen on any page will cause PmWiki to regenerate the page, as if someone had done an edit+save sequence.

Release Notes

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".

See Also

Contributors

Pm
Anno

Comments

This works well when you have only a handful of pages to regenerate, but what happens when you mass update several (in my case, all) or your pages and have to regenerate everything? Simply doing something like:

    cd .../wiki.d
    for f in * ; do
        curl http://www.example.com/wiki/pmwiki.php?n=$f&action=regen > /dev/null
    done

doesn't work when some or all of the pages are edit locked? — tamouse July 15, 2012, at 05:20 AM

You could either log in via the curl/wget script before editing, or temporarily unlock the wiki while you regenerate it. --Petko July 15, 2012, at 06:25 AM

  if ($action == 'regen') 
    { unset($DefaultPasswords['edit']); $action = 'edit'; ... }
Thanks, Petko. I investigated the first option, and found it ridiculously simple:
         cd .../wiki.d
         curl -c /tmp/cookies.txt -d 'authid=<user>&authpw=<pass>&submit=Go' 'http://www.example.com/wiki/pmwiki.php?action=login'
         for f in * ; do
            curl -b /tmp/cookies.txt "http://www.example.com/wiki/pmwiki.php?n=$f&action=regen" > /dev/null
         done
         rm /tmp/cookies.txt
where <user> is user login name, <pass> is their password.
I ran this on my staging wiki and it worked a treat. Exactly what I needed. I prefer this method to modifying local/config.php
tamouse July 15, 2012, at 02:48 PM

User notes +1: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.