taxonomy_check_vocabulary_hierarchy() is horribly inefficient as it calls taxonomy_get_tree() in order to check the parents.

Also, it seems that the only reason $changed_term is needed is because of the static caching in taxonomy_get_tree().

The job taxonomy_check_vocabulary_hierarchy() could be better solved by a couple of queries, which would also remove the need for $changed_term.

Patch coming up...

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gielfeldt’s picture

Status: Active » Needs review
FileSize
4.85 KB
c960657’s picture

This is a great improvement.

+    ->condition('h.parent', 0, '>')

I wonder if it is better/more efficient to use '<>' here?

A few style issues:

The naming of $has_parents and $multiple_parents is inconsistent wrt the has_ prefix.

First the variables $has_parents and $multiple_parents contain a query object, but then they are overwritten by the result of the query. Reusing variables in this way is not good for readability.

gielfeldt’s picture

Status: Needs review » Needs work

I wonder if it is better/more efficient to use '<>' here?

Can't say if it makes a difference, but I guess it can't hurt to be as explicit as possible to the db-engine.

The naming of $has_parents and $multiple_parents is inconsistent wrt the has_ prefix.

First the variables $has_parents and $multiple_parents contain a query object, but then they are overwritten by the result of the query. Reusing variables in this way is not good for readability.

Of course. A bit sloppy :-). I'll fix.

alchemist_ua’s picture

Version: 8.x-dev » 6.x-dev
FileSize
3.33 KB

Here it is the backport of this to drupal 6.x.

alchemist_ua’s picture

Status: Needs work » Needs review
alchemist_ua’s picture

Version: 6.x-dev » 8.x-dev
Status: Needs review » Needs work
klonos’s picture

Issue tags: +Needs backport to D6
gielfeldt’s picture

Yes, this issue is also relevant for D7.

klonos’s picture

Issue tags: +Needs backport to D7

...thought so ;)

gielfeldt’s picture

Anybody interested in fixing the point mentioned in #3 ?

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

p-neyens’s picture

Version: 8.4.x-dev » 7.x-dev
Issue summary: View changes
Status: Needs work » Needs review
FileSize
3.66 KB

Backport for D7.