Warning: Invalid argument supplied for foreach() in Drupal\access_unpublished\EventSubscriber\AddHttpHeaders->onResponse() (line 55 of modules/contrib/access_unpublished/src/EventSubscriber/AddHttpHeaders.php).

Created on 26 May 2021, about 3 years ago
Updated 31 May 2024, 25 days ago

Problem/Motivation

When viewing an unpublished node after removing a token, I get the following error:

ร—Error message
Warning: Invalid argument supplied for foreach() in Drupal\access_unpublished\EventSubscriber\AddHttpHeaders->onResponse() (line 55 of modules/contrib/access_unpublished/src/EventSubscriber/AddHttpHeaders.php).
Drupal\access_unpublished\EventSubscriber\AddHttpHeaders->onResponse(Object, 'kernel.response', Object)
call_user_func(Array, Object, 'kernel.response', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.response', Object) (Line: 191)
Symfony\Component\HttpKernel\HttpKernel->filterResponse(Object, Object, 1) (Line: 130)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 191)
Drupal\page_cache\StackMiddleware\PageCache->fetch(Object, 1, 1) (Line: 128)
Drupal\page_cache\StackMiddleware\PageCache->lookup(Object, 1, 1) (Line: 82)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 50)
Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

  1. Copy a token from an unpublished node.
  2. Remove the token.
  3. As an anonymous user, try to access the node using the token.
  4. Error appears.

Note: to reproduce the error again by reloading the page, the Drupal cache would need to be cleared.

Proposed resolution

When I perform these steps, I should not see an error.

๐Ÿ› Bug report
Status

Postponed: needs info

Version

1.1

Component

Code

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States bribread22

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States generalredneck

    There are great work-arounds here. I suspect that several people got to this situation after mismanaging configuration using configuration export. It appears that's what happened on a site I'm maintaining because looking at the key_value table, the update clearly ran at some point.

Production build 0.69.0 2024