Problem/Motivation

The website encountered an unexpected error. Please try again later.
TypeError: array_values(): Argument #1 ($array) must be of type array, null given in array_values() (line 116 of modules\contrib\visitors\src\EventSubscriber\KernelTerminateSubscriber.php).
array_values() (Line: 116)
Drupal\visitors\EventSubscriber\KernelTerminateSubscriber->onTerminate()
call_user_func() (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 100)
Symfony\Component\HttpKernel\HttpKernel->terminate() (Line: 32)
Stack\StackedHttpKernel->terminate() (Line: 687)
Drupal\Core\DrupalKernel->terminate() (Line: 22)

Steps to reproduce

Upgrade the module to 8.x-2.10, but don't update the database.

Proposed resolution

add `?? []` so the value is never null.

Issue fork visitors-3305275

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

bluegeek9 created an issue. See original summary.

  • bluegeek9 committed d7a1c5d on 8.x-2.x
    Issue #3305275 by bluegeek9: TypeError upgrade 8.x-2.10
    
bluegeek9’s picture

Status: Active » Fixed
paintingguy’s picture

After upgrading to the last (8.x-2.11)build I get this error which forces me to remove the visitors block.

Warning: Undefined array key "show_total_visitors" in Drupal\visitors\Plugin\Block\VisitorsBlock->build() (line 96 of modules/visitors/src/Plugin/Block/VisitorsBlock.php).

bluegeek9’s picture

@paintingguy,

It should work again if you add a new visitors block or save the existing block's configuration form.

I am working on an update so this does not happen to other site builders.

The visitors block now has per block configurations; you can place the visitors block more than once, each with different settings.

  • bluegeek9 committed 86ba56b on 8.x-2.x
    Issue #3305275 by bluegeek9: TypeError upgrade 8.x-2.10
    
bluegeek9’s picture

Title: TypeError upgrade 8.x-2.10 » Upgrade 8.x-2.11 - Undefined array key
Category: Task » Bug report

Status: Fixed » Closed (fixed)

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