1====== Delete Page Guard Plugin ====== 2 3---- plugin ---- 4description: 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. 5author : Johann Duscher 6email : jonny.dee@posteo.net 7type : action 8lastupdate : 2025-11-02 9compatible : Librarian 10depends : 11conflicts : 12similar : 13tags : protection, security, admin, pages, deletion 14 15downloadurl: https://github.com/jonnydee/deletepageguard/releases/download/v1.0.0/deletepageguard-1.0.0.zip 16bugtracker : https://github.com/jonnydee/deletepageguard/issues 17sourcerepo : https://github.com/jonnydee/deletepageguard 18donationurl: 19 20screenshot_img : 21---- 22 23===== Description ===== 24 25The **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. 26 27===== Features ===== 28 29 * Prevents deletion via "empty save" on protected pages 30 * Supports any number of protection patterns using PCRE syntax 31 * Choose whether to match against the colon-separated page ID or the relative file system path 32 * Allow administrators and optional additional groups to bypass the protection 33 * Optionally treat whitespace-only content as empty 34 * **Pattern validation**: Real-time validation with detailed error messages for administrators 35 * **Admin interface**: Dedicated admin page for testing and validating patterns 36 * **Security features**: Built-in ReDoS protection and input sanitization 37 38===== Installation ===== 39 40Install the plugin using the [[plugin:extension|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. 41 42After installation, visit the **Configuration Manager** in your DokuWiki admin panel and adjust the plugin settings under the "Delete Page Guard" section. 43 44===== Configuration ===== 45 46The following options are available in the Configuration Manager: 47 48^ Setting ^ Description ^ 49| **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. | 50| **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. | 51| **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. | 52 53==== Pattern Examples ==== 54 55 * ''%%^users:%%'' – protect all pages in the ''users'' namespace 56 * ''%%^users:[^:]+:start$%%'' – protect every user's landing page named ''start'' under ''users:<username>'' 57 * ''%%^projects:.*$%%'' – protect everything in the ''projects'' namespace 58 * ''%%^private/.*\.txt$%%'' – when matching against file paths, protect any ''.txt'' file in the ''private'' directory 59 60===== Pattern Validation ===== 61 62The plugin includes comprehensive pattern validation: 63 64 * **Real-time validation**: Invalid patterns are automatically detected when pages are saved 65 * **Administrator feedback**: Detailed error messages are shown to administrators when invalid patterns are encountered 66 * **Admin interface**: Visit **Admin → Delete Page Guard** to test and validate patterns before saving them to configuration 67 * **Security protection**: Built-in protection against ReDoS (Regular Expression Denial of Service) attacks 68 69===== How It Works ===== 70 71When 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. 72 73===== Development ===== 74 75The plugin includes a comprehensive test suite for developers: 76 77<code bash> 78# Run all tests 79php tests/test_runner.php 80 81# Check syntax of all files 82make check 83 84# See all available commands 85make help 86</code> 87 88The test suite includes 32 comprehensive tests covering pattern validation, matching logic, security features, and edge cases without requiring a DokuWiki installation. 89 90For maintainers and contributors, see the [[https://github.com/jonnydee/deletepageguard/blob/master/RELEASE.md|RELEASE.md]] file for the complete release workflow. 91 92===== Compatibility ===== 93 94This plugin has been tested with **DokuWiki "Librarian" (2025-05-14b)**. 95 96It 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. 97 98===== Changelog ===== 99 100See [[https://github.com/jonnydee/deletepageguard/blob/master/CHANGELOG.md|CHANGELOG.md]] for detailed release notes. 101 102 * **2025-11-02** 103 * Initial release v1.0.0 104 * Core deletion prevention functionality 105 * Pattern validation with ReDoS protection 106 * Admin interface for testing patterns 107 * Comprehensive test suite 108 109===== License ===== 110 111This plugin is released under the [[https://www.gnu.org/licenses/gpl-2.0.html|GNU General Public License v2]]. 112 113===== Support ===== 114 115 * **Bug Reports**: [[https://github.com/jonnydee/deletepageguard/issues|GitHub Issues]] 116 * **Source Code**: [[https://github.com/jonnydee/deletepageguard|GitHub Repository]] 117 * **Discussion**: [[https://github.com/jonnydee/deletepageguard/discussions| GitHub Discussions]] 118