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** | List of PCRE regular expressions. Each line defines a pattern. When a page matches any pattern, non-admin users cannot delete it by empty save. Invalid patterns are automatically skipped with warnings shown to administrators. | 50| **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''). | 51| **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. | 52| **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. | 53 54==== Pattern Examples ==== 55 56 * ''%%^users:%%'' – protect all pages in the ''users'' namespace 57 * ''%%^users:[^:]+:start$%%'' – protect every user's landing page named ''start'' under ''users:<username>'' 58 * ''%%^projects:.*$%%'' – protect everything in the ''projects'' namespace 59 * ''%%^private/.*\.txt$%%'' – when matching against file paths, protect any ''.txt'' file in the ''private'' directory 60 61===== Pattern Validation ===== 62 63The plugin includes comprehensive pattern validation: 64 65 * **Real-time validation**: Invalid patterns are automatically detected when pages are saved 66 * **Administrator feedback**: Detailed error messages are shown to administrators when invalid patterns are encountered 67 * **Admin interface**: Visit **Admin → Delete Page Guard** to test and validate patterns before saving them to configuration 68 * **Security protection**: Built-in protection against ReDoS (Regular Expression Denial of Service) attacks 69 70===== How It Works ===== 71 72When 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. 73 74===== Development ===== 75 76The plugin includes a comprehensive test suite for developers: 77 78<code bash> 79# Run all tests 80php tests/test_runner.php 81 82# Check syntax of all files 83make check 84 85# See all available commands 86make help 87</code> 88 89The test suite includes 32 comprehensive tests covering pattern validation, matching logic, security features, and edge cases without requiring a DokuWiki installation. 90 91For maintainers and contributors, see the [[https://github.com/jonnydee/deletepageguard/blob/master/RELEASE.md|RELEASE.md]] file for the complete release workflow. 92 93===== Compatibility ===== 94 95This plugin has been tested with **DokuWiki "Librarian" (2025-05-14b)**. 96 97It 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. 98 99===== Changelog ===== 100 101See [[https://github.com/jonnydee/deletepageguard/blob/master/CHANGELOG.md|CHANGELOG.md]] for detailed release notes. 102 103 * **2025-11-02** 104 * Initial release v1.0.0 105 * Core deletion prevention functionality 106 * Pattern validation with ReDoS protection 107 * Admin interface for testing patterns 108 * Comprehensive test suite (32 tests) 109 110===== License ===== 111 112This plugin is released under the [[https://www.gnu.org/licenses/gpl-2.0.html|GNU General Public License v2]]. 113 114===== Support ===== 115 116 * **Bug Reports**: [[https://github.com/jonnydee/deletepageguard/issues|GitHub Issues]] 117 * **Source Code**: [[https://github.com/jonnydee/deletepageguard|GitHub Repository]] 118 * **Discussion**: Use the discussion section below 119