I inherited a Drupal 7 site that appears to have a history.

I'm receiving the following error when updating modules or clearing the cache:

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'website_staging.search_api_server' doesn't exist: SELECT base.id AS id, base.name AS name, base.machine_name AS machine_name, base.description AS description, base.class AS class, base.options AS options, base.enabled AS enabled, base.status AS status, base.module AS module FROM {search_api_server} base WHERE (base.status IN (:db_condition_placeholder_0, :db_condition_placeholder_1, :db_condition_placeholder_2)) ; Array ( [:db_condition_placeholder_0] => 3 [:db_condition_placeholder_1] => 2 [:db_condition_placeholder_2] => 6 ) in EntityAPIController->query() (line 187 of /home/website/apps/api/docroot/sites/all/modules/entity/includes/entity.controller.inc).

The question is: where in the database do I need to remove any and all traces that point to this table?

Background:

I figured this was just a module that somehow did not install its tables right somehow. Uninstall, reinstall and done, right?

Two problems:

  1. Uninstalling a module also yields this error, and does not work
  2. The Search API module (http://drupal.org/project/search_api) never was installed at all

It appears the previous developers created a custom module, and named it 'search_api'. My guess is that later they went and did a blanket update of the site modules using drush, and starting updating the custom module far enough to install something to the database. Then they realized their mistake, and replaced the custom module in its original location (but did not rename it).

Nowhere in my modules is there a pointer to the search_api_server table, so it must be somewhere in the database.

So my plan as it stands is:

  1. Somehow fix the error
  2. Uninstall the custom search_api module
  3. Rename the custom search_api module and reinstall

And I need some help with step 1

  • I think you're going to need to step through the code and find out exactly where that's coming from - it's going to be almost impossible to guess from here – Clive Sep 14 at 11:49
  • From the look of it, it's a loop through all of the known entity types that are then queried for their defaults (?). Not that familiar with the inner workings of the entity module. – Menno van den Heuvel Sep 14 at 12:30
  • Though I can't offer any help with regard to the specific issue, you may find that drush registry_rebuild will help along the way. That's gotten me out of more problems than I can remember. – Danny Englander Sep 14 at 13:16
up vote 1 down vote accepted

I second the voices above.

My recent experience to get out of the pdoexception is crude and more akin to a 'big hammer' rather than anything elegant.

  1. make a backup of your database and the code
  2. either use a UI like phpmyadmin OR sql if you feel more comfortable with code
  3. create the table it says is missing (website_staging.search_api_server)
  4. add at least 1 variable (id)... take the defaults of integer
  5. you don't have to add a value to the table, just create it and add the definition for the id variable
  6. try your uninstall again

In my case for my custom module practice development, I also had to add a second variable because there were two 'keys' on the table. But I'd try this with just the one variable (id)... hopefully it will be enough to get you out of the PDOexception and onward to module/code review.

The concept here is to give Drupal the minimum info it needs via manual PHP/SQL creation so it can 'connect the dots' and move forward to execute your commands (uninstall). JW

  • This is what I ended up doing. I just looked in the .install file to find the correct definition of the required table. Once it stopped complaining I uninstalled and renamed the custom modules. – Menno van den Heuvel Oct 1 at 13:57

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.