Problem/Motivation
The Blocks context reaction injects the block_manager service with a concrete BlockManager type hint in its constructor. When another module decorates the block_manager service — as the Canvas module does with its BlockManagerDecorator — Symfony's dependency injection container throws a TypeError because the decorator is not an instance of the concrete BlockManager class, even though it correctly implements BlockManagerInterface. This causes a fatal error on any page load when both Context and Canvas are enabled.
Steps to reproduce
- Install the Context module (5.0.0-rc2)
- Install the Canvas module (1.7.1)
- Enable both modules
- Visit any page on the site
Proposed resolution
Change the type hint in Blocks::__construct() from the concrete BlockManager class to BlockManagerInterface, and update the corresponding @var docblock and use statement accordingly. Any class that correctly implements BlockManagerInterface — including decorated services — will then be accepted.
Remaining tasks
Review and commit the patch
User interface changes
None
API changes
None. The constructor parameter changes from a concrete class to the interface it implements. Any code already passing a valid BlockManager instance continues to work unchanged.
Data model changes
None
| Comment | File | Size | Author |
|---|---|---|---|
| context-block-manager-interface.patch | 1.56 KB | studiozut |
Comments