We are having an issue where if you install the taxonomy module after installing this module, it causes a fatal that says.

 PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'cedi.taxonomy_vocabulary' doesn't exist: SELECT name, machine_name, vid FROM {taxonomy_vocabulary}; Array ( ) in taxonomy_vocabulary_get_names() (line 991 of /var/www/cedi/docroot/modules/taxonomy/taxonomy.module).

After debugging, this problem, we identified that the problem exists in the feeds/feeds.plugins.inc file where you are calling entity_get_info() which causes major errors when installing other modules.

After debugging, it was determined what is actually happening is a race condition where the taxonomy modules schema is not installed when this function is called, but registers as an enabled module thus calling the taxonomy's function taxonomy_entity_info() before it's schema is installed.

This happens because of the nature of how module_enable() works. When you call this function, it goes through the following process...

      system_list_reset();
      module_list(TRUE);
      module_implements('', FALSE, TRUE);
      _system_update_bootstrap_status();
      registry_update();
      drupal_get_schema(NULL, TRUE);
      drupal_theme_rebuild();
      entity_info_cache_clear();
      drupal_install_schema($module);

The CTools plugin handler is actually rebuilt during the 'registry update' section... However, the schema of a module doesn't get installed until after that... Like so...

      ...
      module_list(TRUE);  <----- (a)
      ...
      ...
      registry_update();    <----- (b)
      ...
      ...
      drupal_install_schema($module); <----- (c)
  • (a) - Module is flagged as 'enabled' so 'module_exists' for this module will now return TRUE.
  • (b) - This is what calls ctools_get_plugins, which you guys then call entity_get_info() which then calls taxonomy_entity_info which assumes schema is installed and fatals when it is not.
  • (c) - This is where the schema is actually installed.

So, with that said... I believe we have an issue with the latest version of this file where entity_get_info was called.

I will try to work out a patch for the fix, but may need some help from the person who introduced this change.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

travist’s picture

Issue summary: View changes
travist’s picture

Issue summary: View changes
travist’s picture

travist’s picture

Status: Active » Needs review
FileSize
1.38 KB

Ok, here is the patch that I came up with that fixes this problem. Basically what you need to do is cache the entity_get_info so that when module_enable is called, it is referring to a previously cached version of the results instead of the live version which breaks modules that require their schema.

dsnopek’s picture

Status: Needs review » Reviewed & tested by the community

+1! Thanks so much for this!

I tested this with Open Atrium 2.15, and it fixes this fatal error which previously occurred during install: #2206223: Table 'sitename.taxonomy_vocabulary' doesn't exist

mpotter’s picture

+1 to this. I was pulling my hair out trying to track down this problem. Thanks very much for the patch. Works great for me also.

travist’s picture

Here is an updated patch that fixes the error when the cache returns NULL and it tries to iterate over NULL.

travist’s picture

Status: Reviewed & tested by the community » Needs review

The new patch needs review.

travist’s picture

MegaChriz’s picture

Issue tags: +Needs tests

I wasn't able to reproduce this bug using a clean install. What I had done:

  1. Installed website using the Minimal profile.
  2. Enabled modules Feeds, Feeds Admin UI, Entity API.
  3. Enabled module Taxonomy.

I tested with PHP 5.4.22.

This needs an automated test. The test should confirm the bug is there without the proposed fix applied and be gone with the proposed fix applied.

dsnopek’s picture

This can only be reproduced with an install profile that installs both Feeds and Taxonomy - everything works fine when you install Feeds and Taxonomy after install. This was reproducible in many environments (but not all - since in some cases the installer would install Taxonomy first and then Feeds) with Open Atrium 2.15.

twistor’s picture

Status: Needs review » Needs work

Can someone provide or link to an installation profile that is causing this issue? It's ok it we don't have a test, but it needs to be tested manually. It also needs documentation in the comment above the hack.

I don't really like the hook_init() approach, that seems like overkill. I would rather not execute code on every request that will be used in such a limited scope. Can we just check if the table exists inside the foreach (entity_get_info() as $type => $entity_info)?

dsnopek’s picture

@twistor: I've been able to reproduce it reliably with Open Atrium 2.15 (later versions are using the patch here) and XAMPP 1.8.3 on Windows 7. Unfortunately, the order the modules are installed is strangely environment specific. I've been unable to recreate this on Debian Squeeze or CentOS 5.10 using the default stack. You can see this issue on Open Atrium for the full hairy history of attempting to reproduce this: #2206223: Table 'sitename.taxonomy_vocabulary' doesn't exist

And, yes, I think checking if the table exists would be a perfectly fine alternative to doing hook_init().

Please let me know if you need any more info!

twistor’s picture

Project: Feeds » Feeds entity processor
Version: 7.x-2.x-dev » 7.x-1.x-dev

We've moved the entity processor.