diff --git a/core/authorize.php b/core/authorize.php index 5418007a76ff41bf4f17ae4fc5bdf11185b111c2..3a340462ed0740dda26648b68a3cb7909671d1a3 100644 --- a/core/authorize.php +++ b/core/authorize.php @@ -50,7 +50,7 @@ */ function authorize_access_allowed() { \Drupal::service('session_manager')->startLazy(); - return Settings::get('allow_authorize_operations', TRUE) && user_access('administer software updates'); + return Settings::get('allow_authorize_operations', TRUE) && \Drupal::currentUser()->hasPermission('administer software updates'); } $request = Request::createFromGlobals(); diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index aa92f9ce52cbd2792c3fad4b54700bba74867ede..145a67195a5121851355f2e9574ae1f3e2074af7 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -1536,13 +1536,13 @@ function drupal_classloader_register($name, $path) { * * Example: * @code - * function user_access($string, $account = NULL) { + * function example_default_format_type() { * // Use the advanced drupal_static() pattern, since this is called very often. * static $drupal_static_fast; * if (!isset($drupal_static_fast)) { - * $drupal_static_fast['perm'] = &drupal_static(__FUNCTION__); + * $drupal_static_fast['format_type'] = &drupal_static(__FUNCTION__); * } - * $perm = &$drupal_static_fast['perm']; + * $format_type = &$drupal_static_fast['format_type']; * ... * } * @endcode diff --git a/core/update.php b/core/update.php index 147168144aa50eb95c988244ec3ee540dec3c9ab..4e8157c46b8e5935cffaeb08cad7c00ad1f4ef19 100644 --- a/core/update.php +++ b/core/update.php @@ -69,7 +69,7 @@ function update_helpful_links() { 'title' => t('Front page'), 'href' => '', ); - if (user_access('access administration pages')) { + if (\Drupal::currentUser()->hasPermission('access administration pages')) { $links['admin-pages'] = array( 'title' => t('Administration pages'), 'href' => 'admin', @@ -97,7 +97,7 @@ function update_flush_all_caches() { */ function update_results_page() { // Report end result. - if (\Drupal::moduleHandler()->moduleExists('dblog') && user_access('access site reports')) { + if (\Drupal::moduleHandler()->moduleExists('dblog') && \Drupal::currentUser()->hasPermission('access site reports')) { $log_message = ' All errors have been logged.'; } else { @@ -249,25 +249,7 @@ function update_access_denied_page() { * TRUE if the current user should be granted access, or FALSE otherwise. */ function update_access_allowed() { - $user = \Drupal::currentUser(); - - // 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_handler->addModule('user', 'core/modules/user'); - $module_handler->reload(); - $module_filenames = $module_handler->getModuleList(); - \Drupal::service('kernel')->updateModules($module_filenames, $module_filenames); - return user_access('administer software updates'); - } - catch (\Exception $e) { - return ($user->id() == 1); - } + return Settings::get('update_free_access') || \Drupal::currentUser()->hasPermission('administer software updates'); } /**