Commit 7d0c5795 authored by alexpott's avatar alexpott

Issue #2062043 by eelkeblok, longwave, rhm50, InternetDevels, alvar0hurtad0,...

Issue #2062043 by eelkeblok, longwave, rhm50, InternetDevels, alvar0hurtad0, Xano: Replace user_access() calls with $account->hasPermission() in core files.
parent 29d0f436
......@@ -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();
......
......@@ -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
......
......@@ -69,7 +69,7 @@ function update_helpful_links() {
'title' => t('Front page'),
'href' => '<front>',
);
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 <a href="' . base_path() . '?q=admin/reports/dblog">logged</a>.';
}
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');
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment