diff --git a/core/modules/statistics/src/Plugin/Block/StatisticsPopularBlock.php b/core/modules/statistics/src/Plugin/Block/StatisticsPopularBlock.php index 0fc0813..a8746d6 100644 --- a/core/modules/statistics/src/Plugin/Block/StatisticsPopularBlock.php +++ b/core/modules/statistics/src/Plugin/Block/StatisticsPopularBlock.php @@ -84,7 +84,7 @@ public static function create(ContainerInterface $container, array $configuratio $plugin_definition, $container->get('entity_type.manager'), $container->get('entity.repository'), - $container->get('statistics.storage'), + $container->get('statistics.storage.node'), $container->get('renderer') ); } diff --git a/core/modules/statistics/statistics.module b/core/modules/statistics/statistics.module index 2a5a7d2..5419645 100644 --- a/core/modules/statistics/statistics.module +++ b/core/modules/statistics/statistics.module @@ -52,7 +52,7 @@ function statistics_node_links_alter(array &$links, NodeInterface $entity, array if ($context['view_mode'] != 'rss') { $links['#cache']['contexts'][] = 'user.permissions'; if (\Drupal::currentUser()->hasPermission('view post access counter')) { - $statistics = \Drupal::service('statistics.storage')->fetchView($entity->id()); + $statistics = \Drupal::service('statistics.storage.node')->fetchView($entity->id()); if ($statistics) { $statistics_links['statistics_counter']['title'] = \Drupal::translation()->formatPlural($statistics->getTotalCount(), '1 view', '@count views'); $links['statistics'] = array( @@ -70,7 +70,7 @@ function statistics_node_links_alter(array &$links, NodeInterface $entity, array * Implements hook_cron(). */ function statistics_cron() { - $storage = \Drupal::service('statistics.storage'); + $storage = \Drupal::service('statistics.storage.node'); $storage->resetDayCount(); $max_total_count = $storage->maxTotalCount(); \Drupal::state()->set('statistics.node_counter_scale', 1.0 / max(1.0, $max_total_count)); @@ -119,12 +119,12 @@ function statistics_title_list($dbfield, $dbrows) { * Retrieves a node's "view statistics". * * @deprecated in Drupal 8.2.x, will be removed before Drupal 9.0.0. - * Use \Drupal::service('statistics.storage')->fetchView($id). + * Use \Drupal::service('statistics.storage.node')->fetchView($id). */ function statistics_get($id) { if ($id > 0) { /** @var \Drupal\statistics\StatisticsViewsResult $statistics */ - $statistics = \Drupal::service('statistics.storage')->fetchView($id); + $statistics = \Drupal::service('statistics.storage.node')->fetchView($id); return [ 'totalcount' => $statistics->getTotalCount(), 'daycount' => $statistics->getDayCount(), @@ -139,7 +139,7 @@ function statistics_get($id) { function statistics_node_predelete(EntityInterface $node) { // Clean up statistics table when node is deleted. $id = $node->id(); - return \Drupal::service('statistics.storage')->deleteViews($id); + return \Drupal::service('statistics.storage.node')->deleteViews($id); } /** diff --git a/core/modules/statistics/statistics.php b/core/modules/statistics/statistics.php index 459be3d..a43509e 100644 --- a/core/modules/statistics/statistics.php +++ b/core/modules/statistics/statistics.php @@ -22,9 +22,9 @@ ->get('count_content_views'); if ($views) { - $id = filter_input(INPUT_POST, 'nid', FILTER_VALIDATE_INT); - if ($id) { + $nid = filter_input(INPUT_POST, 'nid', FILTER_VALIDATE_INT); + if ($nid) { $container->get('request_stack')->push(Request::createFromGlobals()); - $container->get('statistics.storage')->recordView($id); + $container->get('statistics.storage.node')->recordView($nid); } } diff --git a/core/modules/statistics/statistics.services.yml b/core/modules/statistics/statistics.services.yml index 95f6307..cf15573 100644 --- a/core/modules/statistics/statistics.services.yml +++ b/core/modules/statistics/statistics.services.yml @@ -1,5 +1,5 @@ services: - statistics.storage: + statistics.storage.node: class: Drupal\statistics\NodeStatisticsDatabaseStorage arguments: ['@database', '@state', '@request_stack'] tags: