You are here

Drupal: PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'foo.image_dimensions' doesn't exist

Submitted by Druss on Thu, 2014-04-17 02:17

I ran into a WSOD on a Drupal site and checking the Drupal 7 log showed me the following:

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'foo.image_dimensions' doesn't exist: SELECT * FROM {image_dimensions} id WHERE id.fid IN (:fids_0, :fids_1,

This was a Media module fuckup. This module (which was up-to-date) uses its own version of the file_entity module in the 7.1 branch and a different file_entity module in 7.2 (which has been in alpha forever). One of the solutions was apparently to rollback to 7.1.3 from the current 7.1.4. This, when I checked using Drush was not an option. 7.1.4 also has security updates, apparently.

As the error message stated, this was being cause simply because the image_dimensions table did not exist. Looking at the file_entity module's .install file, I saw that this pertained to update 7101. Furthermore, the update 7100 was basically a placeholder as it was empty. So it'd seemingly be safe to recreate the table. Now, I didn't really want to recreate it by hand on the sql commandline. Drush provided (as it often does) a relatively easy, uncomplicated solution as follows:

drush @foo.example.com php-eval 'module_load_install('file_entity'); file_entity_update_7101();'

This boots up Drupal, loads the file_entity module's install file and then runs the 7101 update, all within an 'eval' call. I then cleared the site cache and reloaded the site. All was now fine. Once again. Hooray!

If you don't have drush (but you really should), you could try the messier alternative of evaluating the same code in a PHP filter within Drupal (using the php module).

Hope this helps!