Convert entity type discovery to PHP attributes

Created on 23 October 2023, about 1 year ago
Updated 16 September 2024, 2 months ago


Problem/Motivation

Child of πŸ“Œ [meta] Convert all core plugin types to attribute discovery Active

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Needs review

Version

11.0 πŸ”₯

Component
EntityΒ  β†’

Last updated about 23 hours ago

Created by

πŸ‡¨πŸ‡­Switzerland berdir Switzerland

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @berdir
  • Status changed to Postponed about 1 year ago
  • πŸ‡¨πŸ‡­Switzerland berdir Switzerland
  • Pipeline finished with Failed
    about 1 year ago
    #36942
  • Pipeline finished with Failed
    about 1 year ago
    Total: 163s
    #38577
  • Pipeline finished with Success
    about 1 year ago
    Total: 677s
    #38592
  • Pipeline finished with Canceled
    about 1 year ago
    Total: 26s
    #38611
  • Pipeline finished with Failed
    about 1 year ago
    Total: 175s
    #38612
  • Pipeline finished with Canceled
    about 1 year ago
    #38660
  • Pipeline finished with Failed
    about 1 year ago
    Total: 171s
    #38661
  • Pipeline finished with Failed
    about 1 year ago
    Total: 707s
    #39609
  • πŸ‡¨πŸ‡­Switzerland berdir Switzerland

    I'd rather not mix that. This only affects the attribute/discovery class. We then get all values from it and instantiate the definition object form it, those two are completely disconnected apart from sharing the same properties (for the most part). While some options related to that were discussed, the current discovery only supports a single class and a discovered definition currently also needs to be a single array/object thing.

    I would expect the BC implications of that issue massive also on the entity type level, this doesn't affect it at all, what you interact with once plugins are discovered is 100% identical to before. Even the build and alter hooks 100% identical to before.

  • Status changed to Needs work about 1 year ago
  • πŸ‡¨πŸ‡­Switzerland berdir Switzerland
  • πŸ‡¬πŸ‡§United Kingdom longwave UK

    +1 to only doing 1:1 mappings from annotations to attributes in these conversion issues; if we want to refactor them later at least attributes will hopefully make that easier.

  • Pipeline finished with Failed
    about 1 year ago
    Total: 222s
    #41164
  • First commit to issue fork.
  • Pipeline finished with Failed
    9 months ago
    Total: 495s
    #95775
  • First commit to issue fork.
  • Pipeline finished with Failed
    8 months ago
    Total: 2633s
    #113529
  • First commit to issue fork.
  • πŸ‡³πŸ‡±Netherlands bbrala Netherlands

    I'm testing out some automation.

    Got dev branch from drupal-rector:

    composer require palantirnet/drupal-rector:dev-feature/annotation-configentitytype

    Added a rector.php

    <?php
    declare(strict_types=1);
    
    use Rector\Config\RectorConfig;
    
    return static function(RectorConfig $rectorConfig): void {
      $rectorConfig->ruleWithConfiguration(\DrupalRector\Drupal10\Rector\Deprecation\AnnotationToAttributeRector::class, [
    
        // Setting remove version to 10.x means the comments are not kept.
        new \DrupalRector\Drupal10\Rector\ValueObject\AnnotationToAttributeConfiguration('10.0.0', '10.0.0', 'ContentEntityType', 'Drupal\Core\Entity\Attribute\ContentEntityType'),
        new \DrupalRector\Drupal10\Rector\ValueObject\AnnotationToAttributeConfiguration('10.0.0', '10.0.0', 'ConfigEntityType', 'Drupal\Core\Entity\Attribute\ConfigEntityType'),
      ]);
    
      $rectorConfig->autoloadPaths([
        './lib',
        './modules',
        './profiles',
        './themes'
      ]);
    
    
      $rectorConfig->skip([
        '*/upgrade_status/tests/modules/*',
        '*/ProxyClass/*',
        '*/tests/fixtures/*',
        '*/vendor/*',
      ]);
      $rectorConfig->fileExtensions([
        'php',
        'module',
        'theme',
        'install',
        'profile',
        'inc',
        'engine'
      ]);
      $rectorConfig->importNames(FALSE, FALSE);
      $rectorConfig->importShortClasses(FALSE);
    };
    
    

    Then ran rector in core (my setup is with joachim's core dev setup):

    vendor/bin/rector process repos/drupal/core/

    Opening a seperate MR to see how it does.

  • Pipeline finished with Failed
    8 months ago
    Total: 187s
    #115267
  • Pipeline finished with Failed
    8 months ago
    Total: 186s
    #115275
  • πŸ‡³πŸ‡±Netherlands bbrala Netherlands

    Php didn't want to run locally.

    Phpstan wasn't happy with missing \ for the translatable markup. Manually fixed those.

    There might be more needed, but out of time.

    Might try later.

  • Pipeline finished with Failed
    8 months ago
    Total: 402s
    #115283
  • Pipeline finished with Failed
    8 months ago
    Total: 192s
    #115286
  • Pipeline finished with Running
    8 months ago
    #115409
  • πŸ‡¬πŸ‡§United Kingdom joachim

    > public readonly ?string $field_ui_base_route = NULL,

    This doesn't belong in core, it's added by Field UI.

    We discussed the problem of 3rd-party annotation properties in the original issue to add attributes to core, but I don't remember how it was decided it would be dealt with.

  • πŸ‡¦πŸ‡ΊAustralia mstrelan

    Can we let modules like Field UI define additional attributes on plugins?

    #[Entity()]
    #[FieldUIBaseRoute]

  • πŸ‡¨πŸ‡­Switzerland berdir Switzerland

    It's an existing, documented property, we're not introducing it here. I agree it shouldn't be here, but having multiple attributes is not supported by our parser and I don't see an easy way to introduce that. Field UI would then need it's own discovery and cache and it would be an API change to any code looking for that info.

    The EntityType attributes class both defines an additional key where extra stuff can be put and also supports variadics for extra stuff that is then put it additional what of that exactly makes it in is still to be determined.

  • πŸ‡¬πŸ‡§United Kingdom joachim

    > I agree it shouldn't be here, but having multiple attributes is not supported by our parser and I don't see an easy way to introduce that.

    Is this going to break BC for modules which put their own top-level properties in entity annotations?

    And what about the annotations we've already converted? I thought the general attribute issue was covering this and now it seems it hasn't.

  • πŸ‡¨πŸ‡¦Canada Charlie ChX Negyesi 🍁Canada

    return !($value === NULL && ($key === 'deriver' || $key === 'provider' || $key == 'entity_type_class'));

    return isset($value) || in_array($key, ['deriver', 'provider', 'entity_type_class'], TRUE);

  • πŸ‡¨πŸ‡­Switzerland berdir Switzerland

    #18: This only affects the annotation/attribute discovery. alter hooks and resulting definitions work unchanged. That's exactly why we're trying to do this 1:1. It will not break/change until you convert your specific annotation to an attribute and whether or not there will be changed in the structure is still to be defined.

  • πŸ‡¨πŸ‡­Switzerland berdir Switzerland

    Recent changes to discovery broke the ability to have subclasses. This is being implemented in πŸ“Œ Convert Layout DisplayVariant, PageDisplayVariant discovery to attributes Needs review , so blocked on that.

  • Per suggestion from @alexpott on Slack, handling the subclass discovery changes in πŸ“Œ Update Drupal\Component\Annotation\Doctrine\StaticReflectionParser::hasClassAttribute() to allow attribute subclasses Active . So that's the blocker instead of πŸ“Œ Convert Layout DisplayVariant, PageDisplayVariant discovery to attributes Needs review .

  • Pipeline finished with Failed
    8 months ago
    Total: 499s
    #118175
  • πŸ‡§πŸ‡ͺBelgium kristiaanvandeneynde Antwerp, Belgium

    One thing I'm wondering is how this MR gets away with not putting the optional arguments last in the attribute constructors. I know that some of it is being covered/hidden by variadics (...$base) and the use of named arguments. However, when I do something similar in Group it complains about the argument order in both phpstan and throws php errors.

    https://git.drupalcode.org/project/group/-/merge_requests/147/diffs#813d...

    How is phpstan and php not tripping over this MR?

    E.g.:

    #[\Drupal\Core\Entity\Attribute\ConfigEntityType(id: 'date_format', label: new TranslatableMarkup('Date format'), handlers: ['access' => 'Drupal\system\DateFormatAccessControlHandler'], entity_keys: ['id' => 'id', 'label' => 'label'], admin_permission: 'administer site configuration', list_cache_tags: ['rendered'], config_export: ['id', 'label', 'locked', 'pattern'])]
    class DateFormat extends ConfigEntityBase implements DateFormatInterface {
    

    Does not specify config_prefix as seen here:

      public function __construct(
        public readonly ?string $config_prefix = NULL,
        public readonly array $lookup_keys = [],
        public readonly array $config_export = [],
        ...$base
      ) {
    

    That should make phpstan complain and even PHP >= 8.1 crash because you can no longer put optional arguments before required ones.
    See: https://www.php.net/manual/en/migration81.incompatible.php#migration81.i...

  • πŸ‡¨πŸ‡­Switzerland berdir Switzerland

    phpstan is complaining, but it's on a level that core ignores atm. Your configuration might be more strict?

    It's not a PHP error exactly because of named arguments, they can be in any order as long as they *are* defined, the phpstan error is just a consistency thing.

    But I will most likely drop the current trickery anyway and re-define all properties on the child classes because I don't care about phpstan, but I do care about autocomplete support in PHPStorm and that can't handle this either.

    * Note: There are tons of test fails because there are undefined named properties, that part is indeed not working, it might work if I implement logic that puts unknown stuff directly in aditional, will need to test. But I'm honestly also fine with just requiring that those need to move inside the explicit additional array. That's what happens after after discovery internally on the EntityType plugin definition class already now anyway (that is a different class than the one we use for parsing the plugin definition)

  • πŸ‡§πŸ‡ͺBelgium kristiaanvandeneynde Antwerp, Belgium

    Ugh, never mind. I forgot that the question mark means "You can omit this or specifically set this to NULL", whereas omitting the question mark while providing a default value means: "You can omit this or set this to something else, but not NULL"

    Sorry, I confused myself.

    But I will most likely drop the current trickery anyway and re-define all properties on the child classes because I don't care about phpstan, but I do care about autocomplete support in PHPStorm and that can't handle this either.

    Thanks for that, while converting to attributes I loved the autocomplete feature.

  • Pipeline finished with Failed
    8 months ago
    Total: 175s
    #118585
  • Pipeline finished with Failed
    8 months ago
    Total: 201s
    #118602
  • Pipeline finished with Failed
    8 months ago
    Total: 495s
    #118605
  • Pipeline finished with Failed
    8 months ago
    Total: 379s
    #120977
  • Pipeline finished with Failed
    8 months ago
    Total: 478s
    #124036
  • Pipeline finished with Failed
    8 months ago
    Total: 623s
    #130993
  • Pipeline finished with Canceled
    8 months ago
    #132041
  • Status changed to Needs review 8 months ago
  • πŸ‡¨πŸ‡­Switzerland berdir Switzerland

    I suspected already that this would be related to config entity cache tags.

    There's an interesting and subtle change here between the way the annotation and attribute work. The entity annotation classes didn't really have any properties defined, we have them on the plugin definition object and were too lazy to do both. So the list_cache_tags property was by default NULL/not defined at all. Now we define it as an array with a default value of []. That means that \Drupal\Core\Entity\Attribute\EntityType::get() no longer filters out out, because an empty array is not NULL.

    Then, \Drupal\Core\Config\Entity\ConfigEntityType::__construct() has this strange copypaste snippet from the parent that sets a default value to the $this->list_cache_tags before calling the parent constructor, so that the similar snippet there is skipped. However, no $definition has a list_cache_tags entry set to an empty array and replaces that again.

    Fix is pretty easy, we just set the default on $definition['list_cache_tags'] if that is empty, instead of the completely bogus if (empty($this->list_cache_tags)) { which at that point definitely always was empty.

    Note sure if there are other subtle differences like this, hopefully not as the plugin definition object should have property defaults for things, lets see if any test fails remain I guess.

  • Pipeline finished with Success
    8 months ago
    Total: 541s
    #132042
  • Pipeline finished with Failed
    8 months ago
    Total: 189s
    #137768
  • Status changed to Needs work 8 months ago
  • The Needs Review Queue Bot β†’ tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

  • Pipeline finished with Success
    8 months ago
    Total: 650s
    #137802
  • Status changed to Needs review 8 months ago
  • Applied my own suggestions and rebased.

  • godotislate β†’ changed the visibility of the branch 3396166-convert-entity-type to hidden.

  • Status changed to Needs work 7 months ago
  • The Needs Review Queue Bot β†’ tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

  • Status changed to Needs review 7 months ago
  • πŸ‡¨πŸ‡­Switzerland berdir Switzerland

    Rebased. Rebasing this is pretty tough with the formatting commits, we might want to squash that all together. And just get it in asap.

  • Pipeline finished with Success
    7 months ago
    Total: 990s
    #146361
  • πŸ‡³πŸ‡±Netherlands kingdutch

    I realize this may be out of scope but #2813895: Combine entity type labels in an array β†’ has been open for a while and would be a breaking change in any existing system. However the conversion to attributes might be the perfect time to make the grouping since people will have to re-write their annotations anyway (so it's not more or less breaking than what we're already doing).

    I only just came across that issue so sorry if this is a bit late in the process.

  • However the conversion to attributes might be the perfect time to make the grouping since people will have to re-write their annotations anyway (so it's not more or less breaking than what we're already doing).

    Per @Berdir in #31 πŸ“Œ Convert entity type discovery to PHP attributes Needs review , it's probably best for this to land ASAP without additional blockers. Though maybe a compromise solution is to add support to set labels per #2813895: Combine entity type labels in an array β†’ now, convert maybe 1 entity type to confirm it works, then do the remainder of the conversion in the other issue? My thinking here would be something like this:

    In the constructors of the new attributes, add protected readonly array $labels = [],.

    Then in the get() methods of the EntityType attribute:

      $values = array_filter(get_object_vars($this) + [
          'class' => $this->getClass(),
          'provider' => $this->getProvider(),
        ], function ($value, $key) {
          return !($value === NULL && ($key === 'deriver' || $key === 'provider' || $key == 'entity_type_class'));
        }, ARRAY_FILTER_USE_BOTH);
    
      $label_map = [
        'label' => 'default',
        'label_singular' => 'singular',
        'label_plural' => 'plural',
        'label_count' => 'count' ,
        'bundle_label' => 'bundle',
        'group_label' => 'group',
      ];
    
      foreach ($label_map as $key => $labels_key) {
        if (isset($value['labels'][$labels_key])) {
          $value[$key] = $value['labels'][$labels_key];
        }
      }
    
      return new $class($values);
    

    Or maybe do the mapping before the filtering so the property order is maintained.

  • πŸ‡¬πŸ‡§United Kingdom joachim

    > It's an existing, documented property, we're not introducing it here. I agree it shouldn't be here, but having multiple attributes is not supported by our parser and I don't see an easy way to introduce that.

    What do you mean by our parser?

    Native PHP can read multiple attributes from a thing:

    $reflection->getAttributes();
    

    > Field UI would then need it's own discovery and cache and it would be an API change to any code looking for that info.

    I don't see why we can't have the entity type manager (or indeed any plugin manager) read ALL attributes from plugin classes, and merge the definitions.

  • πŸ‡¬πŸ‡§United Kingdom joachim

    Something like this would work?

    #[Attribute()]
    class PluginExtender {
    
    }
    
    
    #[Attribute()]
    class EntityType {
      public function __construct(
        public readonly string $id,
        // etc...
      ){}
    }
    
    #[Attribute()]
    #[PluginExtender()]
    class FieldableEntityType {
      public function __construct(
        public readonly string $field_admin_route,
      ){}
    }
    
    #[EntityType(
      'node',
      // etc
    )]
    #[FieldableEntityType('myroute')]
    class Node {
    
    }
    
    
  • I don't see why we can't have the entity type manager (or indeed any plugin manager) read ALL attributes from plugin classes, and merge the definitions.

    Currently attribute discovery only works with one attribute class passed from the the plugin manager, though subclasses are allowed. Adapting for multiple attribute classes would be non-trivial.

    protected function parseClass(string $class, \SplFileInfo $fileinfo): array {
        // @todo Consider performance improvements over using reflection.
        // @see https://www.drupal.org/project/drupal/issues/3395260.
        $reflection_class = new \ReflectionClass($class);
    
        $id = $content = NULL;
        if ($attributes = $reflection_class->getAttributes($this->pluginDefinitionAttributeName, \ReflectionAttribute::IS_INSTANCEOF)) {
          /** @var \Drupal\Component\Plugin\Attribute\AttributeInterface $attribute */
          $attribute = $attributes[0]->newInstance();
          $this->prepareAttributeDefinition($attribute, $class);
    
          $id = $attribute->getId();
          $content = $attribute->get();
        }
        return ['id' => $id, 'content' => $content];
      }
    

    In addition, if the idea is for something like a FieldableEntityType attribute to live in the field_ui module and not core, then when field_ui is not installed, discovery will hit fatal errors trying to instantiate ReflectionClass on a class having an attribute of an unknown class.

  • πŸ‡¬πŸ‡§United Kingdom joachim

    It doesn't crash while you're just working with class names:

    $reflection_class = new \ReflectionClass(Node::class);
    
    if ($attributes = $reflection_class->getAttributes()) {
      foreach ($attributes as $attribute) {
        $attribute_class = $attribute->getName();
    
        // Skip attribute classes from uninstalled modules.
        if (!class_exists($attribute_class)) {
          continue;
        }
    
        $attribute->newInstance();
      }
    }
    
  • πŸ‡§πŸ‡ͺBelgium kristiaanvandeneynde Antwerp, Belgium

    Regarding the $field_ui_base_route discussion: What if we move those to constants (or properties) with attributes on the entity type's class?

    We could declare those as Attribute::TARGET_CLASS_CONSTANT and only look for them in classes that are tagged with the EntityType attribute.

    E.g.:

    #[ContentEntityType(
      id: 'node',
      label: new TranslatableMarkup('Content'),
      label_collection: new TranslatableMarkup('Content'),
      // ... other stuff but not field_ui_base_route
    )]
    class Node extends EditorialContentEntityBase implements NodeInterface {
    
      #[FieldUiBaseRoute]
      public const FIELD_UI_BASE_ROUTE = 'entity.node_type.edit_form';
    
    

    Then we can do away with putting non-core properties on the EntityType attribute and immediately have a way for other modules to declare their own third-party properties on entity type definitions.

  • πŸ‡¬πŸ‡§United Kingdom joachim

    This works in AttributeClassDiscovery:

    
        // Get plugin extension attributes.
        if ($extending_attributes = $reflection_class->getAttributes(PluginExtender::class, \ReflectionAttribute::IS_INSTANCEOF)) {
          foreach ($extending_attributes as $attribute) {
            $attribute_class = $attribute->getName();
            // Attribute classes may come from modules which are not enabled, so
            // skip these.
            if (!class_exists($attribute_class)) {
              continue;
            }
    
            $attribute_properties = $attribute->getArguments();
            foreach ($attribute_properties as $name => $value) {
              if (property_exists($content, $name)) {
                throw new InvalidPluginDefinitionException("May not reuse $name.");
              }
            }
    
            // TODO: decide how to add property $name to $content plugin definition.
          }
        }
    

    What needs to be figured out is where we put 3rd party definition data on the EntityType definition object. For array definition plugins we just shove into the array! :D

  • πŸ‡¬πŸ‡§United Kingdom joachim

    Proof of concept pushed to branch 3396166-convert-entity-type-extension-annotations.

  • What needs to be figured out is where we put 3rd party definition data on the EntityType definition object. For array definition plugins we just shove into the array! :D

    Nice! Though one additional thing that needs to be solved is to delete the plugin class data from APCU file cache when modules are installed.

    That being said, I am +1 with @berdir and @longwave to getting this in as near 1:1 as possible so we can move the meta πŸ“Œ [meta] Convert all core plugin types to attribute discovery Active forward and close in on deprecation [#326594].

  • πŸ‡¦πŸ‡ΊAustralia kim.pepper πŸ„β€β™‚οΈπŸ‡¦πŸ‡ΊSydney, Australia
  • πŸ‡¬πŸ‡§United Kingdom joachim

    > Nice! Though one additional thing that needs to be solved is to delete the plugin class data from APCU file cache when modules are installed or uninstalled.

    That's probably just a call to opcache_reset() in the extension system?

    Though even without that, I don't think it matters:

    - you uninstall module Foo
    - plugins are re-discovered. Because the Foo attribute class is still in memory cache from the last discovery, Foo module's attributes are parsed and stored in the plugin discovery cache. But nothing is going to read them anyway.
    - when opcache is eventually cleared, a subsequent re-discovery won't read the Foo attributes

    I'm torn between making incremental improvements, and getting this right with attributes rather than carrying over a mess from the annotation system.

    It also opens up lots of possibilities for plugins in general - there's a long-standing issue to get Views data handling declared on field type plugins, which is exactly the same problem of component and module hierarchy. That would be fixed by this concept too.

  • That's probably just a call to opcache_reset() in the extension system?

    Though even without that, I don't think it matters:

    - you uninstall module Foo

    It'd probably have to be apcu_clear_cache(). That does reduce some of the advantage of using file cache, but modules probably aren't installed all that frequently.

    And the issue is on install (I spent a week and a half chasing down a test failure similar to this for migrate source plugins):

    • Module foo has a plugin class of a type defined in core
    • Plugin class has a plugin extender attribute defined in module bar
    • Module bar has never been installed
    • Plugin discovery picks up the plugin definition without the bar extension attribute values and stores in the definition data array in file cache
    • bar is installed, and plugin discovery picks up the plugin definition data unchanged from file cache
  • Status changed to Needs work 7 months ago
  • The Needs Review Queue Bot β†’ tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

  • Status changed to Needs review 7 months ago
  • πŸ‡³πŸ‡ΏNew Zealand quietone
  • Pipeline finished with Success
    7 months ago
    Total: 1026s
    #155425
  • Status changed to Needs work 7 months ago
  • The Needs Review Queue Bot β†’ tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

  • Pipeline finished with Success
    7 months ago
    Total: 500s
    #156513
  • Status changed to Needs review 7 months ago
  • Rebased after tour removal.

  • πŸ‡¬πŸ‡§United Kingdom catch

    I think we should be doing 1-1 conversions in the first pass, then splitting attributes in a follow-up. It will mean another layer of bc for the single-vs-multiple attribute definitions but it also means we can get off annotations quicker once core is fully converted and we start implementing deprecations for contrib. A new issue for multi-attribute-plugin-discovery would be great though.

  • πŸ‡¬πŸ‡§United Kingdom joachim

    That sounds like a good roadmap to me.

    One small problem is that I'd thought it would be good DX if supplementary attributes were not able to redeclare a property that's in the main plugin attribute:

            $attribute_properties = $attribute->getArguments();
            foreach ($attribute_properties as $name => $value) {
              if (property_exists($content, $name)) {
                throw new InvalidPluginDefinitionException("May not reuse $name.");
              }
            }
    

    If we later on want to move a property like field_ui_base_route to a supplementary attribute, we need a way to make an exception to that rule, for BC handling, because there will be a period when the property is in both the main attribute and the supplementary attribute.

    That could fairly easily be done by marking the property with an attribute to say it's expected that it does that, but it's an extra piece of complexity.

  • πŸ‡¬πŸ‡§United Kingdom joachim
  • Status changed to Needs work 6 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Seems to need a manual rebase.

  • Pipeline finished with Success
    6 months ago
    Total: 699s
    #173764
  • Status changed to Needs review 6 months ago
  • Rebased and resolved merge conflicts.

  • Status changed to RTBC 5 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Swear I reviewed and marked this one yesterday but guess it didn't save :(

    As this is approaching the 2 month mark of #needs-review-queue going to give my best shot.

    Applied the MR and verified all instances of @ConfigEntityType have been replaced.
    Reverted the change to Media.php to make sure annotation still works (it did)
    Tried to pull from reviews from other convert tickets and believe the main points have been hit.
    Appears all threads in the MR have been resolved so believe this one to be good.

  • πŸ‡³πŸ‡ΏNew Zealand quietone
  • Status changed to Needs work 4 months ago
  • The Needs Review Queue Bot β†’ tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

  • Pipeline finished with Failed
    4 months ago
    Total: 333s
    #230365
  • Pipeline finished with Success
    4 months ago
    Total: 562s
    #230402
  • Status changed to RTBC 4 months ago
  • Status changed to Needs work 4 months ago
  • The Needs Review Queue Bot β†’ tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

  • Pipeline finished with Success
    4 months ago
    Total: 651s
    #232441
  • Status changed to RTBC 4 months ago
  • Rebased again, back to RTBC.

  • Pipeline finished with Success
    4 months ago
    Total: 523s
    #233161
  • Pipeline finished with Failed
    2 months ago
    Total: 635s
    #279337
  • Pipeline finished with Failed
    2 months ago
    Total: 391s
    #279356
  • Pipeline finished with Failed
    2 months ago
    Total: 729s
    #279375
  • Status changed to Needs work 2 months ago
  • Some test failures after rebasing.

  • Pipeline finished with Success
    2 months ago
    Total: 546s
    #280772
  • Status changed to Needs review 2 months ago
  • Test fixed. Back to review to confirm changes after rebase.

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    This needs another rebase I think.

  • Pipeline finished with Success
    about 2 months ago
    Total: 3055s
    #289972
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    I pulled this down and ran the same check as @smustgrave.

    Everything seems good, and all @ContentEntityType's have been converted.

    There are still a few references in comments, should those be cleaned up if the attribute is the way to go. If this should be a follow up then I think this issue is RTBC otherwise.

    core.api.php:

    To annotate a class as a plugin, add code similar to the following to the
     * end of the documentation block immediately preceding the class declaration:
     * @code
     * * @ContentEntityType(
    

    entity.api.php:

    *   \Drupal\Core\Entity\ContentEntityBase, with annotation for
     *   \@ConfigEntityType or \@ContentEntityType in its documentation block.
    

    EntityStorageInterface.php:

     * \Drupal\Core\Config\Entity\ConfigEntityStorage for config entities. Those
     * implementations are used by default when the @ContentEntityType or
    

    Example.php.twig:

    &#10;* @ContentEntityType(&#10;
    
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Think we should address the comments here too.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Will try and keep an eye out for this one so maybe we can land it in 11.1, else believe we would have to wait for 11.2

  • Updated comments in core/lib/Drupal/Core/Entity/entity.api.php and core/lib/Drupal/Core/Entity/EntityStorageInterface.php.

    Example.php.twig

    I think this file comes from chi-teck/drupal-code-generator and not in Drupal core?

    core.api.php

    The documentation here is not specific to entity types, and the three paragraphs+ of whole topic probably need a significant rewrite. I think that should be done in a follow up, if it's not already part of the Attribute conversion meta.

  • Pipeline finished with Success
    about 2 months ago
    Total: 1423s
    #290677
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    You're right on Example PHP.

    I think it makes sense to handle core.api.php documentation in a follow up since it isn't directly about this annotation.

    I'll create a follow up issue on the parent meta issue.

    RTBC since it seems ready now!

  • First commit to issue fork.
  • The Needs Review Queue Bot β†’ tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

  • godotislate β†’ changed the visibility of the branch experimental_rebase to hidden.

  • godotislate β†’ changed the visibility of the branch 3396166-convert-entity-type-extension-annotations to hidden.

  • Pipeline finished with Success
    about 1 month ago
    Total: 353s
    #305551
  • Pipeline finished with Failed
    about 1 month ago
    Total: 139s
    #305758
  • πŸ‡³πŸ‡ΏNew Zealand quietone

    Left some suggestions for comments on the MR.

  • Pipeline finished with Success
    about 1 month ago
    Total: 564s
    #305768
  • Applied some suggested changes.

  • The Needs Review Queue Bot β†’ tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

  • Pipeline finished with Success
    12 days ago
    Total: 1111s
    #328942
  • Rebased. Put it back to RTBC since that was where it was before the bot detected the merge conflict.

  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10
  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

    There's a couple of open threads on the MR

    Pretty keen to see this in the beta

  • I believe all previous threads were addressed, but I can't resolve them because I didn't open the MR.

    Will take a look at the new threads for the config entity attributes a bit later.

  • Pipeline finished with Success
    4 days ago
    Total: 1099s
    #335876
  • Removed some unneed arguments from ConfigEntityType attribute constructor and rebased.

  • πŸ‡¬πŸ‡§United Kingdom catch

    I think I found some additional ConfigEntityType constructor arguments we don't need. We might want a follow-up to try to rationalise these anyway?

  • Pipeline finished with Failed
    3 days ago
    Total: 135s
    #336494
  • Pipeline finished with Success
    3 days ago
    Total: 646s
    #336559
  • Upstream issue fixed. Rebased and tests are green again.

    @catch, @larowlan can you clarify the follow up requests?

    I'd love to see constants or enums for these (in a follow up), magic strings lead to typos

    Is to use constants/enums for common form keys such "default" and "delete"?

    I think I found some additional ConfigEntityType constructor arguments we don't need. We might want a follow-up to try to rationalise these anyway?

    Is this to discuss restoring some properties that were removed?

  • πŸ‡¬πŸ‡§United Kingdom catch

    @godotislate no I meant checking if there's anything else like bundle_entity_type to drop. There might not be.

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    Ok I took a look, looks great!
    I see no open MR comments other than for the follow ups.

    There are two new things to do in a follow up:

    1. Update docs around annotations:
    These are in core.api.php entity.api.php and EntityStorageInterface.php that I could find.
    2. Trailing comma and bracket in these 10 files larowlan said he'd fix on commit.

    core/lib/Drupal/Core/Datetime/Entity/DateFormat.php
    core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php
    core/lib/Drupal/Core/Entity/Entity/EntityFormMode.php
    core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php
    core/lib/Drupal/Core/Entity/Entity/EntityViewMode.php
    core/modules/config/tests/config_test/src/Entity/ConfigTest.php
    core/modules/language/src/Entity/ContentLanguageSettings.php
    core/modules/media/src/Entity/Media.php
    core/modules/media/src/Entity/MediaType.php
    core/modules/menu_link_content/src/Entity/MenuLinkContent.php

    • larowlan β†’ committed e66621af on 11.1.x
      Issue #3396166 by godotislate, berdir, quietone, bbrala, joachim,...
  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

    Committed to 11.x and backported to 11.1.x, thanks all. See you in the followups.

Production build 0.71.5 2024