summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2014-07-20 10:28:21 (GMT)
committerAlex Pott2014-07-20 10:28:21 (GMT)
commit7d0c5795a6744dc4520f83692b84ed3972194411 (patch)
treec656a109866ae92a2b39ddf7c895dd87da7f57e2
parent29d0f4361d53cbf72c7b60e2370f2bbdf250e18c (diff)
Issue #2062043 by eelkeblok, longwave, rhm50, InternetDevels, alvar0hurtad0, Xano: Replace user_access() calls with $account->hasPermission() in core files.
-rw-r--r--core/authorize.php2
-rw-r--r--core/includes/bootstrap.inc6
-rw-r--r--core/update.php24
3 files changed, 7 insertions, 25 deletions
diff --git a/core/authorize.php b/core/authorize.php
index 5418007..3a34046 100644
--- a/core/authorize.php
+++ b/core/authorize.php
@@ -50,7 +50,7 @@ const MAINTENANCE_MODE = 'update';
*/
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 aa92f9c..145a671 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 1471681..4e8157c 100644
--- a/core/update.php
+++ b/core/update.php
@@ -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');
}
/**