19a383d51SJohann Duscher====== Delete Page Guard Plugin ====== 29a383d51SJohann Duscher 39a383d51SJohann Duscher---- plugin ---- 49a383d51SJohann Duscherdescription: 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. 59a383d51SJohann Duscherauthor : Johann Duscher 69a383d51SJohann Duscheremail : jonny.dee@posteo.net 79a383d51SJohann Duschertype : action 89a383d51SJohann Duscherlastupdate : 2025-11-02 9bacaf983SJohann Duschercompatible : Librarian 109a383d51SJohann Duscherdepends : 119a383d51SJohann Duscherconflicts : 129a383d51SJohann Duschersimilar : 139a383d51SJohann Duschertags : protection, security, admin, pages, deletion 149a383d51SJohann Duscher 159a383d51SJohann Duscherdownloadurl: https://github.com/jonnydee/deletepageguard/releases/download/v1.0.0/deletepageguard-1.0.0.zip 169a383d51SJohann Duscherbugtracker : https://github.com/jonnydee/deletepageguard/issues 179a383d51SJohann Duschersourcerepo : https://github.com/jonnydee/deletepageguard 189a383d51SJohann Duscherdonationurl: 199a383d51SJohann Duscher 209a383d51SJohann Duscherscreenshot_img : 219a383d51SJohann Duscher---- 229a383d51SJohann Duscher 239a383d51SJohann Duscher===== Description ===== 249a383d51SJohann Duscher 259a383d51SJohann DuscherThe **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. 269a383d51SJohann Duscher 279a383d51SJohann Duscher===== Features ===== 289a383d51SJohann Duscher 299a383d51SJohann Duscher * Prevents deletion via "empty save" on protected pages 309a383d51SJohann Duscher * Supports any number of protection patterns using PCRE syntax 319a383d51SJohann Duscher * Choose whether to match against the colon-separated page ID or the relative file system path 329a383d51SJohann Duscher * Allow administrators and optional additional groups to bypass the protection 339a383d51SJohann Duscher * Optionally treat whitespace-only content as empty 349a383d51SJohann Duscher * **Pattern validation**: Real-time validation with detailed error messages for administrators 359a383d51SJohann Duscher * **Admin interface**: Dedicated admin page for testing and validating patterns 369a383d51SJohann Duscher * **Security features**: Built-in ReDoS protection and input sanitization 379a383d51SJohann Duscher 389a383d51SJohann Duscher===== Installation ===== 399a383d51SJohann Duscher 409a383d51SJohann DuscherInstall 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. 419a383d51SJohann Duscher 429a383d51SJohann DuscherAfter installation, visit the **Configuration Manager** in your DokuWiki admin panel and adjust the plugin settings under the "Delete Page Guard" section. 439a383d51SJohann Duscher 449a383d51SJohann Duscher===== Configuration ===== 459a383d51SJohann Duscher 469a383d51SJohann DuscherThe following options are available in the Configuration Manager: 479a383d51SJohann Duscher 489a383d51SJohann Duscher^ Setting ^ Description ^ 49*e5ef2aeaSJohann Duscher| **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. | 509a383d51SJohann Duscher| **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. | 519a383d51SJohann Duscher| **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. | 529a383d51SJohann Duscher 539a383d51SJohann Duscher==== Pattern Examples ==== 549a383d51SJohann Duscher 559a383d51SJohann Duscher * ''%%^users:%%'' – protect all pages in the ''users'' namespace 569a383d51SJohann Duscher * ''%%^users:[^:]+:start$%%'' – protect every user's landing page named ''start'' under ''users:<username>'' 579a383d51SJohann Duscher * ''%%^projects:.*$%%'' – protect everything in the ''projects'' namespace 589a383d51SJohann Duscher * ''%%^private/.*\.txt$%%'' – when matching against file paths, protect any ''.txt'' file in the ''private'' directory 599a383d51SJohann Duscher 609a383d51SJohann Duscher===== Pattern Validation ===== 619a383d51SJohann Duscher 629a383d51SJohann DuscherThe plugin includes comprehensive pattern validation: 639a383d51SJohann Duscher 649a383d51SJohann Duscher * **Real-time validation**: Invalid patterns are automatically detected when pages are saved 659a383d51SJohann Duscher * **Administrator feedback**: Detailed error messages are shown to administrators when invalid patterns are encountered 669a383d51SJohann Duscher * **Admin interface**: Visit **Admin → Delete Page Guard** to test and validate patterns before saving them to configuration 679a383d51SJohann Duscher * **Security protection**: Built-in protection against ReDoS (Regular Expression Denial of Service) attacks 689a383d51SJohann Duscher 699a383d51SJohann Duscher===== How It Works ===== 709a383d51SJohann Duscher 719a383d51SJohann DuscherWhen 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. 729a383d51SJohann Duscher 739a383d51SJohann Duscher===== Development ===== 749a383d51SJohann Duscher 759a383d51SJohann DuscherThe plugin includes a comprehensive test suite for developers: 769a383d51SJohann Duscher 779a383d51SJohann Duscher<code bash> 789a383d51SJohann Duscher# Run all tests 799a383d51SJohann Duscherphp tests/test_runner.php 809a383d51SJohann Duscher 819a383d51SJohann Duscher# Check syntax of all files 829a383d51SJohann Duschermake check 839a383d51SJohann Duscher 849a383d51SJohann Duscher# See all available commands 859a383d51SJohann Duschermake help 869a383d51SJohann Duscher</code> 879a383d51SJohann Duscher 889a383d51SJohann DuscherThe test suite includes 32 comprehensive tests covering pattern validation, matching logic, security features, and edge cases without requiring a DokuWiki installation. 899a383d51SJohann Duscher 909a383d51SJohann DuscherFor maintainers and contributors, see the [[https://github.com/jonnydee/deletepageguard/blob/master/RELEASE.md|RELEASE.md]] file for the complete release workflow. 919a383d51SJohann Duscher 929a383d51SJohann Duscher===== Compatibility ===== 939a383d51SJohann Duscher 94bacaf983SJohann DuscherThis plugin has been tested with **DokuWiki "Librarian" (2025-05-14b)**. 959a383d51SJohann Duscher 96bacaf983SJohann DuscherIt 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. 979a383d51SJohann Duscher 989a383d51SJohann Duscher===== Changelog ===== 999a383d51SJohann Duscher 1009a383d51SJohann DuscherSee [[https://github.com/jonnydee/deletepageguard/blob/master/CHANGELOG.md|CHANGELOG.md]] for detailed release notes. 1019a383d51SJohann Duscher 1029a383d51SJohann Duscher * **2025-11-02** 1039a383d51SJohann Duscher * Initial release v1.0.0 1049a383d51SJohann Duscher * Core deletion prevention functionality 1059a383d51SJohann Duscher * Pattern validation with ReDoS protection 1069a383d51SJohann Duscher * Admin interface for testing patterns 107*e5ef2aeaSJohann Duscher * Comprehensive test suite 1089a383d51SJohann Duscher 1099a383d51SJohann Duscher===== License ===== 1109a383d51SJohann Duscher 1119a383d51SJohann DuscherThis plugin is released under the [[https://www.gnu.org/licenses/gpl-2.0.html|GNU General Public License v2]]. 1129a383d51SJohann Duscher 1139a383d51SJohann Duscher===== Support ===== 1149a383d51SJohann Duscher 1159a383d51SJohann Duscher * **Bug Reports**: [[https://github.com/jonnydee/deletepageguard/issues|GitHub Issues]] 1169a383d51SJohann Duscher * **Source Code**: [[https://github.com/jonnydee/deletepageguard|GitHub Repository]] 117*e5ef2aeaSJohann Duscher * **Discussion**: [[https://github.com/jonnydee/deletepageguard/discussions| GitHub Discussions]] 118