Determines if the current user is allowed to run update.php.
TRUE if the current user should be granted access, or FALSE otherwise.
function update_access_allowed() {
global $user;
// Allow the global variable in settings.php to override the access check.
if (settings()
->get('update_free_access')) {
return TRUE;
}
// Calls to user_access() might fail during the Drupal 6 to 7 update process,
// so we fall back on requiring that the user be logged in as user #1.
try {
$module_handler = Drupal::moduleHandler();
$module_filenames = $module_handler
->getModuleList();
$module_filenames['user'] = 'core/modules/user/user.module';
$module_handler
->setModuleList($module_filenames);
$module_handler
->reload();
drupal_container()
->get('kernel')
->updateModules($module_filenames, $module_filenames);
return user_access('administer software updates');
} catch (\Exception $e) {
return $user->uid == 1;
}
}