diff --git a/core/modules/comment/lib/Drupal/comment/CommentAccessController.php b/core/modules/comment/lib/Drupal/comment/CommentAccessController.php index 4c95dc8..b783fb3 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentAccessController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentAccessController.php @@ -24,16 +24,16 @@ class CommentAccessController extends EntityAccessController { protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { switch ($operation) { case 'view': - return $account->hasPermission('access comments', $account); + return $account->hasPermission('access comments'); case 'update': - return ($account->id() && $account->id() == $entity->uid->value && $entity->status->value == CommentInterface::PUBLISHED && $account->hasPermission('edit own comments', $account)) || $account->hasPermission('administer comments', $account); + return ($account->id() && $account->id() == $entity->uid->value && $entity->status->value == CommentInterface::PUBLISHED && $account->hasPermission('edit own comments')) || $account->hasPermission('administer comments'); case 'delete': - return $account->hasPermission('administer comments', $account); + return $account->hasPermission('administer comments'); case 'approve': - return $account->hasPermission('administer comments', $account); + return $account->hasPermission('administer comments'); } } @@ -41,7 +41,7 @@ protected function checkAccess(EntityInterface $entity, $operation, $langcode, A * {@inheritdoc} */ protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) { - return $account->hasPermission('post comments', $account); + return $account->hasPermission('post comments'); } } diff --git a/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php b/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php index 82ec590..4643aeb 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php @@ -62,8 +62,8 @@ public function getTranslationAccess(EntityInterface $entity, $op) { $account = \Drupal::currentUser(); // If no permission granularity is defined this entity type does not need an // explicit translate permission. - if (!$account->hasPermission('translate any entity') && !empty($info['permission_granularity'])) { - $translate_permission = $account->hasPermission($info['permission_granularity'] == 'bundle' ? "translate {$entity->bundle()} {$entity->entityType()}" : "translate {$entity->entityType()}"); + if (!$account->hasPermission('translate any entity') && $permission_granularity = $info->getPermissionGranularity()) { + $translate_permission = $account->hasPermission($permission_granularity == 'bundle' ? "translate {$entity->bundle()} {$entity->entityType()}" : "translate {$entity->entityType()}"); } return $translate_permission && $account->hasPermission("$op content translations"); } diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index e3c49d6..c02e693 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -772,7 +772,7 @@ function filter_process_format($element) { $all_formats = filter_formats(); $format_exists = isset($all_formats[$element['#format']]); $user_has_access = isset($formats[$element['#format']]); - $user_is_admin = Drupal::currentUser()->hasPermission('administer filters'); + $user_is_admin = \Drupal::currentUser()->hasPermission('administer filters'); // If the stored format does not exist, administrators have to assign a new // format. diff --git a/core/modules/views/views.api.php b/core/modules/views/views.api.php index 2e6c769..ab7a354 100644 --- a/core/modules/views/views.api.php +++ b/core/modules/views/views.api.php @@ -377,7 +377,7 @@ function hook_views_form_substitutions() { function hook_views_pre_view(ViewExecutable $view, $display_id, array &$args) { // Modify contextual filters for my_special_view if user has 'my special permission'. - $account = Drupal::currentUser(); + $account = \Drupal::currentUser(); if ($view->name == 'my_special_view' && $account->hasPermission('my special permission') && $display_id == 'public_display') { $args[0] = 'custom value'; @@ -446,7 +446,7 @@ function hook_views_pre_execute(ViewExecutable $view) { // view administrators that the query might be heavy. // (This action could be performed later in the execution process, but not // earlier.) - $account = Drupal::currentUser(); + $account = \Drupal::currentUser(); if (count($view->query->tables) > 2 && $account->hasPermission('administer views')) { drupal_set_message(t('The view %view may be heavy to execute.', array('%view' => $view->name)), 'warning'); diff --git a/core/modules/views/views.module b/core/modules/views/views.module index 7128a53..baafd14 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -332,8 +332,7 @@ function views_page_alter(&$page) { */ function views_preprocess_page(&$variables) { // Early-return to prevent adding unnecessary JavaScript. - $account = Drupal::currentUser(); - if (!$account || !$account->hasPermission('access contextual links')) { + if (\Drupal::currentUser()->hasPermission('access contextual links')) { return; } diff --git a/core/update.php b/core/update.php index ac2a1e2..075bfdb 100644 --- a/core/update.php +++ b/core/update.php @@ -70,7 +70,7 @@ function update_helpful_links() { 'title' => t('Front page'), 'href' => '', ); - if (Drupal::currentUser()->hasPermission('access administration pages')) { + if (user_access('access administration pages')) { $links['admin-pages'] = array( 'title' => t('Administration pages'), 'href' => 'admin',