Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Context mapping should happen before $block->access()
For \Drupal\ctools_block\Plugin\Block\EntityField->blockAccess()
this causes WSOD.
Steps to reproduce
Add an ctools EntityField to a context reaction - see WSOD.
Proposed resolution
Move context mapping before $block->access().
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#3 | context-mapping-should-happen-before-block-access-3.patch | 1.56 KB | silverham |
Comments
Comment #2
silverham CreditAttribution: silverham at EY Digital commentedComment #3
silverham CreditAttribution: silverham at EY Digital commentedComment #5
paulocsHey @silverham,
Can you provide the steps to add the EntityField block to a reaction?
I installed the Chaos Tools Blocks module but I don't know exactly how it works. I see that module prevents the EntityField block to be displayed on viewable block types so I don't know how to use it and what it does exactly.
Comment #6
DeaOm CreditAttribution: DeaOm at Agiledrop - Your Trusted Drupal Teammates commentedThis is only changing the order of the code execution, so if access for blocks is still working correctly, I would say commit the patch but without all the unnecessary comments added.
Comment #7
silverham CreditAttribution: silverham at EY Digital commentedHi @paulocs
How to replicate:
1. Install Drupal 8
2. Install ctools & submodule ctools_block (latest stable - 8.x-3.2)
3. Install context module (latest dev - issue appears in stable as well)
4. Create a context - any condition e.g. path NOT admin/* - with reaction block -> (Block: "ID", Category: "Content")
5. Go to the page which will trigger happen (e.g. homepage or any node page) -> see Error of death
Note that the $block->access() is cached when fixed, so you must clear cache and then go the page with fix removed to see the reaction cause the WSOD again. (if testing a few times)
Comment #8
paulocsHello @silverham,
after I applied the patch, I got the error:
Drupal\Component\Plugin\Exception\MissingValueContextException: Required contexts without a value: entity in Drupal\Core\Plugin\Context\ContextHandler->applyContextMapping() (line 155 of core/lib/Drupal/Core/Plugin/Context/ContextHandler.php).
I understand the problem now, but I'm not sure yet what the best solution is. If you have any suggestion, please let me know.
Maybe we should disable the context or the block that throws the exception and tell the user (or not) that is not possible to use the reaction in this context.
I'm looking if the core has already any solution for it so we can do something similar.
Comment #9
silverham CreditAttribution: silverham at EY Digital commentedI double checked the patch does actually work on node pages.
But am wrong however about working on homepages - it still crashes there - but that's out of scope.
Detailed steps to reproduce:
Comment #10
paulocsThanks @silverham!
Comment #12
paulocsFixed in dev branch.
Thanks @all.
Comment #13
silverham CreditAttribution: silverham at EY Digital commentedGreat - thanks. :-)