drush -y en data_ui
The following extensions will be enabled: data_ui, data
Do you really want to continue? (y/n): y
PHP Fatal error:  Call to undefined function data_get_all_tables() in /sites/all/modules/contrib/data/data.install on line 78
PHP Stack trace:
PHP   1. {main}() /usr/local/Cellar/drush/HEAD/libexec/drush.php:0
PHP   2. drush_main() /usr/local/Cellar/drush/HEAD/libexec/drush.php:16
PHP   3. _drush_bootstrap_and_dispatch() /usr/local/Cellar/drush/HEAD/libexec/drush.php:61
PHP   4. drush_dispatch() /usr/local/Cellar/drush/HEAD/libexec/drush.php:92
PHP   5. call_user_func_array:{/usr/local/Cellar/drush/HEAD/libexec/includes/command.inc:182}() /usr/local/Cellar/drush/HEAD/libexec/includes/command.inc:182
PHP   6. drush_command() /usr/local/Cellar/drush/HEAD/libexec/includes/command.inc:182
PHP   7. _drush_invoke_hooks() /usr/local/Cellar/drush/HEAD/libexec/includes/command.inc:214
PHP   8. call_user_func_array:{/usr/local/Cellar/drush/HEAD/libexec/includes/command.inc:362}() /usr/local/Cellar/drush/HEAD/libexec/includes/command.inc:362
PHP   9. drush_pm_enable() /usr/local/Cellar/drush/HEAD/libexec/includes/command.inc:362
PHP  10. drush_module_enable() /usr/local/Cellar/drush/HEAD/libexec/commands/pm/pm.drush.inc:1013
PHP  11. module_enable() /usr/local/Cellar/drush/HEAD/libexec/commands/core/drupal/environment_7.inc:143
PHP  12. module_invoke() /includes/module.inc:477
PHP  13. call_user_func_array:{/includes/module.inc:866}() /includes/module.inc:866
PHP  14. data_install() /includes/module.inc:866
PHP  15. drupal_get_schema() /sites/all/modules/contrib/data/data.install:106
PHP  16. drupal_get_complete_schema() /includes/bootstrap.inc:2985
PHP  17. drupal_alter() /includes/bootstrap.inc:3072
PHP  18. data_schema_alter() /includes/module.inc:1101

Comments

mrded’s picture

Version: 7.x-1.0-alpha6 » 7.x-1.x-dev
maxilein’s picture

Got the same error here:

An AJAX HTTP error occurred. HTTP Result Code: 200 Debugging information follows. Path: http://..../update.php?op=selection&token=TBsomethingQ&id=588&op=do StatusText: OK ResponseText: Fatal error: Call to undefined function data_get_all_tables() in /var/www/default/web/content/sites/all/modules/data/data_entity/data_entity.install on line 12 Call Stack: 0.0001 650056 1. {main}() /var/www/default/web/content/update.php:0 1.6358 15841328 2. _batch_page() /var/www/default/web/content/update.php:498 1.6362 15852192 3. _batch_do() /var/www/default/web/content/includes/batch.inc:80 1.6362 15852192 4. _batch_process() /var/www/default/web/content/includes/batch.inc:161 1.6369 15898976 5. call_user_func_array() /var/www/default/web/content/includes/batch.inc:284 1.6369 15899056 6. update_do_one() /var/www/default/web/content/includes/batch.inc:0 1.6369 15899840 7. data_entity_update_7000() /var/www/default/web/content/includes/update.inc:963

maxilein’s picture

Here is how I solved it:

1) enable all data modules.
-> You must enable the Schema module to install Data entity. (!) Which was the missing hint to me.
The missing function seems to be inside of the schema module.

2) re-run the updates.

3) disable unused modules again.

R, Max

joachim’s picture

> The missing function seems to be inside of the schema module.

That's not true at all!

/**
 * Load all data tables.
 */
function data_get_all_tables($reset = FALSE) {

in data.module.

What may be happening is that if you enable Data Entity and Data at the same time, the circularity problem occurs.

seb_r’s picture

Hi,

I ran into the same issue while updating an old site.

I made a patch that should fix it.

Seb

seb_r’s picture

Status: Active » Needs review
seb_r’s picture

roderik’s picture

StatusFileSize
new1.63 KB

(Just doing some reviews while browsing the issue queue for a.o. patches I'd need to apply...)

I have not tested the below, but while looking into the conversation, two things occurred to me:

1) The patch in #5 is fine, but for a different issue: it patches hook_update_7000() which is only executed when updating from D6. The patch for the original description was still missing.

2)

What may be happening is that if you enable Data Entity and Data at the same time, the circularity problem occurs.

From the stack trace (and the install command), it doesn't seem like that is the case for the original reported issue.

Peeking into the code that causes this:

 * TODO: This is still rather hairy, and needs more work.
 * In the meantime, it's probably best to enable CTools first, and then Data
 * rather than both together.
 */
function data_schema_alter(&$schema) {
  // Sidestep this during installation, as otherwise this is circular:
  // data_get_all_tables() calls ctools stuff, which calls the schema, and
  // gets us right back here.
  if (drupal_get_installed_schema_version('data') != SCHEMA_UNINSTALLED) {
    $tables = data_get_all_tables(TRUE);
    foreach ($tables as $table) {
      // Only add table if not yet present or the table at hand is defined in DB.
      // This allows other modules to "own" data managed tables which in turn makes Drupal
      // track schema versions - the prerequisit for using hook_update_N() on data tables.
      if (!isset($schema[$table->get('name')]) || (EXPORT_IN_DATABASE & $table->get('export_type'))) {
        $table_schema = $table->get('table_schema');
        // @todo: figure out why we need this check here and why for WTF
        // reasons, we sometimes get here and get nada for $table_schema.
        if (isset($table_schema)) {
          $table_schema += array(
            'module' => 'data',
          );
          $schema[$table->get('name')] = $table_schema;
        }
      }
    }
  }
  • I get visions of nasty bugs and want to slowly back away. (That function is indirectly calling itself recursively and then at a semi random moment returning an incomplete array to whichever caller called it last. Who knows what could happen as a result.) But that is not connected to the bug report.
  • The code is pretty clear about its intention of skipping the logic conditionally. We should just be able to skip it if data_get_all_tables() does not exist, which solves the problem -- regardless the exact cause. Because we should be able to trust that data_get_all_tables() always exists during 'normal operation'.
  • And as for how this could even happen... I guess it can (at least) happen if you enable the module, disable it, and then re-enable it. Because then the schema version is not SCHEMA_UNINSTALLED.

Anyway: fix attached. I dumped comments into it, and given the pre-existing statement that this code hairy anyway, IMHO this doesn't need more testing / figuring out if this is the right fix for the reported issue.

Patch #5 is included. I'm not including an interdiff because the two hunks in the patch are nicely separate.