function update_access_allowed

Determines if the current user is allowed to run update.php.

Return value

TRUE if the current user should be granted access, or FALSE otherwise.

1 call to update_access_allowed()
update.php in drupal/core/update.php
Administrative page for handling updates from one Drupal version to another.

File

drupal/core/update.php, line 338
Administrative page for handling updates from one Drupal version to another.

Code

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;
  }
}