It's better when it's simple

User Tools

Site Tools



Intercept or modify saving of a wiki page
save the given content and create a new revision

This event is signalled by saveWikiText() in inc/common.php when a page is saved, handlers can use it to:

  • prevent saves by either preventing the default action or overwriting the contentChanged field in a BEFORE hook
  • enforce saves even when no content changed by overwriting the contentChanged field in a BEFORE hook
  • adjust the saved content by modifying the newContent field in a BEFORE hook
  • adjust the stored change log information (summary, type, extras) in an AFTER hook
  • easily know if a page was deleted, created or edited by inspecting the changeType field
  • do whatever they want before or after a wiki page is saved

Passed Data

The passed Doku_Event has the field $data.

$data is an array with the following keys:

  • id – the page ID of the page to save
  • file – the path to the corresponding file of that page
  • revertFrom – if this save is a revert to an older version, that older version is in here. falsy otherwise
  • oldRevision – this is the revision date (timestamp) of the page before the save
  • newRevision – this is the revision date (timestamp) of the page after the save (only available in the AFTER event)
  • newContent – the new page content to be saved
  • oldContent – the page's content before saving
  • summary – the edit summary
  • contentChanged – a boolean comparing newContent and oldContent. The default action is only executed when this is true. A BEFORE hook could change it to true to force saving even when the page content did not change
  • changeInfo – additional info to be stored with the changelog. usually empty. Contains revertFrom for reverts.
  • changeType – one of the following constants:
  • sizechange – contains after saving the size (in bytes) of the saved change

See also

devel/event/common_wikipage_save.txt · Last modified: 2018-12-08 15:08 by torpedo

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki