Problem/Motivation
Follow-up of #3252386: Use PHP attributes instead of doctrine annotations, once that is in, we need to convert all the remaining plugin types, likely an issue per plugin type, *maybe* sometimes grouped together, like all the tests and maybe views as well, although there will be a lot there.
Once that is done, the old discovery as well as calling DefaultPluginManager with old arguments should trigger deprecation messages, either then in this issue or another child issue.
#3400458: AttributeClassDiscovery fails while trying to include non valid plugin class is about to fix some critical regressions in the attribute discovery at least when using the BC layer. There are some remaining questions about whether or not we want to support such cases (classes that can not be loaded due to missing traits, base classes, interfaces, ...)
Another step that is needed is updating plugin system documentation, issue for that: #3401822: Document attribute-based discovery in the handbook.
Steps to reproduce
Proposed resolution
Convert all plugin types and provide Rector rules via https://github.com/palantirnet/drupal-rector/pull/257
Remaining tasks
#3265945: Triggering deprecations for plugins using annotations when core plugin type has been converted to attributes
#3400121: Allow opt-out of annotation parsing
Plugin conversions
I18nQueryTrait
- move to migrate_drupal #3258581: Move I18nQueryTrait from content_translation to migrate_drupalMigrateSource
: #3421014: [PP-1] Convert MigrateSource plugin discovery to attributes
Done
- #3425568: Block attribute class expecting wrong ContextDefinition
- #3426217: Fix @param docs for $deriver on plugin attribute classes
- #3427388: Update Drupal\Component\Annotation\Doctrine\StaticReflectionParser::hasClassAttribute() to allow attribute subclasses
Archiver
: #3420985: Convert Archiver discovery to attributesCKEditor5AspectsOfCKEditor5Plugin
,CKEditor5Plugin
,DrupalAspectsOfCKEditor5Plugin
,CKEditor4To5Upgrade
: #3399036: CKEditor5PluginManager: use PHP attributes instead of doctrine annotationsCondition
: #3420986: Convert Condition plugin discovery to attributesConstraint
: #3420990: Convert Constraint plugin discovery to attributesContextDefinition
: #3420989: Convert ContextDefinition plugin discovery to attributesDataType
: #3420987: Convert DataType plugin discovery to attributesDisplayVariant
andPageDisplayVariant
: #3420984: Convert Layout DisplayVariant, PageDisplayVariant discovery to attributesEditor
: #3421011: Convert Editor plugin discovery to attributesEntityReferenceSelection
: #3420982: Convert EntityReferenceSelection plugin discovery to attributesEntityType
,ContentEntityType
,ConfigEntityType
: #3396166: Convert entity type discovery to PHP attributesFieldFormatter
: #3420980: Convert FieldFormatter plugin discovery to attributesFieldType
: #3420981: Convert FieldType plugin discovery to attributesFieldWidget
: #3420978: Convert FieldWidget plugin discovery to attributesFilter
: #3421012: Convert Filter plugin discovery to attributesHelpSection
: #3420993: Convert HelpSection plugin discovery to attributesImageEffect
: #3420996: Convert ImageEffect plugin discovery to attributesImageToolkit
: #3420991: Convert ImageToolkit plugin discovery to attributesImageToolkitOperation
: #3420992: Convert ImageToolkitOperation plugin discovery to attributesLanguageNegotiation
: #3421017: Convert LanguageNegotiation plugin discovery to attributesLayout
: #3420983: Convert Layout plugin discovery to attributesMail
: #3420977: Convert Mail plugin discovery to attributesMediaSource
: #3420997: Convert MediaSource plugin discovery to attributesMigrateDestination
: #3421015: Convert MigrateDestination plugin discovery to attributesMigrateField
: #3421020: Convert MigrateField plugin discovery to attributesMigratePluginManager
:#3424509: Update MigratePluginManager to include both attribute and annotation classMigrateProcessPlugin
: #3421016: Convert MigrateProcessPlugin plugin discovery to attributesQueueWorker
: #3420988: Convert QueueWorker plugin discovery to attributesRenderElement
andFormElement
: #3421439: Convert form and render element plugin discovery to attributesRestResource
: #3420994: Convert RestResource plugin discovery to attributesSearchPlugin
: #3421013: Convert Search plugin discovery to attributesSectionStorage
: #3421019: Convert SectionStorage plugin discovery to attributesViewsAccess
: #3421001: Convert ViewsAccess plugin discovery to attributesViewsArea
: #3426959: Convert ViewsArea plugin discovery to attributesViewsArgument
andViewsArgumentHandlers
: #3425359: Convert ViewsArgumentHandlers plugin discovery to attributesViewsArgumentDefault
: #3421003: Convert ViewsArgumentDefault plugin discovery to attributesViewsArgumentValidator
: #3421010: Convert ViewsArgumentValidator plugin discovery to attributesViewsCache
: #3421009: Convert ViewsCache plugin discovery to attributesViewsDisplayExtender
andViewsPluginAnnotationBase
: #3421006: Convert ViewsDisplayExtender plugin discovery to attributesViewsExposedForm
: #3421008: Convert ViewsExposedForm plugin discovery to attributesViewsField
: #3426955: Convert ViewsField plugin discovery to attributesViewsFilter
: #3426957: Convert ViewsFilter plugin discovery to attributesViewsDisplay
: #3421002: Convert ViewsDisplay plugin discovery to attributesViewsJoin
: #3426958: Convert ViewsJoin plugin discovery to attributesViewsPager
: #3421004: Convert ViewsPager plugin discovery to attributesViewsQuery
: #3421007: Convert ViewsQuery plugin discovery to attributesViewsRelationship
: #3426956: Convert ViewsRelationship plugin discovery to attributesViewsRow
: #3420999: Convert ViewsRow plugin discovery to attributesViewsSort
: #3426961: Convert ViewsSort plugin discovery to attributesViewsStyle
: #3421005: Convert ViewsStyle plugin discovery to attributesViewsWizard
: #3421000: Convert ViewsWizard plugin discovery to attributesWorkflowType
: #3421018: Convert WorkflowType plugin discovery to attributes
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork drupal-3396165
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
Comment #2
berdirComment #3
berdirThe blocker is committed.
Comment #4
andypostComment #5
andypostComment #6
wim leersComment #7
catchMeta question, is this enough of a meta issue to encompass the entirety of moving from annotations to attributes, or should we also open a parent 'plan' issue that encompasses this and any other attribute issues that come up (like deprecations and so on)?
Comment #8
longwaveI think we should start by opening child issues here to finish off actions (only needs deprecations now?) and blocks (two remaining blocks plus deprecations?) and then go from there.
Comment #9
berdir#3265945: Triggering deprecations for plugins using annotations when core plugin type has been converted to attributes will add deprecations for all plugin types that use the BC-discovery automatically, doesn't need a separate issue for actions. Blocks maybe could use a separate issue, although the layout builder one kind of already has one issue.
IMHO this is enough for the meta issue to cover relate tasks as well?
Comment #10
wim leersComment #11
longwaveAdded #3265945: Triggering deprecations for plugins using annotations when core plugin type has been converted to attributes as a child as it seems the best place for it right now.
Comment #12
berdirI'm a bit unsure if we should wait on rector to do at least the bigger ones. I guess entity is by far the most complex with 100+ very large attribute definitions. @andypost started something there, but unsure how feasible it is to have something that works in a reasonable timeframe, this is far more complex than most deprecations.
This is something we have to be aware of with this change. As necessary as it is to remove doctrine annotations and as much better the new DX is, this might be the single biggest deprecation that we've had since 8.0 (deliberately excluding some pre 8.0 things). There's barely a module out there with not at least a single plugin and *many* contrib modules defining their own plugin types that other contrib modules will first need to wait to support attributes, sites will break when updating the wrong module first and dependency versions aren't clearly defined. This is going to be painful.
One thing to consider I guess is to fork the doctrine stuff even further so we keep support for Annotations until D12?
Comment #13
catch@berdir @longwave just opened a new issue to discuss that #3400121: [policy, no patch] Allow both annotations and attributes in Drupal 11
Comment #14
berdirComment #15
berdirComment #16
larowlanComment #17
larowlanComment #18
larowlanAdded child issues for all plugin types except
\Drupal\plugin_test_extended\Plugin\Annotation\PluginExtended
which we can sort out later.Updated issue summary with list
Comment #19
longwaveComment #20
godotislate CreditAttribution: godotislate at Digital Polygon commentedComment #21
quietone CreditAttribution: quietone at PreviousNext commentedUnless I am mistaken, there is also the views handler, \Drupal\views\Plugin\ViewsHandlerManager.
Comment #22
andypostUpdated IS with link to https://github.com/palantirnet/drupal-rector/pull/257
@bbrala polished 10.2 conversions already
@quietone yes, views plugins are the last and could use own META
Comment #23
mstrelan CreditAttribution: mstrelan at PreviousNext commentedAdded #3425568: Block attribute class expecting wrong ContextDefinition which may also impact other plugins too
Comment #24
mstrelan CreditAttribution: mstrelan at PreviousNext commentedAdded #3426217: Fix @param docs for $deriver on plugin attribute classes
Comment #25
berdirI realized that we forgot about another generic plugin feature beside deriver, the provider. It isn't used a lot in core for obvious reasons, but it's a valid use case to implement a plugin if another module exists. There are some challenges with it in case it depends on base classes/traits like \Drupal\layout_builder\Plugin\Block\InlineBlock (which doesn't use provider because the deriver kind of takes care of that but it would be if not using a deriver)
\Drupal\book\Plugin\migrate\destination\Book is another example in core, which has been made redundant due to the move to book module, and it's being removed in #3421015: Convert MigrateDestination plugin discovery to attributes.
The most common use case is contrib modules providing plugins for core or other contrib modules that may or may not be there. entity_browser does that for some of its plugins, linkit does it, pathauto for forum module, and our monitoring project. Those cases are all for their own plugin types, so those modules are absolutely free to define it, but it won't be possible to do it directly in the attribute for core plugin types. There are not many examples that would need that, one that I found is https://git.drupalcode.org/project/crop_image/-/blob/1.0.x/src/Plugin/Fi..., which provides a field widget plugin if entity_browser is enabled.
Not sure what we should do about that :)
Comment #26
bbralaThis is releasing very soon:
https://github.com/palantirnet/drupal-rector/blob/2cc2787bd323406b7da4f4...
Tracked in this PR: https://github.com/palantirnet/drupal-rector/pull/296
Tested on this issue: https://www.drupal.org/project/drupal/issues/3396166 (see the MR for the automated branch)
Comment #27
bbralaReleased here:
https://github.com/palantirnet/drupal-rector/releases/tag/0.20.1
Includes usage docs for Core conversions. Hopefully it helps speed things up.
Comment #28
mstrelan CreditAttribution: mstrelan at PreviousNext commentedAdded 7 more views plugin types for conversion
Comment #29
bbralaFun fact, you can run the rector on an existing MR to check if something was missed. It will skip over any classes already implementing the attribute.
Comment #30
feuerwagenSorted the task list a bit
Comment #31
godotislate CreditAttribution: godotislate at Digital Polygon commentedAdded #3427388: Update Drupal\Component\Annotation\Doctrine\StaticReflectionParser::hasClassAttribute() to allow attribute subclasses to the list to handle subclasses.
Comment #32
feuerwagenComment #33
quietone CreditAttribution: quietone at PreviousNext commentedComment #34
naveenvalechaComment #35
godotislate CreditAttribution: godotislate at Digital Polygon commentedComment #36
naveenvalechaComment #37
quietone CreditAttribution: quietone at PreviousNext commentedIssue summary updates: Remove Tip from the issue summary because it will be done in contrib. And added #3265945: Triggering deprecations for plugins using annotations when core plugin type has been converted to attributes.
Comment #38
quietone CreditAttribution: quietone at PreviousNext commentedComment #39
quietone CreditAttribution: quietone at PreviousNext commentedComment #40
bbralaEarlier this week I did a check using a branch with all converted plugins in rector against head. Source of the list was the change record.
https://github.com/palantirnet/drupal-rector/tree/feature/annotation-rules
Good news, there were no conversions missing.
Comment #41
bbrala@Berdir sent me a message there were a few missing.
Examples:
So i've looked into why this is. Might be me doing not smart things while scripting.
Comment #42
bbralaOk, i've done a booboo when making the script. Aftersome tweaks:
The BooBoo were a few things:
My config added classes instead of the annotations. Rector didnt like backslashes before the classes, so did some extra normization actions. I'll push how i ran on core to a branch here.
Comment #43
bbralaCompare changes on GitLab
Comment #44
andypost@bbrala great job! Looks only formatting left to apply and it could be reused for contrib!
Comment #45
quietone CreditAttribution: quietone at PreviousNext commentedComment #46
quietone CreditAttribution: quietone at PreviousNext commentedComment #47
naveenvalechaComment #48
quietone CreditAttribution: quietone at PreviousNext commentedComment #49
godotislate CreditAttribution: godotislate at Digital Polygon commentedComment #50
naveenvalechaComment #51
godotislate CreditAttribution: godotislate at Digital Polygon commentedAdded #3258581: Move I18nQueryTrait from content_translation to migrate_drupal to the remaining tasks for visibility, because it's a blocker for #3421014: [PP-1] Convert MigrateSource plugin discovery to attributes.
Comment #52
catchTagging this so it's easier to find in 'things that would be good to do for 11.0/10.3 beta'.
Comment #53
joegl CreditAttribution: joegl commentedThis may be the wrong place for this (apologies if so).
The change record and documentation state Drupal 10.2.0 plugins should start using attribute-based instead of annotation-based plugins, but the core plugins don't actually support attribute-based discovery until 10.3.x. Can there be more clear documentation stating it's not well-supported yet until 10.3.x?
Relevant links:
- https://www.drupal.org/node/3403921 (10.2)
- https://www.drupal.org/node/3395575 (10.2)
- https://www.drupal.org/node/3229001 (10.3)
Comment #54
godotislate CreditAttribution: godotislate at Digital Polygon commentedComment #55
larowlanComment #56
quietone CreditAttribution: quietone at PreviousNext commented