feat(privacy): add check for missing wp_privacy_personal_data_erasers registration#1293
Open
faisalahammad wants to merge 1 commit intoWordPress:trunkfrom
Open
Conversation
Add a new static check that warns plugin authors when their plugin handles personal data (user meta, comment meta, direct DB writes) but does not register a callback via the wp_privacy_personal_data_erasers filter. - New check class: Personal_Data_Eraser_Check - Registered in Default_Check_Repository under 'personal_data_eraser' - PHPUnit test class with three test cases - Test data plugins (with and without eraser registration) Fixes WordPress#1252
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new static check (
Personal_Data_Eraser_Check) that warns plugin authors when their plugin appears to handle personal data — viaadd_user_meta,update_user_meta,add_comment_meta,update_comment_meta, or direct$wpdbwrites — but does not register a callback via thewp_privacy_personal_data_erasersfilter.Since WordPress 4.9.6, the Personal Data Removal tool lets site administrators honor GDPR erasure requests. Plugins storing personal data are expected to hook into this tool.
Fixes #1252
Changes
includes/Checker/Checks/Plugin_Repo/Personal_Data_Eraser_Check.php(new)Two-step static check: first confirm the plugin has at least one personal-data storage call, then verify whether it registers the
wp_privacy_personal_data_erasersfilter. A warning is only emitted when step 1 matches and step 2 does not — avoiding false positives for plugins that never touch personal data.Key constants:
Warning code:
missing_personal_data_eraserDocs link: https://developer.wordpress.org/plugins/privacy/adding-the-personal-data-eraser-to-your-plugin/
includes/Checker/Default_Check_Repository.phpTesting
Test 1: Plugin stores user meta, no eraser registered → should warn
update_user_meta()without hookingwp_privacy_personal_data_erasersmissing_personal_data_eraseris reported ✅Test 2: Plugin stores user meta and registers an eraser → should pass
update_user_meta()and registers viaadd_filter( 'wp_privacy_personal_data_erasers', ... )missing_personal_data_eraserwarning ✅Test 3: Plugin has no personal data handling → should pass
$wpdbwritesmissing_personal_data_eraserwarning ✅PHPUnit test class:
tests/phpunit/tests/Checker/Checks/Personal_Data_Eraser_Check_Tests.phpcovers all three cases with dedicated test data plugins.