ExpireDiff

Summary: How to remove a page's history
Version: 20180109
Prerequisites:
Status: Stable
Maintainer: Petko (original author: Pm)
Discussion: ExpireDiff-Talk
Categories: Administration, PHP72
License: GPLv2

Question answered by this recipe

How do I remove a page's history?

Answer

The expirediff.phpΔ script adds ?action=expirediff, which removes all of the page revision history information from a wiki page. It requires the user to have edit permissions to the page, and handles locking. It also creates a backup copy of the page with the page revisions intact (same as if someone had requested to delete a page).

In addition, one can add the keepdays=nn parameter, which says to keep any page history within the past nn days. For example, ?action=expirediff&keepdays=7 will remove any page history older than seven days. By default keepdays is zero, which expires the entire page history.

You can also remove the history of all pages or only the history of a specified group. It is possible to specify some options when calling the function ExpireDiffAll from your config.php. The first parameter specifies the group whose files history should be removed. Default is '' which means all files. The second parameter specifies whether backups should be created, 0 means overwrite existing files (defaults to 1). Be careful with this option! The third parameter specifies which histories should be kept, see keepdays above (defaults to 0).

Example:
    
    ExpireDiffAll('Test',0,5);
    

means: Remove the history older than 5 days from all files within the Group Test and overwrite existing files (no backup).

To install this script, simply copy it into your cookbook/ subdirectory, and then add the line

    include_once("$FarmD/cookbook/expirediff.php");

to your local/config.php file.

Page directive

The script also includes a directive (:nohistory:) which, when placed in a page, drops all previous history and does not record new history.

To enable the directive, add to config.php before the include_once line:

  $EnableNoHistoryDirective = 1;

By default this is disabled to prevent abuse -- enable it only when you have complete confidence both in the good will and the technical abilities of the people who edit your wiki.

Note, the directive works for individual pages only: placing it in an included page or a header/footer will only drop the history of the included page or header/footer.

Release notes

  • 20180109, fix bug introduced yesterday, reported by Frank
  • 20180108, add (:nohistory:), $EnableNoHistoryDirective (Petko)
  • 20170928, Fix undefined $keepdays integer value 0 when not set (Petko)
  • 20150821, Add license block and $RecipeInfo tag (Petko)
  • 20050824, Fixed bug introduced with last change (Klonk)
  • 20050810, Updated to add the action with help of $HandleActions (Klonk)
  • 20050414, Added function ExpireDiffAll (Klonk)
  • 20041218, original release (Pm)

See Also

Contributors

  • See Release notes for contributions to the source code.
  • Hagan, Suggestion to fix password protection.
  • Dfaure, Suggestion to add ExpireDiff to end of history page.
  • Ian MacGregor, Suggestion to style (via CSS) ExpireDiff on history page.
  • Petko is the maintainer of this recipe.

Comments

See discussion at ExpireDiff-Talk

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