Privacy: Reset wp_page_for_privacy_policy when the page is trashed or deleted - #11443
Privacy: Reset wp_page_for_privacy_policy when the page is trashed or deleted#11443masteradhoc wants to merge 33 commits into
Conversation
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
mukeshpanchal27
left a comment
There was a problem hiding this comment.
Thanks for the PR!
Left some initial feedbacks.
Co-authored-by: Mukesh Panchal <mukeshpanchal27@users.noreply.github.com>
Co-authored-by: Mukesh Panchal <mukeshpanchal27@users.noreply.github.com>
|
Your feedback has been added, thanks @mukeshpanchal27 ! |
|
This will need unit tests as well. |
Co-authored-by: Weston Ruter <westonruter@gmail.com>
|
Thanks to @nimesh-xecurify for his work on the Tests at #11520 |
In the future, it would be helpful to preserve that attribution by using a For example: |
There was a problem hiding this comment.
Pull request overview
This PR ensures the wp_page_for_privacy_policy option is cleared when the selected Privacy Policy page is trashed or permanently deleted, preventing the setting from pointing at an invalid page and adding a small “self-heal” in the admin notice path.
Changes:
- Add
_reset_privacy_policy_page_for_post()and hook it tobefore_delete_postandwp_trash_postto resetwp_page_for_privacy_policyto0. - Simplify the Privacy Settings screen logic by removing the special-case error for when the selected page is in the Trash.
- Add PHPUnit coverage for trash/delete resets, “do not reset” cases, the admin-notice self-heal behavior, and avoiding unnecessary option updates.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
tests/phpunit/tests/privacy/wpPrivacyResetPolicyPageForPost.php |
Adds new test coverage for resetting/self-healing behavior around wp_page_for_privacy_policy. |
src/wp-includes/post.php |
Introduces _reset_privacy_policy_page_for_post() to clear the option when the selected page is trashed/deleted. |
src/wp-includes/default-filters.php |
Hooks the new reset callback into core delete/trash actions. |
src/wp-admin/options-privacy.php |
Removes the “policy page is in the Trash” settings error path. |
src/wp-admin/includes/class-wp-privacy-policy-content.php |
Adds a self-healing guard to reset the option if it points to a non-existent page. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This reverts commit 0572273.
Co-authored-by: Weston Ruter <westonruter@gmail.com>
…steradhoc/wordpress-develop into 56694-uncached-database-reads
…steradhoc/wordpress-develop into 56694-uncached-database-reads
|
@mukeshpanchal27 @westonruter anything left here that needs to get adjusted? |
If the privacy page is deleted but the setting is left intact, an admin_hook would fire on every admin screen attempting to notify about changes in the privacy policy. With the page deleted, this database read is never cached, since it returns no results. Add a `before_delete_post` hook to reset setting if the post is deleted. Add a guard to reset the option on the privacy screen to cover edge cases. Developed in #11443, #11520 Props johnjamesjacoby, masteradhoc, westonruter, nimeshatxecurify, mukesh27, joedolson. Fixes #56694. git-svn-id: https://develop.svn.wordpress.org/trunk@62845 602fd350-edb4-49c9-b593-d223f7449a82
If the privacy page is deleted but the setting is left intact, an admin_hook would fire on every admin screen attempting to notify about changes in the privacy policy. With the page deleted, this database read is never cached, since it returns no results. Add a `before_delete_post` hook to reset setting if the post is deleted. Add a guard to reset the option on the privacy screen to cover edge cases. Developed in WordPress/wordpress-develop#11443, WordPress/wordpress-develop#11520 Props johnjamesjacoby, masteradhoc, westonruter, nimeshatxecurify, mukesh27, joedolson. Fixes #56694. Built from https://develop.svn.wordpress.org/trunk@62845 git-svn-id: http://core.svn.wordpress.org/trunk@62125 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Trac ticket: https://core.trac.wordpress.org/ticket/56694
Use of AI Tools
AI assistance: Yes
Tool(s): Claude
Model(s): Sonnet 4.6
Used for: Code review and manual test suggestions to test extensively; final implementation were reviewed and fully tested by me.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.