Problem/Motivation
A slots data type error throws a message like this (note the missing component):
[warning] Drupal\Core\Render\Component\Exception\InvalidComponentException: [slots.contacts] Array value found, but an object is required in Drupal\Core\Theme\Component\ComponentValidator->validateDefinition() (line 145 of /var/www/html/web/core/lib/Drupal/Core/Theme/Component/ComponentValidator.php).
Steps to reproduce
Obvious.
Proposed resolution
Add the component id to the error.
In ComponentValidator, find
$message_parts = [
...$message_parts,
...$missing_class_errors,
];
Replace with:
$message_parts = [
sprintf('In component %s:', $definition['id']),
...$message_parts,
...$missing_class_errors,
];
Remaining tasks
- Roll a MR
- Review
- Commit
User interface changes
None.
Introduced terminology
None.
API changes
None.
Data model changes
None.
Release notes snippet
---
Issue fork drupal-3549909
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:
- 3549909-component-slot-error
compare
- 11.x
changes, plain diff MR !13421
Comments
Comment #2
geek-merlinComment #5
solimanharkas commentedI've added the component ID to validation errors.
Before:
[warning] Drupal\Core\Render\Component\Exception\InvalidComponentException: [slots.contacts] Array value found, but an object is required in Drupal\Core\Theme\Component\ComponentValidator->validateDefinition()...
After:
[warning] Drupal\Core\Render\Component\Exception\InvalidComponentException: In component test_component:
[slots.contacts] Array value found, but an object is required...
Comment #6
ankitv18 commentedMR changes looks good, hence moving into RTBC.
Comment #9
longwaveCommitted and pushed 6c68fad3969 to 11.x and 4b4e574e417 to 11.3.x. Thanks!
Decided not to backport in case something like a test is relying on the old format (Canvas has some tests around this for sure) and 11.3.0 is out next month anyway.