When using a custom installation profile, the installation fails with the following error:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'database.media_type' doesn't exist .

Have tried versions 7.x-2.x and get the same error.
Had no problem before media-7.x-1.0 .

This issue is similar to http://drupal.org/node/1311828 which has been closed. The provided patch works, would it be possible to add it to a future version?

Thanks

Comments

Dave Reid’s picture

Version: 7.x-1.1 » 7.x-1.x-dev
Status: Active » Postponed (maintainer needs more info)

See http://drupal.org/node/1311828#comment-5691576. You'll have to do some debugging and backtracing as to what the cause of the error coming back is.

Anonymous’s picture

Thanks for your answer.

However, could you kindly indicate how I should proceed for debugging?
I've tried installing via drush with debug option and get this:

WD registry: PDOException: SQLSTATE[42S02]: Base table or view not       [error]

found: 1146 Table 'test.media_type' doesn't exist: SELECT mt.*
FROM
{media_type} mt
ORDER BY weight ASC; Array
(
)
 in media_type_get_types() (line 134 of
C:\xampp\htdocs\test\sites\all\modules\media\inclu
des\media.types.inc).
[129.04 sec, 51.5 MB]
WD php: PDOException: SQLSTATE[42S02]: Base table or view not found:     [error]

1146 Table 'test.media_type' doesn't exist: SELECT mt.*
FROM
{media_type} mt
ORDER BY weight ASC; Array
(
)
 in media_type_get_types() (line 134 of
C:\xampp\htdocs\test\sites\all\modules\media\inclu
des\media.types.inc).
[129.05 sec, 51.44 MB]
WD php: Warning: Cannot modify header information - headers already    [warning]

sent by (output started at C:\drush\includes\output.inc:37) in
drupal_send_headers() (line 1239 of
C:\xampp\htdocs\test\includes\bootstrap.inc).
[129.07 sec, 51.45 MB]
PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'md
714drush.media_type' doesn't exist: SELECT mt.*
FROM
{media_type} mt
ORDER BY weight ASC; Array
(
)
 in media_type_get_types() (line 134 of C:\xampp\htdocs\md7.14_201205xx_SECU_dru
sh\sites\all\modules\media\includes\media.types.inc).
Drush command terminated abnormally due to an unrecoverable error.       [error]

[129.08 sec, 51.43 MB]

Also, I've tried to remove some of the modules activated in the profile and noticed that the installation succeeds when the linkit module is not activated.

TIA for further help

Anonymous’s picture

Is there a chance that the change that brought this error will be reverted?

Dave Reid’s picture

Seeing as you've been one of the only people that has reported this issue, we are still not sure of how exactly this is caused. We'll need to know which functions are in the backtrace when this happens so we can figure out the root cause of it.

Bob123’s picture

Version: 7.x-1.x-dev » 7.x-1.2

I got the same issue during media module installation:

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'drupal7test.media_type' doesn't exist: SELECT mt.* FROM {media_type} mt ORDER BY weight ASC; Array ( ) in media_type_get_types() (line 134 of C:\wamp\www\Drupal7Test\sites\all\modules\media\includes\media.types.inc).

    New install:

- drupal-7.19.zip
- ctools-7.x-1.2.zip
- job_scheduler-7.x-2.0-alpha3.zip
- feeds-7.x-2.0-alpha7.zip
- entity-7.x-1.0.zip
- linkit-7.x-2.5.zip
- views-7.x-3.5.zip
- media-7.x-1.2.zip --> Error message during installation "PDOException: SQLSTATE[42S02] ..."

Now my test site is no more accessible: It only shows the very same "PDOException: SQLSTATE[42S02] ..." error!

There is indeed no table named "media_type" in the database.
Do the media module needs it? Who (which module) should create this table?

Please Help...

Bob123’s picture

- Replace \sites\all\modules\media\includes\media.types.inc temporary by an empty file to re-gain access to the site.
- Unable media module.
- Unable linkit module.
- Replace the empty \sites\all\modules\media\includes\media.types.inc by the original file.
- Enable media module --> Seems OK, 3 media_ Tables has been created: media_filter_usage; media_list_type; Media_type.
- Enable linkit module --> Seems OK.

So this seems to be an incompatibility problem between the linkit module and the media module... : Enabling first the media module and afterwards the linkit modules seems to be OK.

mo3.mo3’s picture

i had similar errors and i got everything to work after i ran /update.php
give it a try!

cwebster’s picture

@Bob123: Thanks so much that saved my site.

genebobmiller’s picture

I've got the same error on install but I don't use the linkit module. I'll investigate further

wxman’s picture

Same here. I had to use the empty media.types.inc solution to fix, and I don't have linkit.

jcallanan’s picture

I am getting the same error with an install of the Open Atrium 2 distribution and can't figure out how to resolve it. The error message is:
PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'stagnito_intranet.media_type' doesn't exist: SELECT mt.* FROM {media_type} mt ORDER BY weight ASC; Array ( ) in media_type_get_types() (line 134 of /home/stagnito/public_html/intranet/profiles/openatrium/modules/contrib/media/includes/media.types.inc).

I've tried removing the Media module and the Linkit module, then added them back, and run update.php but still getting the error. Any ideas?

aken.niels@gmail.com’s picture

Issue summary: View changes

We've got the same error with our installation profile. Removing dependency of Linkit also resolved the problem here.

kendouglass’s picture

Similar to others above. I install any recent version of media. Then I uninstall it. Even with the module uninstalled I'm getting these errors"

drush updatedb
No database updates required   [success]
WD php: PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mydatabase_dp7_dev.media_filter_usage' doesn't exist: DELETE FROM {media_filter_usage}  [error]
WHERE  (timestamp < :db_condition_placeholder_0) ; Array
(
  [:db_condition_placeholder_0] => 1392755134
)
 in media_flush_caches() (line 1129 of /home/drupal/drupal7_sites/all/modules/contrib/media/media.module).
PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table &#039;mydatabase_dp7_dev.media_filter_usage&#039; doesn&#039;t exist: DELETE FROM {media_filter_usage}
WHERE  (timestamp < :db_condition_placeholder_0) ; Array
(
  [:db_condition_placeholder_0] => 1392755134
)
 in media_flush_caches() (line 1129 of /home/drupal/drupal7_sites/all/modules/contrib/media/media.module).
Drush command terminated abnormally due to an unrecoverable error.   [error]
Finished performing updates.   
lucasfazzi’s picture

I don`t know if i will say something wrong but i will try...
Acces directly yoursite.com.br/install.php , i think it`ll works !! But it not resolve the problem completely, in this way you can get a lack to pass for the installation module.
Sorry if am i wrong.
Good code !! cya

Elijah Lynn’s picture

This can result when you did an install without doing an sql-drop. And if you did and are using memcache, it could be memcache messing stuff up. Try a sql-drop first and then toggling memcache off if you have it on.