1 update.php 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.:

File

core/update.php, line 378
Administrative page for handling updates from one Backdrop 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 update process,
  // so we fall back on requiring that the user be logged in as user #1.
  try {
    require_once BACKDROP_ROOT . '/' . backdrop_get_path('module', 'user') . '/user.module';
    return user_access('administer software updates');
  }
  catch (Exception $e) {
    return ($user->uid == 1);
  }
}