TypeError: array_filter(): Argument #1 ($array) must be of type array, null given in array_filter()

Created on 31 January 2023, over 1 year ago
Updated 24 February 2023, over 1 year ago

Problem/Motivation

I am using the module for the first time. I am getting a fatal error when visiting the multidev I just installed it on.

TypeError: array_filter(): Argument #1 ($array) must be of type array, null given in array_filter() (line 85 of /code/web/modules/contrib/newrelic_transactions/src/EventSubscriber/EventSubscriber.php) #0 /code/web/modules/contrib/newrelic_transactions/src/EventSubscriber/EventSubscriber.php(85): array_filter(NULL)
#1 [internal function]: Drupal\newrelic_transactions\EventSubscriber\EventSubscriber->nameTransaction(Object(Symfony\Component\HttpKernel\Event\RequestEvent), 'kernel.request', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#2 /code/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(142): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\RequestEvent), 'kernel.request', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#3 /code/vendor/symfony/http-kernel/HttpKernel.php(145): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\RequestEvent), 'kernel.request')
#4 /code/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#5 /code/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#6 /code/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#7 /code/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(191): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#8 /code/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(128): Drupal\page_cache\StackMiddleware\PageCache->fetch(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#9 /code/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(82): Drupal\page_cache\StackMiddleware\PageCache->lookup(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#10 /code/web/modules/contrib/advban/src/AdvbanMiddleware.php(57): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#11 /code/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\advban\AdvbanMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#12 /code/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#13 /code/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#14 /code/web/core/lib/Drupal/Core/DrupalKernel.php(709): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 /code/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#16 {main}.

Steps to reproduce

On my Local, required it with composer, installed it, config export and pushed it up to a fresh multidev on Pantheon. I then visited the multidev and got the WSOD. We have errors sent over to Sentry so I was able to access the error.

I have the basic New Relic subscription that comes with every Pantheon app.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States capellic Austin, Texas

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

Comments & Activities

  • Issue created by @capellic
  • Status changed to Needs review over 1 year ago
  • πŸ‡ͺπŸ‡ΈSpain pcambra Spain, πŸ‡ͺπŸ‡Ί

    Found this issue on Pantheon too.

    There are a few causes for this:

    - The module doesn't define any configuration schema or config created on install, which makes the result of the transaction_roles, empty and not an empty array.
    - There's no fallback when getting the transaction roles, which makes anything that expects an array, receive null instead, added a couple of fallback for current installs.

  • Status changed to Needs work over 1 year ago
  • πŸ‡¨πŸ‡¦Canada RobLoach Earth

    Thanks a lot for the review here. Looks like there's some roles that we don't really need to represent in the default config...

    ```
    +transaction_roles:
    + anonymous: '0'
    + authenticated: '0'
    + administrator: '0'
    + member: '0'
    + guest: '0'
    + federated_member: '0'
    + wiki_editor: '0'
    + licensing_member: '0'
    + sales: '0'
    + lbc_attendee: '0'
    ```

  • Status changed to Needs review over 1 year ago
  • πŸ‡ͺπŸ‡ΈSpain pcambra Spain, πŸ‡ͺπŸ‡Ί

    oops :)

    • RobLoach β†’ committed c2afd01d on 1.0.x
      Issue #3338072 by pcambra: TypeError: array_filter(): Argument #1 ()...
  • Status changed to Fixed over 1 year ago
  • πŸ‡¨πŸ‡¦Canada RobLoach Earth

    Thanks so much! Looks great.

Production build 0.69.0 2024