Prevent deletion of pages by empty saves when page IDs or file paths match configured regular expressions. Only administrators and optionally exempt groups may delete such pages.
Compatible with DokuWiki
Prevent deletion of pages by empty saves when page IDs or file paths match configured regular expressions. Only administrators and optionally exempt groups may delete such pages.
The Delete Page Guard plugin prevents accidental or intentional deletion of wiki pages in your DokuWiki installation by blocking the “empty save” operation when certain pages are protected. A page is considered for protection when its ID or relative file path matches one or more regular expressions configured via the DokuWiki Configuration Manager.
Install the plugin using the Extension Manager and the download URL above, which points to the latest version. Or download the package manually and extract it into your DokuWiki's lib/plugins/ directory.
After installation, visit the Configuration Manager in your DokuWiki admin panel and adjust the plugin settings under the “Delete Page Guard” section.
The following options are available in the Configuration Manager:
| Setting | Description |
|---|---|
| Protected page patterns | Regular expression patterns to protect pages from deletion. Enter one pattern per line. When a page matches any pattern, only administrators (and optionally configured groups) can delete it via empty save. Invalid patterns are automatically skipped with warnings shown to administrators. |
| Match against | Choose whether the patterns should match against the page ID (e.g. users:john:home) or the relative file path (e.g. users/john/home.txt). |
| Extra groups allowed to delete | Comma separated list of user groups that are allowed to delete protected pages, in addition to administrators. Leave empty to restrict deletion to admins only. |
| Treat whitespace-only pages as empty | If enabled, pages containing only whitespace will be treated as empty and deletion will be blocked on protected pages. |
^users: – protect all pages in the users namespace^users:[^:]+:start$ – protect every user's landing page named start under users:<username>^projects:.*$ – protect everything in the projects namespace^private/.*\.txt$ – when matching against file paths, protect any .txt file in the private directoryThe plugin includes comprehensive pattern validation:
When a page is saved, DokuWiki triggers the COMMON_WIKIPAGE_SAVE event just before writing to disk. For normal edits, the plugin does nothing. However, when the new content is empty (after optional trimming) the plugin checks the configured patterns against the chosen target (ID or file path). If a match occurs and the current user is not an administrator and not in one of the exempt groups, the plugin prevents the deletion and displays an error message.
The plugin includes a comprehensive test suite for developers:
# Run all tests php tests/test_runner.php # Check syntax of all files make check # See all available commands make help
The test suite includes 32 comprehensive tests covering pattern validation, matching logic, security features, and edge cases without requiring a DokuWiki installation.
For maintainers and contributors, see the RELEASE.md file for the complete release workflow.
This plugin has been tested with DokuWiki “Librarian” (2025-05-14b).
It hooks into the COMMON_WIKIPAGE_SAVE event, which was introduced in DokuWiki release “Detritus” (2016-02-24) and is marked as preventable. The plugin uses only stable, public APIs and the documented event system that have been available since “Detritus”, so it should work with most recent DokuWiki versions. Please report any compatibility issues on GitHub.
See CHANGELOG.md for detailed release notes.
This plugin is released under the GNU General Public License v2.