Problem/Motivation
Language context missing in Block Deriver definition.
As we were updating our site from 8.9 to 9.2.7 we noticed this module was throwing the following exception:
Drupal\Component\Plugin\Exception\ContextException: Assigned contexts were not satisfied: language in Drupal\Core\Plugin\Context\ContextHandler->applyContextMapping() (line 145 of /DRUPAL_ROOT/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php).
So, we needed to dig in and fix the problem because this exception was blocking the rendering of our content.
Steps to reproduce
Simply enable this module for one of your content types under Drupal 9.2.x environment, and try to view/render it, you should have the aforesaid exception.
Proposed resolution
The problem we found is the missing language context on the deriver class (src/Plugin/Derivative/TextLongFieldTocBlockDeriver.php) on the getDerivativeDefinitions method. We had to add the language context using the context repository service.
Remaining tasks
We should also considere to replace the context entry on @Block annotation under src/Plugin/Block/TextLongFieldTocBlock.php with context_definitions since it was deprecated since Drupal 8.7
User interface changes
None
API changes
None
Data model changes
None
Issue fork table_of_contents-3244723
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
Comment #3
hawkeye.twolfComment #4
adaltavo commentedComment #5
e0ipsoThis looks great!
Comment #6
e0ipsoI left some minor comments.
Comment #7
hawkeye.twolfRTBC from me! Be sure to credit @adaltavo with the commits.
Comment #8
e0ipsoThis looks good. Merging.