Comments

temoor’s picture

Title: Replace all instances of taxonomy_term_load(), taxonomy_term_load_multiple(), entity_load('taxonomy_term') and entity_load_multiple('taxonomy_term') with static method calls » Replace all instances of taxonomy_term_load(), entity_load('taxonomy_term') and entity_load_multiple('taxonomy_term') with static method calls
Status: Active » Needs review
Related issues: +#2010138: Remove taxonomy_term_load_multiple() in favour of \Drupal\taxonomy\Entity\Term::loadMultiple().
StatusFileSize
new11.72 KB

taxonomy_term_load_multiple() have separate task #2010138: Remove taxonomy_term_load_multiple() in favour of \Drupal\taxonomy\Entity\Term::loadMultiple(). , so isn't included in patch.

Michael Hodge Jr’s picture

Status: Needs review » Reviewed & tested by the community

As with the other issues similar to this, i've applied the patch, grepped the code and can confirm everything looks good.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/modules/taxonomy/src/Plugin/Field/FieldWidget/TaxonomyAutocompleteWidget.php
    @@ -10,6 +10,7 @@
    +use Drupal\taxonomy\Entity\Term;
    
    @@ -74,7 +75,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
    -        $tags[] = isset($item->entity) ? $item->entity : entity_load('taxonomy_term', $item->target_id);
    +        $tags[] = isset($item->entity) ? $item->entity : Term::load($item->target_id);
    

    We should be injecting the storage here. The plugin needs to implement ContainerFactoryPluginInterface

  2. +++ b/core/modules/taxonomy/src/Plugin/views/argument/IndexTidDepth.php
    @@ -10,6 +10,7 @@
    +use Drupal\taxonomy\Entity\Term;
    
    @@ -113,7 +114,7 @@ public function query($group_by = FALSE) {
    -    $term = entity_load('taxonomy_term', $this->argument);
    +    $term = Term::load($this->argument);
    

    As above

  3. +++ b/core/modules/taxonomy/src/Plugin/views/argument/Taxonomy.php
    @@ -9,6 +9,7 @@
    +use Drupal\taxonomy\Entity\Term;
    
    @@ -25,7 +26,7 @@ class Taxonomy extends Numeric {
    -      $term = entity_load('taxonomy_term', $this->argument);
    +      $term = Term::load($this->argument);
    

    As above

ashutoshsngh’s picture

Status: Needs work » Needs review
StatusFileSize
new11.8 KB

Find attached with changes mentioned above.

Status: Needs review » Needs work

The last submitted patch, 4: drupal8-entity_system-taxonomy-term-load-2322067-2.patch, failed testing.

ashutoshsngh’s picture

Status: Needs work » Needs review
StatusFileSize
new12.22 KB
emclaughlin’s picture

Looks good to me! Nothing is obviously broken that I could find after applying it.

temoor’s picture

Status: Needs review » Needs work
Issue tags: -

But there's no difference between patches in #1 and #6, or am I missing something?

Edit:
Actually it fixes this missed call

diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module
index e5f8bd7..c8c4797 100644
--- a/core/modules/taxonomy/taxonomy.module
+++ b/core/modules/taxonomy/taxonomy.module
@@ -259,7 +259,7 @@ function taxonomy_term_view(Term $term, $view_mode = 'full', $langcode = NULL) {
  * Constructs a drupal_render() style array from an array of loaded terms.
  *
  * @param array $terms
- *   An array of taxonomy terms as returned by entity_load_multiple('taxonomy_term').
+ *   An array of taxonomy terms as returned by Term::loadMultiple().
  * @param string $view_mode
  *   View mode, e.g. 'full', 'teaser'...
  * @param string $langcode

But there are no changes regarding #3

temoor’s picture

Status: Needs work » Needs review
StatusFileSize
new15.83 KB
new6.95 KB

Added changes according to #3

roderik’s picture

Issue summary: View changes
Issue tags: +Amsterdam2014

Tagging for Amsterdam. This is for an experienced PHP coder but novice contributor. While reviewing / checking if this still covers all calls, you will learn about Drupal's dependency injection with a practical example (which is this patch). If you set this is RTBC, feel free to comment about how and why you came to the conclusion.

finn lewis’s picture

I will start reviewing the patch and ensure that it fixes the issue. (at the code sprint in Amsterdam)

finn lewis’s picture

Patch fails to apply against current D8 core head.
I'll see if I can re-roll and test.

finn lewis’s picture

It looks like core taxonomy.module code has moved on since 27th August, for example,

taxonomy_term_load_parents() is now

function taxonomy_term_load_parents($tid) {
  return \Drupal::entityManager()->getStorage('taxonomy_term')->loadParents($tid);
}

so my (possibly incorrect) assumption is that the changes in the original patch to the taxonomy.module file are no longer required.

it looks like the new line returns the parents without calling Term::loadMultiple($tids).

I am now running the taxonomy tests locally and hope to post a re-rolled patch shortly.

finn lewis’s picture

I have rerolled the patch from #9 above, removing the changes to taxonomy.module functions as mentioned in #13.

I have run the tests for the taxonomy suite under Drupal\taxonomy\Tests and all the tests pass apart from one.

The test that fails is Drupal\taxonomy\Tests\TaxonomyImageTest and this also appears to fail on vanilla Drupal 8 install, so I think this is not directly caused by this patch.

Rerolled patch attached.

jsobiecki’s picture

I'm working on review of that issue.

finn lewis’s picture

Just added related issue of the failing Drupal\taxonomy\Tests\TaxonomyImageTest. I don't think this issue is causing that, but it may be related, and I prevents the whole suite of taxonomy tests from running.

jsobiecki’s picture

I don't confirm problem with test. On my local dev mentioned test went fine, so I think it's a matter of local env. From review perspective - it looks ok. All function calls were removed. Funtction was left, with @deprecated flag, so it's seem to be OK. Unit tests are all green, we are waiting for testbot results.

finn lewis’s picture

The patch in #14 passed the tests, suggesting that my related issue of failing Drupal\taxonomy\Tests\TaxonomyImageTest is a local issue.

roderik’s picture

@finn.lewis / #13: agreed.

I just found an issue in the patch where it reverts $GLOBALS (recently changed) back to $_SESSION.

If you can review and you're OK with it, you can set status RTBC :)

finn lewis’s picture

@roderik, thanks, I will review today and confirm.

finn lewis’s picture

The Patch in #19 applies cleanly to current HEAD and interdiff looks sound. I've also confirmed that the taxonomy tests still pass, but I guess that's what the test bots are for!
Setting RTBC as advised by roderik in #19.

finn lewis’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 1308c59 and pushed to 8.0.x. Thanks!

  • alexpott committed 1308c59 on
    Issue #2322067 by Temoor, ashutoshsngh, roderik, finn.lewis: Replace all...

Status: Fixed » Closed (fixed)

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