Problem/Motivation

The canvas_bootstrap module's
ThemeAwareSingleDirectoryComponentDiscovery class fails to
instantiate when the canvas module is installed, because its
constructor does not pass a required PropShapeRepositoryInterface
argument when creating the inner
SingleDirectoryComponentDiscovery object.

The canvas module updated
SingleDirectoryComponentDiscovery::__construct() to require
PropShapeRepositoryInterface as its first parameter, but
canvas_bootstrap's ThemeAwareSingleDirectoryComponentDiscovery
was not updated to match. This results in a fatal error at runtime when
the canvas component discovery service is resolved from the container.

Steps to reproduce

  1. Install both drupal/canvas and drupal/canvas_bootstrap.
  2. Enable both modules.
  3. Visit any page that triggers the canvas component plugin manager (e.g. a
    page using a layout with canvas components, or by clearing caches).
  4. Observe a fatal PHP error:

    Too few arguments to function SingleDirectoryComponentDiscovery::__construct()
    (or an ArgumentCountError / type mismatch depending on PHP version).

Proposed resolution

Update ThemeAwareSingleDirectoryComponentDiscovery to:

  1. Add use Drupal\canvas\PropShape\PropShapeRepositoryInterface; to the imports.
  2. Inject PropShapeRepositoryInterface as the first constructor argument (matching the updated SingleDirectoryComponentDiscovery signature).
  3. Pass $this->propShapeRepository as the first argument when constructing the inner SingleDirectoryComponentDiscovery instance.
  4. Resolve PropShapeRepositoryInterface::class from the container in the create() factory method.

Remaining tasks

  • Review and commit the patch.
  • Add a regression test that verifies the service can be instantiated
    when both canvas and canvas_bootstrap are enabled.

User interface changes

None.

API changes

The constructor signature of
ThemeAwareSingleDirectoryComponentDiscovery gains a new required
first parameter: PropShapeRepositoryInterface $propShapeRepository.
Any code instantiating this class directly (outside the container) will
need to be updated to pass this argument.

Data model changes

None.

Command icon 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

alabandit created an issue. See original summary.

alabandit’s picture

StatusFileSize
new1.38 KB

ahmad abbad made their first commit to this issue’s fork.

  • ahmad abbad committed 9ed7f9af on 1.0.x
    fix: #3605189 ThemeAwareSingleDirectoryComponentDiscovery constructor...
ahmad abbad’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

ahmad abbad’s picture

Thank you, alabandit

ahmad abbad’s picture

Status: Fixed » Closed (fixed)