sites\default\services.yml
twig.config: debug: true, auto_reload: true, cache: false

Colorbox is a image field formatter for node. On the page of the node message:

Notice: Undefined index: theme_hook_original in twig_render_template() (line 78 of core\themes\engines\twig\twig.engine).
twig_render_template('modules/contrib/colorbox/templates/colorbox-formatter.html.twig', Array)........

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anonymous’s picture

Jon-Snow created an issue. See original summary.

serg2’s picture

Same issue occurring for me. Would any other info be helpful?

terribeausejour’s picture

My under development site in Drupal 8 has a problem - WSOD when attempting to display individual nodes. In viewing php errors, I see this: Notice: Undefined index: theme_hook_original in twig_render_template() (line 89 of /srv/bindings/79398a211a33497587f1f5c3f7af5e93/code/core/themes/engines/twig/twig.engine). I also see these notices: Notice: Undefined index: linked in linked_field_entity_display_build_alter() (line 174 of /srv/bindings/79398a211a33497587f1f5c3f7af5e93/code/modules/linked_field/linked_field.module).

Could this be causing the WSOD on node index display? Note, I disabled the linked field module thinking that module could be causing the issue, but it does not resolve the WSOD to do so. --Please advise, and guidance greatly appreciated.

serg2’s picture

@terribeausejour In my case there was no WSOD. Once I set twig debug to false the issue doesn't appear so maybe you could use that to check, or alternatively disable and un-install the module to see if it is the cause.

terribeausejour’s picture

Thanks for the tip on disabling twig debug. I agree now that the WSOD is originating elsewhere. That issue remains unresolved (for me) but I will post elsewhere on that as needed.

terribeausejour’s picture

Has anyone been able to eliminate this error while twig debug is enabled? It is ugly and distracting to have this during debugging and also makes it difficult to demo the site for the client without repeatedly having to disable/enable twig debugging during development phase. Note, for me it is only posted when not logged in, if that is helpful.

Any guidance would be appreciated.

Terri

Sam152’s picture

I will have a look and see if I can reproduce and fix this bug, hang tight.

DarkstarTom’s picture

I'm having the same problem, but again only when twig debugging is turned on and I am not logged into the site. A fix would be appreciated. Thanks.

gausarts’s picture

Status: Active » Needs review
FileSize
740 bytes

This doesn't happen when viewed as admin, but does when anonymous and only happens once on the first page load.

Reproduction

  • Clear cache.
  • View the colorbox page as anonymous for the first time after cache cleared.

Like the OP, I also have: debug: true, auto_reload: true, but cache: true.

As the notice said:
The underlying problem is template_preprocess_colorbox_formatter() removed the variables theme_hook_original needed by twig_render_template():
$variables = array(); // Reset the $variables parameter.

Attached a simple fix to bring back the deleted variables and shut up the notice ;)

  • frjo committed 50840c0 on 8.x-1.x
    Issue #2626466 by gausarts, Jon-Snow: Notice: Undefined index:...
frjo’s picture

Status: Needs review » Fixed

@gausarts thanks for tracking this down! I think an even easier solution is to simply delete the line that resets "$variables", it is a leftover from D7.

I have committed that fix now to 8.x-1.x. Reopen if there are any problems.

gausarts’s picture

Thank you.

I am currently working with Blazy and colorbox integration, and found another issue with the missing variable URL specific for anonymous users again due to such aggressive variables reset.

Removing that line fixes the problem elsewhere ;) A lot more flexible. Thanks.

Status: Fixed » Closed (fixed)

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

terribeausejour’s picture

I know this issue is closed, however. I referred back to it in order to apply the patch. In doing so, I found that the patch is for colorbox.theme.inc but the code that is to be patched is now in colorbox.inc. Just thought I'd give a heads up in case anyone else runs into this. Perhaps an update to the patch would be helpful as well...

Thanks very much for patching this, it is much appreciated.

Terri

agoradesign’s picture

The file was renamed in an earlier commit, so the patch is fine. As the patch is also already committed, I'd recommend you to switch to the dev version, until the next version is released.

vitalie’s picture

Re-rolled patch in #9 for 8.x-1.0 for those who prefer to patch the stable release.

Peter van den Heuvel’s picture

Patch from commet #16 worked fine for me. Thanks for the efford!

costellofax’s picture

Patch from #16 worked for me, thank you!!