Make WordPress Core

Changeset 49090


Ignore:
Timestamp:
10/04/2020 03:21:38 AM (4 years ago)
Author:
SergeyBiryukov
Message:

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.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/erase-personal-data.php

    r48468 r49090  
    1111
    1212if ( ! current_user_can( 'erase_others_personal_data' ) || ! current_user_can( 'delete_users' ) ) {
    13     wp_die( __( 'Sorry, you are not allowed to erase data on this site.' ) );
     13    wp_die( __( 'Sorry, you are not allowed to erase personal data on this site.' ) );
    1414}
    1515
  • trunk/src/wp-admin/includes/privacy-tools.php

    r49026 r49090  
    2121
    2222    if ( ! $request || 'user_request' !== $request->post_type ) {
    23         return new WP_Error( 'privacy_request_error', __( 'Invalid request.' ) );
     23        return new WP_Error( 'privacy_request_error', __( 'Invalid user privacy request.' ) );
    2424    }
    2525
     
    2929        return $result;
    3030    } elseif ( ! $result ) {
    31         return new WP_Error( 'privacy_request_error', __( 'Unable to initiate confirmation request.' ) );
     31        return new WP_Error( 'privacy_request_error', __( 'Unable to initiate user privacy confirmation request.' ) );
    3232    }
    3333
     
    5050
    5151    if ( ! $request ) {
    52         return new WP_Error( 'privacy_request_error', __( 'Invalid request.' ) );
     52        return new WP_Error( 'privacy_request_error', __( 'Invalid user privacy request.' ) );
    5353    }
    5454
     
    105105                        'action_type',
    106106                        'action_type',
    107                         __( 'Invalid action.' ),
     107                        __( 'Invalid user privacy action.' ),
    108108                        'error'
    109109                    );
     
    117117                        'action_type',
    118118                        'action_type',
    119                         __( 'Invalid action.' ),
     119                        __( 'Invalid user privacy action.' ),
    120120                        'error'
    121121                    );
     
    298298function wp_privacy_generate_personal_data_export_file( $request_id ) {
    299299    if ( ! class_exists( 'ZipArchive' ) ) {
    300         wp_send_json_error( __( 'Unable to generate export file. ZipArchive not available.' ) );
     300        wp_send_json_error( __( 'Unable to generate user privacy export file. ZipArchive not available.' ) );
    301301    }
    302302
     
    305305
    306306    if ( ! $request || 'export_personal_data' !== $request->action_name ) {
    307         wp_send_json_error( __( 'Invalid request ID when generating export file.' ) );
     307        wp_send_json_error( __( 'Invalid request ID when generating user privacy export file.' ) );
    308308    }
    309309
     
    311311
    312312    if ( ! is_email( $email_address ) ) {
    313         wp_send_json_error( __( 'Invalid email address when generating export file.' ) );
     313        wp_send_json_error( __( 'Invalid email address when generating user privacy export file.' ) );
    314314    }
    315315
     
    319319
    320320    if ( ! wp_mkdir_p( $exports_dir ) ) {
    321         wp_send_json_error( __( 'Unable to create export folder.' ) );
     321        wp_send_json_error( __( 'Unable to create user privacy export folder.' ) );
    322322    }
    323323
     
    327327        $file = fopen( $index_pathname, 'w' );
    328328        if ( false === $file ) {
    329             wp_send_json_error( __( 'Unable to protect export folder from browsing.' ) );
     329            wp_send_json_error( __( 'Unable to protect user privacy export folder from browsing.' ) );
    330330        }
    331331        fwrite( $file, '<!-- Silence is golden. -->' );
     
    396396
    397397    if ( false === $file ) {
    398         wp_send_json_error( __( 'Unable to open export file (JSON report) for writing.' ) );
     398        wp_send_json_error( __( 'Unable to open user privacy export file (JSON report) for writing.' ) );
    399399    }
    400400
     
    411411
    412412    if ( false === $file ) {
    413         wp_send_json_error( __( 'Unable to open export file (HTML report) for writing.' ) );
     413        wp_send_json_error( __( 'Unable to open user privacy export file (HTML report) for writing.' ) );
    414414    }
    415415
     
    505505    if ( true === $zip->open( $archive_pathname, ZipArchive::CREATE ) ) {
    506506        if ( ! $zip->addFile( $json_report_pathname, 'export.json' ) ) {
    507             $error = __( 'Unable to add data to JSON file.' );
     507            $error = __( 'Unable to add data to user privacy export file (JSON format).' );
    508508        }
    509509
    510510        if ( ! $zip->addFile( $html_report_pathname, 'index.html' ) ) {
    511             $error = __( 'Unable to add data to HTML file.' );
     511            $error = __( 'Unable to add data to user privacy export file (HTML format).' );
    512512        }
    513513
     
    530530        }
    531531    } else {
    532         $error = __( 'Unable to open export file (archive) for writing.' );
     532        $error = __( 'Unable to open user privacy export file (archive) for writing.' );
    533533    }
    534534
     
    759759
    760760    if ( ! $request || 'export_personal_data' !== $request->action_name ) {
    761         wp_send_json_error( __( 'Invalid request ID when merging exporter data.' ) );
     761        wp_send_json_error( __( 'Invalid request ID when merging user privacy exporter data.' ) );
    762762    }
    763763
     
    910910
    911911    if ( ! $request || 'remove_personal_data' !== $request->action_name ) {
    912         wp_send_json_error( __( 'Invalid request ID when processing eraser data.' ) );
     912        wp_send_json_error( __( 'Invalid request ID when processing user privacy eraser data.' ) );
    913913    }
    914914
  • trunk/src/wp-admin/options-privacy.php

    r48965 r49090  
    1111
    1212if ( ! current_user_can( 'manage_privacy_options' ) ) {
    13     wp_die( __( 'Sorry, you are not allowed to manage privacy on this site.' ) );
     13    wp_die( __( 'Sorry, you are not allowed to manage privacy options on this site.' ) );
    1414}
    1515
  • trunk/src/wp-admin/privacy-policy-guide.php

    r47198 r49090  
    1111
    1212if ( ! current_user_can( 'manage_privacy_options' ) ) {
    13     wp_die( __( 'Sorry, you are not allowed to manage privacy on this site.' ) );
     13    wp_die( __( 'Sorry, you are not allowed to manage privacy options on this site.' ) );
    1414}
    1515
  • trunk/src/wp-includes/user.php

    r49036 r49090  
    36133613
    36143614    if ( $requests_query->found_posts ) {
    3615         return new WP_Error( 'duplicate_request', __( 'An incomplete request for this email address already exists.' ) );
     3615        return new WP_Error( 'duplicate_request', __( 'An incomplete user privacy request for this email address already exists.' ) );
    36163616    }
    36173617
     
    36813681
    36823682    if ( ! $request ) {
    3683         return new WP_Error( 'invalid_request', __( 'Invalid user request.' ) );
     3683        return new WP_Error( 'invalid_request', __( 'Invalid user privacy request.' ) );
    36843684    }
    36853685
     
    38633863    global $wp_hasher;
    38643864
    3865     $request_id = absint( $request_id );
    3866     $request    = wp_get_user_request( $request_id );
    3867 
    3868     if ( ! $request ) {
    3869         return new WP_Error( 'invalid_request', __( 'Invalid request.' ) );
     3865    $request_id       = absint( $request_id );
     3866    $request          = wp_get_user_request( $request_id );
     3867    $saved_key        = $request->confirm_key;
     3868    $key_request_time = $request->modified_timestamp;
     3869
     3870    if ( ! $request || ! $saved_key || ! $key_request_time ) {
     3871        return new WP_Error( 'invalid_request', __( 'Invalid user privacy request.' ) );
    38703872    }
    38713873
    38723874    if ( ! in_array( $request->status, array( 'request-pending', 'request-failed' ), true ) ) {
    3873         return new WP_Error( 'expired_link', __( 'This link has expired.' ) );
     3875        return new WP_Error( 'expired_request', __( 'This user privacy request has expired.' ) );
    38743876    }
    38753877
    38763878    if ( empty( $key ) ) {
    3877         return new WP_Error( 'missing_key', __( 'Missing confirm key.' ) );
     3879        return new WP_Error( 'missing_key', __( 'This user privacy request is missing the confirmation key.' ) );
    38783880    }
    38793881
     
    38833885    }
    38843886
    3885     $key_request_time = $request->modified_timestamp;
    3886     $saved_key        = $request->confirm_key;
    3887 
    3888     if ( ! $saved_key ) {
    3889         return new WP_Error( 'invalid_key', __( 'Invalid key.' ) );
    3890     }
    3891 
    3892     if ( ! $key_request_time ) {
    3893         return new WP_Error( 'invalid_key', __( 'Invalid action.' ) );
    3894     }
    3895 
    38963887    /**
    38973888     * Filters the expiration time of confirm keys.
     
    39053896
    39063897    if ( ! $wp_hasher->CheckPassword( $key, $saved_key ) ) {
    3907         return new WP_Error( 'invalid_key', __( 'Invalid key.' ) );
     3898        return new WP_Error( 'invalid_key', __( 'This user privacy request confirmation key is invalid.' ) );
    39083899    }
    39093900
    39103901    if ( ! $expiration_time || time() > $expiration_time ) {
    3911         return new WP_Error( 'expired_key', __( 'The confirmation email has expired.' ) );
     3902        return new WP_Error( 'expired_key', __( 'This user privacy request confirmation key has expired.' ) );
    39123903    }
    39133904
  • trunk/tests/phpunit/tests/privacy/wpPrivacyGeneratePersonalDataExportFile.php

    r48996 r49090  
    165165
    166166        $this->expectException( 'WPDieException' );
    167         $this->expectOutputString( '{"success":false,"data":"Invalid request ID when generating export file."}' );
     167        $this->expectOutputString( '{"success":false,"data":"Invalid request ID when generating user privacy export file."}' );
    168168        wp_privacy_generate_personal_data_export_file( $request_id );
    169169    }
     
    176176    public function test_invalid_request_id() {
    177177        $this->expectException( 'WPDieException' );
    178         $this->expectOutputString( '{"success":false,"data":"Invalid request ID when generating export file."}' );
     178        $this->expectOutputString( '{"success":false,"data":"Invalid request ID when generating user privacy export file."}' );
    179179        wp_privacy_generate_personal_data_export_file( 123456789 );
    180180    }
     
    196196
    197197        $this->expectException( 'WPDieException' );
    198         $this->expectOutputString( '{"success":false,"data":"Invalid email address when generating export file."}' );
     198        $this->expectOutputString( '{"success":false,"data":"Invalid email address when generating user privacy export file."}' );
    199199        wp_privacy_generate_personal_data_export_file( $request_id );
    200200    }
     
    210210
    211211        $this->expectException( 'WPDieException' );
    212         $this->expectOutputString( '{"success":false,"data":"Unable to create export folder."}' );
     212        $this->expectOutputString( '{"success":false,"data":"Unable to create user privacy export folder."}' );
    213213        wp_privacy_generate_personal_data_export_file( self::$export_request_id );
    214214    }
  • trunk/tests/phpunit/tests/privacy/wpPrivacyProcessPersonalDataExportPage.php

    r48996 r49090  
    368368
    369369        // Process data, given the last exporter, on the last page and send as email.
    370         $this->_setup_expected_failure( '{"success":false,"data":"Invalid request ID when merging exporter data."}' );
     370        $this->_setup_expected_failure( '{"success":false,"data":"Invalid request ID when merging user privacy exporter data."}' );
    371371
    372372        wp_privacy_process_personal_data_export_page(
     
    400400
    401401        // Process data, given the last exporter, on the last page and send as email.
    402         $this->_setup_expected_failure( '{"success":false,"data":"Invalid request ID when merging exporter data."}' );
     402        $this->_setup_expected_failure( '{"success":false,"data":"Invalid request ID when merging user privacy exporter data."}' );
    403403
    404404        wp_privacy_process_personal_data_export_page(
Note: See TracChangeset for help on using the changeset viewer.