mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 17:18:32 +01:00
Privacy: Improve clarity of privacy error strings.
Primarily this adds "user privacy" to the strings for privacy requests, so they are more easily distinguished from other system actions within logs. Props garrett-eclipse, carike, birgire. Fixes #51351. Built from https://develop.svn.wordpress.org/trunk@49090 git-svn-id: http://core.svn.wordpress.org/trunk@48852 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0f13b2c268
commit
1651342d2b
@ -10,7 +10,7 @@
|
||||
require_once __DIR__ . '/admin.php';
|
||||
|
||||
if ( ! current_user_can( 'erase_others_personal_data' ) || ! current_user_can( 'delete_users' ) ) {
|
||||
wp_die( __( 'Sorry, you are not allowed to erase data on this site.' ) );
|
||||
wp_die( __( 'Sorry, you are not allowed to erase personal data on this site.' ) );
|
||||
}
|
||||
|
||||
// Handle list table actions.
|
||||
|
@ -20,7 +20,7 @@ function _wp_privacy_resend_request( $request_id ) {
|
||||
$request = get_post( $request_id );
|
||||
|
||||
if ( ! $request || 'user_request' !== $request->post_type ) {
|
||||
return new WP_Error( 'privacy_request_error', __( 'Invalid request.' ) );
|
||||
return new WP_Error( 'privacy_request_error', __( 'Invalid user privacy request.' ) );
|
||||
}
|
||||
|
||||
$result = wp_send_user_request( $request_id );
|
||||
@ -28,7 +28,7 @@ function _wp_privacy_resend_request( $request_id ) {
|
||||
if ( is_wp_error( $result ) ) {
|
||||
return $result;
|
||||
} elseif ( ! $result ) {
|
||||
return new WP_Error( 'privacy_request_error', __( 'Unable to initiate confirmation request.' ) );
|
||||
return new WP_Error( 'privacy_request_error', __( 'Unable to initiate user privacy confirmation request.' ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -49,7 +49,7 @@ function _wp_privacy_completed_request( $request_id ) {
|
||||
$request = wp_get_user_request( $request_id );
|
||||
|
||||
if ( ! $request ) {
|
||||
return new WP_Error( 'privacy_request_error', __( 'Invalid request.' ) );
|
||||
return new WP_Error( 'privacy_request_error', __( 'Invalid user privacy request.' ) );
|
||||
}
|
||||
|
||||
update_post_meta( $request_id, '_wp_user_request_completed_timestamp', time() );
|
||||
@ -104,7 +104,7 @@ function _wp_personal_data_handle_actions() {
|
||||
add_settings_error(
|
||||
'action_type',
|
||||
'action_type',
|
||||
__( 'Invalid action.' ),
|
||||
__( 'Invalid user privacy action.' ),
|
||||
'error'
|
||||
);
|
||||
}
|
||||
@ -116,7 +116,7 @@ function _wp_personal_data_handle_actions() {
|
||||
add_settings_error(
|
||||
'action_type',
|
||||
'action_type',
|
||||
__( 'Invalid action.' ),
|
||||
__( 'Invalid user privacy action.' ),
|
||||
'error'
|
||||
);
|
||||
}
|
||||
@ -297,20 +297,20 @@ function wp_privacy_generate_personal_data_export_group_html( $group_data, $grou
|
||||
*/
|
||||
function wp_privacy_generate_personal_data_export_file( $request_id ) {
|
||||
if ( ! class_exists( 'ZipArchive' ) ) {
|
||||
wp_send_json_error( __( 'Unable to generate export file. ZipArchive not available.' ) );
|
||||
wp_send_json_error( __( 'Unable to generate user privacy export file. ZipArchive not available.' ) );
|
||||
}
|
||||
|
||||
// Get the request.
|
||||
$request = wp_get_user_request( $request_id );
|
||||
|
||||
if ( ! $request || 'export_personal_data' !== $request->action_name ) {
|
||||
wp_send_json_error( __( 'Invalid request ID when generating export file.' ) );
|
||||
wp_send_json_error( __( 'Invalid request ID when generating user privacy export file.' ) );
|
||||
}
|
||||
|
||||
$email_address = $request->email;
|
||||
|
||||
if ( ! is_email( $email_address ) ) {
|
||||
wp_send_json_error( __( 'Invalid email address when generating export file.' ) );
|
||||
wp_send_json_error( __( 'Invalid email address when generating user privacy export file.' ) );
|
||||
}
|
||||
|
||||
// Create the exports folder if needed.
|
||||
@ -318,7 +318,7 @@ function wp_privacy_generate_personal_data_export_file( $request_id ) {
|
||||
$exports_url = wp_privacy_exports_url();
|
||||
|
||||
if ( ! wp_mkdir_p( $exports_dir ) ) {
|
||||
wp_send_json_error( __( 'Unable to create export folder.' ) );
|
||||
wp_send_json_error( __( 'Unable to create user privacy export folder.' ) );
|
||||
}
|
||||
|
||||
// Protect export folder from browsing.
|
||||
@ -326,7 +326,7 @@ function wp_privacy_generate_personal_data_export_file( $request_id ) {
|
||||
if ( ! file_exists( $index_pathname ) ) {
|
||||
$file = fopen( $index_pathname, 'w' );
|
||||
if ( false === $file ) {
|
||||
wp_send_json_error( __( 'Unable to protect export folder from browsing.' ) );
|
||||
wp_send_json_error( __( 'Unable to protect user privacy export folder from browsing.' ) );
|
||||
}
|
||||
fwrite( $file, '<!-- Silence is golden. -->' );
|
||||
fclose( $file );
|
||||
@ -395,7 +395,7 @@ function wp_privacy_generate_personal_data_export_file( $request_id ) {
|
||||
$file = fopen( $json_report_pathname, 'w' );
|
||||
|
||||
if ( false === $file ) {
|
||||
wp_send_json_error( __( 'Unable to open export file (JSON report) for writing.' ) );
|
||||
wp_send_json_error( __( 'Unable to open user privacy export file (JSON report) for writing.' ) );
|
||||
}
|
||||
|
||||
fwrite( $file, '{' );
|
||||
@ -410,7 +410,7 @@ function wp_privacy_generate_personal_data_export_file( $request_id ) {
|
||||
$file = fopen( $html_report_pathname, 'w' );
|
||||
|
||||
if ( false === $file ) {
|
||||
wp_send_json_error( __( 'Unable to open export file (HTML report) for writing.' ) );
|
||||
wp_send_json_error( __( 'Unable to open user privacy export file (HTML report) for writing.' ) );
|
||||
}
|
||||
|
||||
fwrite( $file, "<!DOCTYPE html>\n" );
|
||||
@ -504,11 +504,11 @@ function wp_privacy_generate_personal_data_export_file( $request_id ) {
|
||||
$zip = new ZipArchive;
|
||||
if ( true === $zip->open( $archive_pathname, ZipArchive::CREATE ) ) {
|
||||
if ( ! $zip->addFile( $json_report_pathname, 'export.json' ) ) {
|
||||
$error = __( 'Unable to add data to JSON file.' );
|
||||
$error = __( 'Unable to add data to user privacy export file (JSON format).' );
|
||||
}
|
||||
|
||||
if ( ! $zip->addFile( $html_report_pathname, 'index.html' ) ) {
|
||||
$error = __( 'Unable to add data to HTML file.' );
|
||||
$error = __( 'Unable to add data to user privacy export file (HTML format).' );
|
||||
}
|
||||
|
||||
$zip->close();
|
||||
@ -529,7 +529,7 @@ function wp_privacy_generate_personal_data_export_file( $request_id ) {
|
||||
do_action( 'wp_privacy_personal_data_export_file_created', $archive_pathname, $archive_url, $html_report_pathname, $request_id, $json_report_pathname );
|
||||
}
|
||||
} else {
|
||||
$error = __( 'Unable to open export file (archive) for writing.' );
|
||||
$error = __( 'Unable to open user privacy export file (archive) for writing.' );
|
||||
}
|
||||
|
||||
// Remove the JSON file.
|
||||
@ -758,7 +758,7 @@ function wp_privacy_process_personal_data_export_page( $response, $exporter_inde
|
||||
$request = wp_get_user_request( $request_id );
|
||||
|
||||
if ( ! $request || 'export_personal_data' !== $request->action_name ) {
|
||||
wp_send_json_error( __( 'Invalid request ID when merging exporter data.' ) );
|
||||
wp_send_json_error( __( 'Invalid request ID when merging user privacy exporter data.' ) );
|
||||
}
|
||||
|
||||
$export_data = array();
|
||||
@ -909,7 +909,7 @@ function wp_privacy_process_personal_data_erasure_page( $response, $eraser_index
|
||||
$request = wp_get_user_request( $request_id );
|
||||
|
||||
if ( ! $request || 'remove_personal_data' !== $request->action_name ) {
|
||||
wp_send_json_error( __( 'Invalid request ID when processing eraser data.' ) );
|
||||
wp_send_json_error( __( 'Invalid request ID when processing user privacy eraser data.' ) );
|
||||
}
|
||||
|
||||
/** This filter is documented in wp-admin/includes/ajax-actions.php */
|
||||
|
@ -10,7 +10,7 @@
|
||||
require_once __DIR__ . '/admin.php';
|
||||
|
||||
if ( ! current_user_can( 'manage_privacy_options' ) ) {
|
||||
wp_die( __( 'Sorry, you are not allowed to manage privacy on this site.' ) );
|
||||
wp_die( __( 'Sorry, you are not allowed to manage privacy options on this site.' ) );
|
||||
}
|
||||
|
||||
$action = isset( $_POST['action'] ) ? $_POST['action'] : '';
|
||||
|
@ -10,7 +10,7 @@
|
||||
require_once __DIR__ . '/admin.php';
|
||||
|
||||
if ( ! current_user_can( 'manage_privacy_options' ) ) {
|
||||
wp_die( __( 'Sorry, you are not allowed to manage privacy on this site.' ) );
|
||||
wp_die( __( 'Sorry, you are not allowed to manage privacy options on this site.' ) );
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'WP_Privacy_Policy_Content' ) ) {
|
||||
|
@ -3612,7 +3612,7 @@ function wp_create_user_request( $email_address = '', $action_name = '', $reques
|
||||
);
|
||||
|
||||
if ( $requests_query->found_posts ) {
|
||||
return new WP_Error( 'duplicate_request', __( 'An incomplete request for this email address already exists.' ) );
|
||||
return new WP_Error( 'duplicate_request', __( 'An incomplete user privacy request for this email address already exists.' ) );
|
||||
}
|
||||
|
||||
$request_id = wp_insert_post(
|
||||
@ -3680,7 +3680,7 @@ function wp_send_user_request( $request_id ) {
|
||||
$request = wp_get_user_request( $request_id );
|
||||
|
||||
if ( ! $request ) {
|
||||
return new WP_Error( 'invalid_request', __( 'Invalid user request.' ) );
|
||||
return new WP_Error( 'invalid_request', __( 'Invalid user privacy request.' ) );
|
||||
}
|
||||
|
||||
// Localize message content for user; fallback to site default for visitors.
|
||||
@ -3862,19 +3862,21 @@ function wp_generate_user_request_key( $request_id ) {
|
||||
function wp_validate_user_request_key( $request_id, $key ) {
|
||||
global $wp_hasher;
|
||||
|
||||
$request_id = absint( $request_id );
|
||||
$request = wp_get_user_request( $request_id );
|
||||
$request_id = absint( $request_id );
|
||||
$request = wp_get_user_request( $request_id );
|
||||
$saved_key = $request->confirm_key;
|
||||
$key_request_time = $request->modified_timestamp;
|
||||
|
||||
if ( ! $request ) {
|
||||
return new WP_Error( 'invalid_request', __( 'Invalid request.' ) );
|
||||
if ( ! $request || ! $saved_key || ! $key_request_time ) {
|
||||
return new WP_Error( 'invalid_request', __( 'Invalid user privacy request.' ) );
|
||||
}
|
||||
|
||||
if ( ! in_array( $request->status, array( 'request-pending', 'request-failed' ), true ) ) {
|
||||
return new WP_Error( 'expired_link', __( 'This link has expired.' ) );
|
||||
return new WP_Error( 'expired_request', __( 'This user privacy request has expired.' ) );
|
||||
}
|
||||
|
||||
if ( empty( $key ) ) {
|
||||
return new WP_Error( 'missing_key', __( 'Missing confirm key.' ) );
|
||||
return new WP_Error( 'missing_key', __( 'This user privacy request is missing the confirmation key.' ) );
|
||||
}
|
||||
|
||||
if ( empty( $wp_hasher ) ) {
|
||||
@ -3882,17 +3884,6 @@ function wp_validate_user_request_key( $request_id, $key ) {
|
||||
$wp_hasher = new PasswordHash( 8, true );
|
||||
}
|
||||
|
||||
$key_request_time = $request->modified_timestamp;
|
||||
$saved_key = $request->confirm_key;
|
||||
|
||||
if ( ! $saved_key ) {
|
||||
return new WP_Error( 'invalid_key', __( 'Invalid key.' ) );
|
||||
}
|
||||
|
||||
if ( ! $key_request_time ) {
|
||||
return new WP_Error( 'invalid_key', __( 'Invalid action.' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the expiration time of confirm keys.
|
||||
*
|
||||
@ -3904,11 +3895,11 @@ function wp_validate_user_request_key( $request_id, $key ) {
|
||||
$expiration_time = $key_request_time + $expiration_duration;
|
||||
|
||||
if ( ! $wp_hasher->CheckPassword( $key, $saved_key ) ) {
|
||||
return new WP_Error( 'invalid_key', __( 'Invalid key.' ) );
|
||||
return new WP_Error( 'invalid_key', __( 'This user privacy request confirmation key is invalid.' ) );
|
||||
}
|
||||
|
||||
if ( ! $expiration_time || time() > $expiration_time ) {
|
||||
return new WP_Error( 'expired_key', __( 'The confirmation email has expired.' ) );
|
||||
return new WP_Error( 'expired_key', __( 'This user privacy request confirmation key has expired.' ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.6-alpha-49089';
|
||||
$wp_version = '5.6-alpha-49090';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user