Make WordPress Core

Opened 4 months ago

Last modified 13 hours ago

#65758 new defect (bug)

added check for post status in wp_privacy_send_personal_data_export_email()

Reported by: pbearne Owned by:
Priority: normal Milestone: 7.2
Component: General Version:
Severity: normal Keywords: has-patch has-unit-tests
Cc: Focuses: privacy

Description

Change History (13)

This ticket was mentioned in ​PR #12759 on ​WordPress/wordpress-develop by ​@pbearne.


4 months ago
#1

  • Keywords has-patch has-unit-tests added

​@masteradhoc commented on ​PR #12759:


4 months ago
#2

Thanks @pbearne for the PR - we have some Unit Tests failing, could you recheck them?
@mindctrl would you mind testing this PR as well given you've recently reviewed quite some privacy test PRs? :)

#3 @pbearne
4 months ago

I didn't run the test for the whole group

updated tests

please review

​@masteradhoc commented on ​PR #12759:


3 months ago
#4

Would you mind checking again @mindctrl ? Thank you!

#5 @masteradhoc
3 months ago

  • Milestone Awaiting Review → 7.1

#6 @wildworks
3 months ago

  • Milestone 7.1 → 7.2

As the 7.1 RC1 commit freeze is fast approaching, I will punt this to 7.2. ​PR 12759 does not seem ready for release.

This ticket was mentioned in ​PR #13770 on ​WordPress/wordpress-develop by ​@therssoftware.


7 weeks ago
#7

Trac ticket: https://core.trac.wordpress.org/ticket/65758

Description

In wp_privacy_send_personal_data_export_email(), the post status was not previously validated before sending the export email. This could lead to export emails being sent for unconfirmed or invalid requests (e.g. request-pending, request-failed).

Changes

  1. Validates that $request->status is either 'request-confirmed' or 'request-completed'. Otherwise returns a WP_Error with code 'invalid_request' and message 'Invalid request status when sending personal data export email.'.
  2. Updated the function docblock with @since 7.2.0.
  3. Added dedicated unit tests asserting the WP_Error return when request status is invalid (request-pending, request-failed, draft), as well as asserting success when the request status is 'request-completed'.
  4. Fixed a minor fixture bug in existing tests where self::$request_id was confirmed instead of $request_id.
  5. Updated wpPrivacyProcessPersonalDataExportPage fixture setup to ensure the request is confirmed before page processing.

Testing Instructions

  1. Run PHPUnit on the privacy group: npm run test:php -- --group privacy
  2. Verify all 254 tests pass.

---

AI Disclosure

Assisted by generative AI tools to draft unit test cases, run automated checks (PHPUnit and PHPCS), and format docblocks according to WordPress Core standards.

This ticket was mentioned in ​Slack in #core by im3dabasia1. ​View the logs.


3 days ago

#9 @im3dabasia1
3 days ago

As per today's pre-RC1 bug scrub:

the newer ​PR adds the status check and tests. @therssoftware, is it ready for review? A committer look would help before RC1. I have requested a couple of reviewers in the PR, which GitHub suggested.

​@masteradhoc commented on ​PR #13770:


31 hours ago
#10

Closing this in favor of ​https://github.com/WordPress/wordpress-develop/pull/12759 which was opened earlier :)

#11 @masteradhoc
31 hours ago

@pbearne would you mind checking this PR and making sure it up-to-date so it can get checked by a core dev?

​@wildworks commented on ​PR #12759:


14 hours ago
#12

I think all the feedback has now been addressed.

In addition, since wp_privacy_send_personal_data_export_email() now returns a WP_Error when the request is not confirmed or completed, I added a changelog entry to its DocBlock in 8a9618bd71.

As this changes the function's behavior, it might be safer to punt this to 7.3, in which case the @since should be updated to 7.3.0.

​@masteradhoc commented on ​PR #12759:


13 hours ago
#13

Thank you @t-hamano!

I'd feel confident landing this in 7.2 before RC1, so the new string makes the string freeze.

Impact is very low: The check reuses the existing error code, and the tests cover every request status. Looks good to commit IMO.

Note: See TracTickets for help on using tickets.