AutoRestore

Summary: Automatically restore pages after a set time interval
Version: 20201114
Prerequisites:
Status: Stable
Maintainer: Petko
Discussion: AutoRestore-Talk
Categories: Administration, PHP72

Questions answered by this recipe

How can I get PmWiki to automatically restore a page (e.g., the Main.WikiSandbox) after a set period of time?

Description

The autorestore.phpΔ script provides a mechanism to have select pages be automatically restored to known content after a set period of inactivity on the page.

Sometimes it is useful to have certain "sandbox" pages where authors can edit the page for experimenting and testing, but have the page revert back to a known version when the edits are finished. This recipe allows an administrator to select pages to be automatically restored in such a fashion.

Simply download autorestore.phpΔ and place it in the site's cookbook/ directory, and add the following lines to a local customization file.

    $AutoRestoreKeep = 900;            # keep edits for 15 minutes (900 seconds)
    include_once('cookbook/autorestore.php');

Next, manually create a directory called wikirev.d/ where the "known versions" of restored pages will be kept.

Now then, for any page that you want to have auto-restored, simply edit the page to contain the text you'd like to have restored, then copy that page's file from wiki.d/ into the wikirev.d/ directory you just created.

With this script enabled, any page copied into the wikirev.d/ directory will be automatically restored to that copy if more than $AutoRestoreKeep seconds have elapsed since the last edit of that page.

From version 20201114, an administrator can update existing pages in the wikirev.d or add new pages, by calling the page with the action "store", for example

  pmwiki.php?n=Main.WikiSandbox&action=store

The 'admin' password needs to be provided, then the page in wiki.d will be copied to the wikirev.d directory.

Notes

The AutoRestore script has been enabled on pmwiki.org for the Main.WikiSandbox page, which is automatically cleared after fifteen minutes of inactivity.

Pages will be restored the first time someone accesses the page directly after the timeout. Be aware that a side effect of this is that the old page contents will still be available for indirect accesses until someone accesses the page directly. Indirect accesses include accessing the page with an include or through a search (pagelist) and by accessing the page's content with the {Page$:var} markup.

Change log / Release notes

  • 20201114: add ?action=store, $AutoRestoreMessage to the edit form (Petko)

See also

Cookbook /
SessionPageStore  Temporary/Ephemeral page storage for testing purposes (Experimental)

Contributors

  • Petko - current maintainer
  • Pm, 2005-02-17

Comments

See discussion at AutoRestore-Talk

User notes +4: 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.