Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Munavijayalakshmi created an issue. See original summary.

Munavijayalakshmi’s picture

Status: Active » Needs review
FileSize
23.07 KB

Status: Needs review » Needs work

The last submitted patch, 2: deprecated_entity_manager-2856238-2.patch, failed testing.

Munavijayalakshmi’s picture

Status: Needs work » Needs review
FileSize
4.9 KB

Status: Needs review » Needs work

The last submitted patch, 4: deprecated_entity_manager-2856238-4.patch, failed testing.

Munavijayalakshmi’s picture

Status: Needs work » Needs review
FileSize
1.38 KB
Berdir’s picture

Status: Needs review » Needs work
+++ b/src/Form/PrepareUninstallForm.php
@@ -64,7 +64,7 @@ class PrepareUninstallForm extends FormBase {
    */
   public static function deleteSubscribers(&$context) {
     $subscriber_ids = \Drupal::entityQuery('simplenews_subscriber')->range(0, 100)->execute();
-    $storage = \Drupal::entityManager()->getStorage('simplenews_subscriber');
+    $storage = \Drupal::entityTypeManager()->getStorage('simplenews_subscriber');
     if ($subscribers = $storage->loadMultiple($subscriber_ids)) {
       $storage->delete($subscribers);

both examples use an entity query, lets also combine converting the usage of this to use $storage->getQuery().

We could also properly inject the dependency.

Munavijayalakshmi’s picture

Assigned: Munavijayalakshmi » Unassigned
jonathanshaw’s picture

jonathanshaw’s picture

Category: Bug report » Task
Priority: Normal » Minor
subson’s picture

Status: Needs work » Needs review
FileSize
1.62 KB

Re-rolling the patch as suggested by Berdir in #7 to use $storage->getQuery().

I tried to pass entityTypeManager as dependency in the PrepareUninstallForm.php, but getting this error -
"Error: Using $this when not in object context in ... " I guess because deleteSubscribers and removeFields is running as a batch process.

Let me know if there is a way to pass dependency in a batch process without using \Drupal::entityTypeManager().

  • Berdir committed 683b587 on 8.x-1.x authored by subson
    Issue #2856238 by Munavijayalakshmi, subson: Replace all usages of...
Berdir’s picture

Status: Needs review » Fixed

Thanks.

Agreed, these are static methods, we can't inject there.

Status: Fixed » Closed (fixed)

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