function user_requirements

Same name in other branches
  1. 11.x core/modules/user/user.install \user_requirements()

Implements hook_requirements().

File

core/modules/user/user.install, line 99

Code

function user_requirements($phase) : array {
    if ($phase !== 'runtime') {
        return [];
    }
    $result = (bool) \Drupal::entityQuery('user')->accessCheck(FALSE)
        ->condition('uid', 0)
        ->range(0, 1)
        ->execute();
    if ($result === FALSE) {
        return [
            'anonymous user' => [
                'title' => t('Anonymous user'),
                'description' => t('The anonymous user does not exist. See the <a href=":url">restore the anonymous (user ID 0) user record</a> for more information', [
                    ':url' => 'https://www.drupal.org/node/1029506',
                ]),
                'severity' => REQUIREMENT_WARNING,
            ],
        ];
    }
    return [];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.