WordPress.org

Make WordPress Core

Ticket #43880: 43880.2.diff

File 43880.2.diff, 2.0 KB (added by lbenicio, 2 years ago)

added unit tests to path 43880

  • src/wp-includes/functions.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    62306230                        /* translators: deleted long text */
    62316231                        $anonymous = __( 'This content was deleted by the author.' );
    62326232                        break;
     6233        case 'user_id':
     6234            $anonymous = _wp_privacy_get_anonymous_user_id();
     6235                         assertGreaterThanOrEqual(0, $anonymous)
     6236            break;
    62336237                default:
    62346238                        $anonymous = '';
    62356239        }
     
    62536256 * @access private
    62546257 */
    62556258function _wp_privacy_active_plugins_change() {
    6256         update_option( '_wp_privacy_text_change_check', 'check' );
     6259        get_option( '_wp_privacy_text_change_check', 'check' );
     6260}
     6261
     6262/**
     6263 * Adds an anonymous user to the database if none exists, and returns the users ID to anonymize.
     6264 *
     6265 * @since 4.9.6
     6266 *
     6267 * @return int $anonymous_user_id  ID if the anonymous user, or 0 if user could not be created.
     6268 */
     6269function _wp_privacy_get_anonymous_user_id()
     6270{
     6271    $anonymous_user_id = (int) get_option('_anonymous_user_id');
     6272
     6273    if ( ! $anonymous_user_id ) {
     6274        $anonymous_user_id = wp_insert_user(array(
     6275            'user_login' => 'anonymous',
     6276            'user_pass' => NULL,
     6277            'user_nicename' => __('Anonymous'),
     6278            'user_email' => wp_privacy_anonymize_data('email', ''),
     6279            'display_name' => __('Anonymous'),
     6280            'description' => __('Anonymous user used to assign posts to when the user requested deletion though privacy tools.'),
     6281            'role' => 'anonymous_user', // Does not exist. This should prevent the user from logging in or getting into wp_admin by all means.
     6282        ));
     6283
     6284        if (!is_wp_error($anonymous_user_id)) {
     6285            update_option('_anonymous_user_id', (int) $anonymous_user_id);
     6286        }
     6287    }
     6288
     6289    return is_wp_error($anonymous_user_id) ? 0 : $anonymous_user_id;
    62576290}