Problem/Motivation
Found while working on #3404246: [META] Fix strict type errors detected by phpstan.
This isn't doing what it looks like. In install_check_class_requirements():
if (class_exists($class_name) && class_implements($class_name, InstallRequirementsInterface::class)) { }
The second param of class_implements is a boolean to opt in or out of autoloading, and the return value is an array of interfaces the class implements. So as long as the class implements one or more interfaces, this condition is satisfied, regardless of if its the right interface. This is why strict types is so useful and why I'm pushing for the phpstan check in the meta.
Steps to reproduce
- Install standard profile
- Edit \Drupal\media\Install\Requirements\MediaRequirements to implement some other interface instead
- Remove MediaRequirements::getRequirements
- Install the media module and see the fatal error
Proposed resolution
Replace call to class_implements with is_subclass_of
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork drupal-3552521
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:
- 3552521-fatal-error-caused
changes, plain diff MR !13504
Comments
Comment #4
luismagr commentedComment #5
smustgrave commentedSeems straight forward not sure if this needs test coverage
Comment #6
nicxvan commentedThanks for catching this!
Comment #7
longwaveNice find. Backported down to 11.2.x as an eligible bug fix. Doesn't apply to 10.6.x as I don't think we have the new requirements API there.
Committed and pushed 3a1a6c0aed2 to 11.x and ea8f200ff51 to 11.3.x and 79a2ab03164 to 11.2.x. Thanks!