Problem/Motivation

The entity.manager service (which returns an EntityManager that implements EntityManagerInterface) was deprecated in Drupal 8.0.x and "will be removed before 9.0.0".

We should remove it before that happens.

Proposed resolution

Fix this.

As of commit b222273 (the HEAD of 8.x-2.x as of 2018-02-16), all of the code passes around and/or type-hints the (supported) EntityTypeManagerInterface objects, but still requests the (deprecated) entity.manager services in auto_entitylabel.services.yml and various objects' public static function create(...) methods, so fixing this is, at minimum, a case of just changing the requested service name.

Even though it's not strictly necessary, for consistency (and following the precedent set in the patch in #6) this patch should rename the class properties which referenced the service (from $entityManager to $entityTypeManager).

Remaining tasks

  1. Write a patch
  2. Re-roll patch
  3. Review and feedback
  4. RTCB and maintainer feedback
  5. Commit

User interface changes

None.

API changes

This module's API doesn't change.

Data model changes

None.

Original report by [username]

EntityManager has been split into 11 classes (more info). So now EntityManager and EntityManagerInterface are deprecated.

Comments

Pavan B S created an issue. See original summary.

Pavan B S’s picture

Status: Active » Needs review
StatusFileSize
new8.34 KB

Applying the patch, please check

Pavan B S’s picture

Assigned: Pavan B S » Unassigned
sutharsan’s picture

Status: Needs review » Needs work

Thank you for taking care of this. Better sooner than later. One comment though:

+++ b/src/AutoEntityLabelPermissionController.php
@@ -25,23 +25,22 @@ class AutoEntityLabelPermissionController implements ContainerInjectionInterface
-  protected $entityManager;
-
+  protected $entityTypeManager;
   /**

Restore this white space.

Pavan B S’s picture

Assigned: Unassigned » Pavan B S

Thank you for the comment, i will be working on that issue.

Pavan B S’s picture

Assigned: Pavan B S » Unassigned
Status: Needs work » Needs review
StatusFileSize
new8.43 KB
new400 bytes

Changed as per the suggestion

dhruveshdtripathi’s picture

Status: Needs review » Reviewed & tested by the community

Changes applied cleanly.

purushotam.rai’s picture

Assigned: Unassigned » purushotam.rai
Status: Reviewed & tested by the community » Patch (to be ported)

LGTM

purushotam.rai’s picture

Assigned: purushotam.rai » Unassigned
Status: Patch (to be ported) » Needs work

Patch needs to be rerolled.

mparker17’s picture

Status: Needs work » Needs review
StatusFileSize
new8.88 KB

The code in the 8.x-2.x branch has changed significantly in the last 11 months (i.e.: since #6), and when I tried to re-roll the patch, I got merge conflicts in every file, and there was even a deleted file!

So, to make sure I didn't miss anything, I re-created the patch from scratch (grepping for the service name entity.manager and working from there). Since I didn't start from previous work, I can't generate an interdiff; sorry!

mparker17’s picture

Issue summary: View changes

Updated the issue summary.

nkoporec’s picture

Hi, tested the patch it applies cleanly but there's error when you try to add a node with auto entity enabled.Recreated your patch with a fix.

mparker17’s picture

@nkoporec, thanks! :)

maaty388’s picture

I rerolled the patch because Controller was removed.

nkoporec’s picture

Status: Needs review » Reviewed & tested by the community

Tested your patch @matjaz_zavski and it's working as expected.Thanks for the re-roll.Marking as RTBC.

colan’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new1.44 KB

Here's the missing interdiff from #14. (Always provide these when uploading patches when there are already patches. See Creating an interdiff for details.)

This looks wrong, or am I missing something? entityManager is being added back in.

diff -u b/src/Form/AutoEntityLabelForm.php b/src/Form/AutoEntityLabelForm.php
--- b/src/Form/AutoEntityLabelForm.php
+++ b/src/Form/AutoEntityLabelForm.php
@@ -257,7 +257,7 @@
     }
 
     /** @var \Drupal\Core\Config\Entity\ConfigEntityStorage $storage */
-    $storage = $this->entityTypeManager->getStorage($this->entityType);
+    $storage = $this->entityManager->getStorage($this->entityType);
     /** @var \Drupal\Core\Config\Entity\ConfigEntityType $entity_type */
     $entity_type = $storage->getEntityType();
     $prefix = $entity_type->getConfigPrefix();
colan’s picture

Version: 8.x-2.x-dev » 8.x-3.x-dev
bcizej’s picture

StatusFileSize
new9.67 KB
new5.12 KB

Rerolled the patch, reviewed the code and replaced variable namings from $entity_manager to $entity_type_manager.

bcizej’s picture

Status: Needs work » Needs review
sutharsan’s picture

