After drupal 8.6 update the table 'taxonomy_term_hierarchy' has been moved to taxonomy_term__parent. So I have following error when access the content type with the module.

"Base table or view not found: 1146 Table 'drupal.taxonomy_term_hierarchy' doesn't exist"

The patch "2996263-6.patch" is created using tag 8.x-1.0-alpha2 for compatibility with ^1.0@alpha version.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gabrielolferrari created an issue. See original summary.

gabrielolferrari’s picture

gabrielolferrari’s picture

gabrielolferrari’s picture

gabrielolferrari’s picture

gabrielolferrari’s picture

Add fix version to tag 8.x-1.0-alpha2

gabrielolferrari’s picture

Issue summary: View changes
perpignan’s picture

Same issue on line 407 of term_reference_tree.module :

i've change the query by :

function _term_reference_tree_get_parent($tid) {
  $q = db_query_range("SELECT h.parent_target_id FROM {taxonomy_term__parent} h WHERE h.entity_id = :tid", 0, 1, [':tid' => $tid]);
  $t = 0;
  foreach ($q as $term) {
    $t = $term->parent_target_id;
  }
  return $t;
}
mark_fullmer’s picture

Here's a patch that catches all of the instances needing updating, based on 8.x-1.x-dev.

Kgaut’s picture

I can confirm that the patch in #9 fix the error ! Thanks a lot.

jedihe’s picture

Patch #9 also works for me. The node edit form for a node type using the term reference tree widget was not loading after I updated core to 8.6.1; just applied the patch, and it's back to working.

Thanks @gabrielolferrari, @perpignan and @mark_fullmer!

VladimirAus’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
3.87 KB

Thanks for your work @gabrielolferrari, @perpignan and @mark_fullmer!

Adding some linting, refactoring and requirements.

RedEight’s picture

I can confirm that #12 fixed my issue. Thanks everyone.

igonzalez’s picture

#12 works for me

kyuubi’s picture

Works like a charm!
Let's get this committed please?

VladimirAus’s picture

Happy to become co maintainer.

Ollibolli’s picture

Hi guys, great to see this fixed. But i think you missed a line at the '_term_reference_tree_get_parent' function.

Over here this made it work again:

function _term_reference_tree_get_parent($tid) {
  $query = "SELECT parent_target_id FROM {taxonomy_term__parent} p WHERE entity_id = :tid";

Sorry for not submitting a patch file to this instead of posting code lines. This only applies to Drupal >= 8.6.0.

All the best

eyilmaz’s picture

Adding the addition by Ollibolli.

rik_deuzeman’s picture

#18 isn't working.

$query = "SELECT h.parent_target_id FROM {taxonomy_term__parent} p WHERE p.entity_id = :tid";
should be
$query = "SELECT p.parent_target_id FROM {taxonomy_term__parent} p WHERE p.entity_id = :tid";

eyilmaz’s picture

Hi @rik_deuzeman.
Thanks for review, you are right, there is a critical typo :).
Here is the updated patch.

superlolo95’s picture

+1 for the patch with drupal 6.2

abellata’s picture

#20 isnt working for my 8.6.2 drupal (your git diff lines aren't matching mine)

EDIT: THE PATCH WORRKING but i couldnt use git apply to apply it.

dqd’s picture

simplytest.me with patch linked me to > Drupal 8.6.2 with patch applied via Dreditor. (Mayby patch needs reroll against Drupal core 8.6.3)

  • Before patch: WSOD when trying to add nodes with TRT enabled for form. Report has shown SQL errors with table not found.
  • After patch: simplytest.me worked. I was able to add new nodes.

RTBC from me so far without closer code review or nitpicks ...

SIDE NOTE: I kind of feel that this module uses wrong and very heavy sql querying which should be changed ...

kimberleycgm’s picture

Patch in #20 is working well for me

knyshuk.vova’s picture

The patch #20 looks good and applies successfully. +1 for RTBC.

mfrosch’s picture

#20 also works for me - please commit.

saurabh29p’s picture

#20 partially applied.

In term_reference_tree.info.yml,
core: 8.x should be # core: 8.x

pifagor’s picture

Look good

  • alex_optim committed 65a0ecc on 8.x-1.x
    Issue #2996263 by eyilmaz, alex_optim: Taxonomy term hierarchy table...
alex_optim’s picture

Assigned: gabrielolferrari » Unassigned
Status: Reviewed & tested by the community » Patch (to be ported)
alex_optim’s picture

Status: Patch (to be ported) » Fixed

Status: Fixed » Closed (fixed)

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

aadeshvermaster@gmail.com’s picture

Patch #20 is working for me for Drupal core - 8.7.3 & Taxonomy Term Reference Tree Widget - 8.x-1.0-alpha2

harshadananjaya’s picture

patch #20 is working for me.

krug’s picture

Patch #20 solved the error after migration drupal 7.54 to 8.7.6
Drupal core - 8.7.6 (nginx/1.6.2 PHP 7.2.2 MySQL 5.5.54) & Term Reference Tree - 8.x-1.0-alpha2

Error:
Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'DBname.prefix_taxonomy_term_hierarchy' doesn't exist: SELECT h.parent FROM {taxonomy_term_hierarchy} h WHERE h.tid = :tid LIMIT 0, 1; Array ( [:tid] => 1303 ) in _term_reference_tree_get_parent() (line 408 of /var/www/clients/client22/web147/web/modules/term_reference_tree/term_reference_tree.module).

texas-bronius’s picture

Heads up, patchers - See module maintainer's message in #31: This patch has been RBTC and committed to the dev release. Confirmed working with latest 8.x-1.x-dev release for 3 months.

tetem’s picture

+1 for the Patch #20. It solved the error after migration drupal 8.5.15 to 8.7.8.
Thanks.

laura.gates’s picture

+1 for the patch #20 it solved some DB issues going from 8.7.9 to 8.8.0 rc1

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'drupal.taxonomy_term_hierarchy' doesn't exist: SELECT t.tid AS tid, t.name AS name, t.vid AS vocabulary_machine_name FROM {taxonomy_term_field_data} t INNER JOIN {taxonomy_term_hierarchy} h ON t.tid = h.tid WHERE (t.vid = :db_condition_placeholder_0) AND (h.parent = :db_condition_placeholder_1) ORDER BY t.weight ASC, t.name ASC; Array ( [:db_condition_placeholder_0] => [your taxonomy here] [:db_condition_placeholder_1] => 0 ) in _term_reference_tree_get_children() (line 218 of modules/contrib/term_reference_tree/term_reference_tree.module).