Part of #2886622: Deprecate all EntityManager methods with E_USER_DEPRECATED, this covers the methods that moved to EntityTypeBundleInfo: getAllBundleInfo(), getBundleInfo(), clearCachedBundles().

The largest chunk here is the ContentEntityStorageBase class including many of its children, specifically SqlContentEntityStorage + Schema class and unit tests for these, those are fully updated to remove the entity_manager dependency.

The other changes are standard replacements, there is one form class that has a new constructor and one that changes it from $entity_manager which was actually pretty bogus as the parent has $this->entityManager set already.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir created an issue. See original summary.

Berdir’s picture

So this is the gets ContentEntityStorageBase and subclasses, but actually expected much worse, not that many services actually used there, just order is a bit weird/tricky I think. And the Schema sub-handler.

DefaultSelection and subclasses are skipped, those are handled by #3023981: Add @trigger_error() to deprecated EntityManager->EntityRepository methods, lets see if I got everything else.

Status: Needs review » Needs work

The last submitted patch, 2: entity-manager-bundle-methods-3025427-2.patch, failed testing. View results

Berdir’s picture

This should fix a good amount of test fails, mostly down to deprecations from the selection handlers if I'm lucky.

Status: Needs review » Needs work

The last submitted patch, 4: entity-manager-bundle-methods-3025427-4.patch, failed testing. View results

Berdir’s picture

Status: Needs work » Needs review

#3023981: Add @trigger_error() to deprecated EntityManager->EntityRepository methods is in, that means this should have a *lot* less failures, triggered a re-test. Will finalize then and update the deprecation messages.

Status: Needs review » Needs work

The last submitted patch, 4: entity-manager-bundle-methods-3025427-4.patch, failed testing. View results

Berdir’s picture

Needed a reroll anyway and the other change was not actually pushed yet. I also saw that a rename went sideways and renamed $this->entityManager in a lot of forms, this should clean that up again.

Also added deprecation tests.

Status: Needs review » Needs work

The last submitted patch, 8: entity-manager-bundle-methods-3025427-8.patch, failed testing. View results

Berdir’s picture

Fixing a few of the obvious issues, this should be better.

Berdir’s picture

+++ b/core/modules/field_ui/src/Form/FieldConfigEditForm.php
@@ -26,6 +28,32 @@ class FieldConfigEditForm extends EntityForm {
+  /**
+   * Constructs a new FieldConfigDeleteForm object.
+   *

classname here is wrong, will fix on the next update.

amateescu’s picture

  1. +++ b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php
    @@ -49,18 +63,25 @@ abstract class ContentEntityStorageBase extends EntityStorageBase implements Con
    +      @trigger_error('Calling ContentEntityStorageBase::__construct() with the $entity_type_bundle_info argument is supported in drupal:8.7.0 and will be required before drupal:9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
    

    Is drupal:x.y.z a new standard for deprecation messages?

  2. +++ b/core/lib/Drupal/Core/Entity/EntityManager.php
    @@ -313,6 +313,7 @@ public function clearCachedFieldDefinitions() {
    +    @trigger_error('EntityManagerInterface::clearCachedBundles() is deprecated in 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\Entity\EntityTypeBundleInfoInterface::clearCachedBundles() instead. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
    
    @@ -326,6 +327,7 @@ public function clearCachedBundles() {
    +    @trigger_error('EntityManagerInterface::getBundleInfo() is deprecated in 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\Entity\EntityTypeBundleInfoInterface::getBundleInfo() instead. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
    
    @@ -339,6 +341,7 @@ public function getBundleInfo($entity_type_id) {
    +    @trigger_error('EntityManagerInterface::getAllBundleInfo() is deprecated in 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\Entity\EntityTypeBundleInfoInterface::getAllBundleInfo() instead. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
    

    If it is, it's not applied consistently.. :) We should at least have "Drupal" before 8.0.0.

  3. +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php
    @@ -31,13 +34,26 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage
       use SqlFieldableEntityTypeListenerTrait {
    ...
    +  use DeprecatedServicePropertyTrait;
    

    Minor: we could move the new trait use statement above the first one.

Everything else looks great to :)

Berdir’s picture

Standardized the deprecation messages in EntityManager and EntityManagerTest.

amateescu’s picture

Status: Needs review » Reviewed & tested by the community

Great!

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 81915a9 and pushed to 8.7.x. Thanks!

  • alexpott committed 81915a9 on 8.7.x
    Issue #3025427 by Berdir, amateescu: Add @trigger_error() to deprecated...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.