Status: Needs review » Needs work

Param description missing at various points.

  1. +++ b/src/AutoEntityLabelPermissionController.php
    @@ -19,23 +19,22 @@ class AutoEntityLabelPermissionController implements ContainerInjectionInterface
    -   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_manager
    -   *   The entity manager.
    +   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
    

    New param description is missing.

  2. +++ b/src/Form/AutoEntityLabelForm.php
    @@ -82,8 +87,7 @@ class AutoEntityLabelForm extends ConfigFormBase {
    -   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_manager
    -   *   Entity Manager.
    +   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
    

    New param description is missing.

  3. +++ b/src/Plugin/Derivative/AutoEntityLabelConfigTask.php
    @@ -19,16 +19,15 @@ class AutoEntityLabelConfigTask extends DeriverBase implements ContainerDeriverI
    -   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_manager
    -   *   The entity manager.
    +   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
        */
    

    See above. Looks like a pattern ...

  4. +++ b/src/Routing/RouteEnhancer.php
    @@ -21,16 +21,15 @@ class RouteEnhancer implements EnhancerInterface {
    -   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_manager
    -   *   The entity manager.
    +   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
        */
    

    See above

kbrodej’s picture

StatusFileSize
new10.42 KB
new2.88 KB

Reviewed and tested the patch from #19, fixed some minor CS issue.

kbrodej’s picture

Status: Needs work » Needs review
sutharsan’s picture

After applying the patch I still find a number of "entity manager" string in the code.

One minor remark on the interdiff:

+++ b/src/Form/AutoEntityLabelForm.php
@@ -221,7 +222,8 @@
-        // #states needs a container to work, so put the token replacement link inside one.
+        // States needs a container to work,
+        // so put the token replacement link inside one.
         '#type' => 'container',

Usually comment lines are filled upto 80 chars. Although I can't find this in the docs https://www.drupal.org/docs/develop/standards/api-documentation-and-comm....

General remark: please keep patches on-topic. Combining various changes in one patch makes accepting the patch hard. I know the itch of finding other things in the code that needs to be addressed. Fixing them in a separate issue is, in the long term, usually the best.

kbrodej’s picture

StatusFileSize
new10.17 KB
new3.31 KB

Hi. Reverted the change pointed out in #23 and replaced "entity manager" with "entity type manager" from comments as well.

sutharsan’s picture

Status: Needs review » Reviewed & tested by the community

@kbrodej, thanks for sticking with the issue.

No more comments.

berdir’s picture

There's also the more general D9 issue over here: #3111526: Add Drupal 9 into the require section of composer.json. Considering that this project isn't very actively maintained, it might make sense to take care of all poblems in a single issue including the .info.yml change. Then the maintainer will only have to commit a single patch to make the module ready and spend a minimal amount of time on it.

It looks like there are no tests yet here, so it probably makes sense to do some manual testing then against a D9 installation because static analysis does not find all problems.

dqd’s picture

Considering that this project isn't very actively maintained

Well, not exactly true ... I can't speak for myself since I have been added here quite recently to help out, but to stand up for the initial maintainers of this project: I assume the reasons for the temporary minimal activity has to do with the core label field initiative and the understandable plan to wait for to know which route to go with AEL after/if that gets in core. Many use cases for this project were based on the inflexibility of core title/label field, what maybe will change over the next time soon and could make a discussion about the AEL features in D9 cycle useful before any other tasks. For all who are following auto entitylabel to circumvent the title field, please also have a look into the momentary discussions about that in core.

/web/modules/contrib/auto_entitylabel$ git apply -v 2856225-23.patch
Checking patch auto_entitylabel.services.yml...
Checking patch src/AutoEntityLabelPermissionController.php...
Checking patch src/Form/AutoEntityLabelForm.php...
Checking patch src/Plugin/Derivative/AutoEntityLabelConfigTask.php...
Checking patch src/Routing/RouteEnhancer.php...
Checking patch src/Routing/RouteSubscriber.php...
Applied patch auto_entitylabel.services.yml cleanly.
Applied patch src/AutoEntityLabelPermissionController.php cleanly.
Applied patch src/Form/AutoEntityLabelForm.php cleanly.
Applied patch src/Plugin/Derivative/AutoEntityLabelConfigTask.php cleanly.
Applied patch src/Routing/RouteEnhancer.php cleanly.
Applied patch src/Routing/RouteSubscriber.php cleanly.

@kbrodej, Pavan B S, nkoporec, benjamincizej, mparker17, colan, maaty388: Thanks for working and keeping up on this!

  • diqidoq committed c332a41 on 8.x-3.x authored by kbrodej
    Issue #2856225 by kbrodej, Pavan B S, nkoporec, benjamincizej, mparker17...
dqd’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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