Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Annotated classes will never have a leading slash, but putting class: '\Drupal\mymodule\MyClass'
in a YAML-based definition is also valid.
Ideally the class itself wouldn't be compared by any code, but it is done in contrib, and should work consistently.
When using the MyClass::class constant, no leading slash is included.
Proposed resolution
Ensure plugin class names do not have leading slashes everywhere.
Remaining tasks
N/A
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#24 | 2824655-plugin-24.patch | 5.28 KB | tim.plunkett |
#24 | 2824655-plugin-24-interdiff.txt | 1.77 KB | tim.plunkett |
#22 | 2824655-plugin-22.patch | 4.44 KB | tim.plunkett |
| |||
#11 | 2824655-plugin-11.patch | 4.78 KB | tim.plunkett |
Comments
Comment #2
tim.plunkettComment #4
tim.plunkettDefaults need to be merged in first.
Comment #5
tim.plunkettOkay okay, I get it, typed config is weird.
Also this is why array-based definitions are bad.
Comment #6
tim.plunkettSo typed config has the same problem in the opposite direction: they are comparing class names as strings and assuming the leading slash:
If that was changed to the more modern style:
then the code would fail, since that has no leading slash.
Comment #10
tim.plunkettFifth time's the charm?
Comment #11
tim.plunkettUpdated now that LayoutPluginManager is in core
Comment #12
dawehnerI just corrected the issue title and summary
Comment #13
tim.plunkettComment #14
jibranDo we need a change notice here?
Comment #15
tim.plunkettThe original IS and title were correct originally.
Added a CR
https://www.drupal.org/node/2847370
Comment #16
jibranThanks!
Comment #18
tim.plunkettComment #19
EclipseGc CreditAttribution: EclipseGc commentedI love that this is consistent now, except for TypedConfig. Whatever the case, definitely an improvement. ++
Eclipse
Comment #20
tim.plunkettComment #21
xjmNote that issues like this should be targeted against 8.4.x, but can be considered for backport once they are committed to that branch. See the updated alpha release policy. Thanks!
Comment #22
tim.plunkett`use` statement conflict, git apply -3 worked cleanly but reuploading to get a green patch again.
Comment #24
tim.plunkett@effulgentsia asked to switch from implicit to explicit test coverage.
Comment #25
tedbowThe changes made to \Drupal\Tests\Core\Plugin\DefaultPluginManagerTest::providerTestProcessDefinition are expliciting testing this with and without slashes using both arrays and PluginDefinition objects.
Comment #27
effulgentsia CreditAttribution: effulgentsia at Acquia commentedThanks! Pushed to 8.4.x and published the CR with the version set to 8.4.x.
Since this is a low-risk, low-disruption patch, I'm open to cherry picking it to 8.3 prior to beta, if this is in fact a "Contributed project soft blocker". But why is it? Please add a comment explaining that and set it to Needs review or RTBC, depending on whether that comment warrants peer review.
A follow-up to remove this would be great, since I think it should be fine to fix that line in
hasConfigSchema()
to useUndefined::class
.Comment #29
effulgentsia CreditAttribution: effulgentsia at Acquia commentedNever mind. I figured it out. Contrib should be able to compare with
Foo::class
. Therefore, cherry picked to 8.3.x and updated the CR to be on that version.