Statistics counter throws TypeError

Created on 30 January 2025, about 13 hours ago

Statistics counter throws a type error regarding StatisticsCounterSubscriber.php

TypeError: Cannot access offset of type array on array i Drupal\Core\Database\Query\Merge->key() (rad 331 av /data/6/1/61bcdcb7-8db6-481a-b0bf-b7b805822688/tfrebell.se/tfrebell.se/web/core/lib/Drupal/Core/Database/Query/Merge.php)

Error traced to code from line 45:

Database::getConnection('default')->merge('node_counter')
        ->key('nid', $node->id())
        ->fields([
          'weekcount' => 1,
          'monthcount' => 1,
          'yearcount' => 1,
        ])
        ->expression('weekcount', 'weekcount + 1')
        ->expression('monthcount', 'monthcount + 1')
        ->expression('yearcount', 'yearcount + 1')
        ->execute();

Seems to be similar to this issue πŸ› Fatal error when creating a rule using the "Set a user expiration date" action Active where specifically the last part from the MR on that issue where the key is changed

        ->key(['uid' => $user->id()])
        ->key('uid', $user->id())

Seems to resolve the issue in StatisticsCounterSubscriber.php, changing:

->key(['nid' => $node->id()])
to
->key('nid', $node->id())

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΈπŸ‡ͺSweden mscweb

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024