Support from Acquia helps fund testing for Drupal Acquia logo

Comments

InternetDevels’s picture

Status: Active » Needs review
FileSize
1.59 KB

Here is the patch.

andypost’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/statistics/lib/Drupal/statistics/Plugin/Block/StatisticsPopularBlock.php
    @@ -58,7 +58,7 @@ public function settings() {
    +    if (\Drupal::request()->attributes->get('_account')->hasPermission('access content')) {
    

    Suppose blocks should use current_user service via injection

  2. +++ b/core/modules/statistics/statistics.module
    @@ -58,7 +58,8 @@ function statistics_node_view(EntityInterface $node, EntityDisplay $display, $vi
    +    $account = Drupal::request()->attributes->get('_account');
    

    Drupal::currentUser()->hasPermission('view post access counter')

rhm5000’s picture

Status: Needs work » Needs review
FileSize
1.64 KB
1.51 KB

Status: Needs review » Needs work

The last submitted patch, 2062023-statistics-replace-user_access-calls-3.patch, failed testing.

andypost’s picture

+++ b/core/modules/statistics/lib/Drupal/statistics/Plugin/Block/StatisticsPopularBlock.php
@@ -57,7 +57,7 @@ public function settings() {
+    if (Drupal::currentUser()->hasPermission('access content')) {

This needs '\' before Drupal at least

rhm5000’s picture

Status: Needs work » Needs review
FileSize
894 bytes
1.52 KB
andypost’s picture

Status: Needs review » Reviewed & tested by the community

this could go, but I wish a maintainer should decide about the usage of \Drupal here.
Probably better to file new issue to pass $account to block access() method

catch’s picture

Yeah let's open an issue for that if there's not one already.

andypost’s picture

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

Automatically closed -- issue fixed for 2 weeks with no activity.