function user_requirements
Same name in other branches
- 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 [];
}
$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,
];
}
$query = \Drupal::database()->select('users_field_data');
$query->addExpression('LOWER(mail)', 'lower_mail');
$query->groupBy('lower_mail');
$query->having('COUNT(uid) > :matches', [
':matches' => 1,
]);
$conflicts = $query->countQuery()
->execute()
->fetchField();
if ($conflicts > 0) {
$return['conflicting emails'] = [
'title' => t('Conflicting user emails'),
'description' => t('Some user accounts have email addresses that differ only by case. For example, one account might have alice@example.com and another might have Alice@Example.com. See <a href=":url">Conflicting User Emails</a> for more information.', [
':url' => 'https://www.drupal.org/node/3486109',
]),
'severity' => REQUIREMENT_WARNING,
];
}
return $return;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.