Add wp user privacy-request commands for GDPR personal data management#611
Add wp user privacy-request commands for GDPR personal data management#611
wp user privacy-request commands for GDPR personal data management#611Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Agent-Logs-Url: https://github.com/wp-cli/entity-command/sessions/945cce56-1ac8-48a6-adc2-32f7ea452224 Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
…in export and erase commands Agent-Logs-Url: https://github.com/wp-cli/entity-command/sessions/945cce56-1ac8-48a6-adc2-32f7ea452224 Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
wp user privacy-request commands for GDPR personal data management
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Agent-Logs-Url: https://github.com/wp-cli/entity-command/sessions/b837075e-3a1d-486d-8781-8d174feb9cfa Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Agent-Logs-Url: https://github.com/wp-cli/entity-command/sessions/23bdadcf-1412-48b9-a8b9-e2c3a8c6adb7 Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
…xport_file_name) Agent-Logs-Url: https://github.com/wp-cli/entity-command/sessions/76bb4546-13cf-4c5e-90d1-e8679fd9b477 Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| $request_id = wp_create_user_request( $email_address, $action_name, [], $status ); | ||
|
|
||
| if ( is_wp_error( $request_id ) ) { | ||
| WP_CLI::error( $request_id ); | ||
| } | ||
|
|
||
| // The $status parameter for wp_create_user_request() was added in WP 5.7.0. | ||
| // For older versions, manually update the post status when 'confirmed' was requested. | ||
| if ( 'confirmed' === $status ) { | ||
| wp_update_post( | ||
| [ |
There was a problem hiding this comment.
The inline comment says the $status parameter for wp_create_user_request() was added in WP 5.7.0, but the call always passes $status as the 4th argument. If that comment is correct, this will be an incompatible call on WP < 5.7. Consider branching on Utils\wp_version_compare( '5.7', '<' ) (or function_exists/reflection) to call the 3-arg signature on older versions, and only pass $status when supported; alternatively, update/remove the comment if the 4th parameter is actually supported on all targeted versions.
| $result = wp_delete_post( $request_id, true ); | ||
|
|
||
| if ( ! $result ) { |
There was a problem hiding this comment.
The PR description mentions using wp_delete_user_request() (with a scoped @phpstan-ignore) for deleting privacy requests, but the implementation deletes the underlying post via wp_delete_post(). Either update the implementation to use wp_delete_user_request() (to match the stated intent and any extra cleanup it performs) or update the PR description accordingly.
WordPress 4.9.6 introduced personal data export and erasure tools (GDPR), but no WP-CLI interface existed for them. This adds a
wp user privacy-requestcommand group covering the full lifecycle ofuser_requestposts.New commands
list— Query all requests; filterable by--action-typeand--status, supports all standard output formats (table,csv,json,ids,count,yaml)create <email> <action-type>— Create aexport_personal_dataorremove_personal_datarequest;--status=pending|confirmed,--send-email,--porcelaindelete <request-id>...— Delete one or more requests; batch-reports success/failure countserase <request-id>— Invoke all registeredwp_privacy_personal_data_erasersfor the request's email, then mark itrequest-completedexport <request-id>— Invoke all registeredwp_privacy_personal_data_exporters, generate the ZIP viawp_privacy_generate_personal_data_export_file(), mark complete, and output the file pathcomplete <request-id>...— Mark one or more requests asrequest-completed; batch-reports success/failure countsImplementation notes
eraseandexportiterate over all registered erasers/exporters page-by-page (matching the admin AJAX flow) before marking the request completeexporterrors explicitly ifwp_privacy_generate_personal_data_export_file()produces no file pathwp_delete_user_request()exists since WP 4.9.6 but is absent from thephp-stubs/wordpress-stubslibrary; suppressed with a scoped@phpstan-ignorephpcs.xml.distupdated to includeUser_Privacy_Request_Commandin the existing NamingConventions class-prefix exclusion pattern (consistent with all other command classes)