I got the following error when trying to install da.

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'domain_taxonomy_source' doesn't exist: SELECT COUNT(*) AS expression FROM (SELECT 1 AS expression FROM {domain_taxonomy_source} domain_taxonomy_source WHERE (domain_id = :db_condition_placeholder_0) ) subquery; Array ( [:db_condition_placeholder_0] => 0 ) in domain_test_schema() (line 3614 of sites\all\modules\domain\domain.module).

I think that this is due to the fact that I have the strict mysql error levels assigned. Whatever the cause, a try catch prevented the error and I managed to install the module.

function domain_test_schema($schema = array()) {
  $tables = array();
  foreach ($schema as $name => $table) {
    if (isset($table['fields']['domain_id']['type']) && $table['fields']['domain_id']['type'] == 'int') {
      try {
        $query = db_select($name)
          ->condition('domain_id', 0);
        $check = $query->countQuery()->execute()->fetchField();
        if ($check) {
          $tables[] = $name;
        }
      }
      catch(Exception $e) {}
    }
  }
  return $tables;
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

agentrickard’s picture

Status: Active » Postponed (maintainer needs more info)

I'm interested to know where this table definition comes from domain_taxonomy_source.

That's not part of the module package, and, obviously, that table should not be present if it is provided by a module that depends on Domain Access.

The try/catch model is probably more correct, but I'd like to be able to replicate the error first. We should also write a test for it.

agentrickard’s picture

Oh, I see. I bet you downloaded a module before install, right? domain_update_module_check() will try to load uninstalled modules, because this can happen as part of a D6 => D7 upgrade.

Alan D.’s picture

Well the check for the table throws an error, so the test is flawed. (IE: You get a PDO exception if the query runs without the existence of the table, you get a PDO exception if you test prior to the query)

The steps to replicate are probably impossible to replicate, I had a timeout during the installation, at 60 sec, so hit refresh to resubmit the page.

Enable DA
Enable 5 or so DA contribute modules
- had timeout on first attempt, increased this to 240 sec
- PDO Exception on second, added fix
- third refresh of the form submit worked

I guess if you just need to know that the table exists, it would be better to use db_table_exists($table). Then no try catch would be required.

function domain_test_schema($schema = array()) {
  $tables = array();
  foreach ($schema as $name => $table) {
    if (isset($table['fields']['domain_id']['type']) && $table['fields']['domain_id']['type'] == 'int') {
        if (db_table_exists($name)) {
          $tables[] = $name;
        }
    }
  }
  return $tables;
}

For testing, just pass in a valid and invalid table schema :)

agentrickard’s picture

Status: Postponed (maintainer needs more info) » Active

Fair enough, since db_table_exists() requires an active connection.

agentrickard’s picture

Status: Active » Fixed
FileSize
790 bytes

I never could replicate this, but here's a patch to be safe.

agentrickard’s picture

FileSize
1.28 KB

Wrong patch.

agentrickard’s picture

Status: Fixed » Needs work

Not yet committed. We have an existing test we can extend here.

agentrickard’s picture

Status: Needs work » Fixed
FileSize
2.91 KB

And a patch with nice tests.

Status: Fixed » Closed (fixed)

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