When trying to save changes to the index Fields settings, I keep getting the following error:
PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'ourdbname.search_api_db_resource_index_body_summary' doesn't exist: ALTER TABLE search_api_db_resource_index_body_summary CONVERT TO CHARACTER SET 'utf8' COLLATE 'utf8_bin'; Array ( ) in SearchApiDbService->createFieldTable() (line 207 of /var/www/sitename/sites/all/modules/contrib/search_api_db/service.inc).
I believe the error is because the table prefix is not being included? It's missing in the error message, and I would guess that $name needs to be adjusted to include prefixes in the code below (line 207 of service.inc)? I really don't understand this well enough to be sure, but if I manually append the prefix we're using for this database to $name, the errors seem to go away:
switch ($db_driver) {
case 'mysql':
db_query("ALTER TABLE {$name} CONVERT TO CHARACTER SET 'utf8' COLLATE 'utf8_bin'")->execute();
break;| Comment | File | Size | Author |
|---|---|---|---|
| #1 | 1976708-search_api_db-1.patch | 526 bytes | hefox |
Comments
Comment #1
hefox commentedIt's due to how string replacement with double quoted strings is done. To php, {$name} is what it replaces with $name (it's for more complicated variable like {$name->key} and such)
So need {" . $name . "} or {{$name}}
Putting it as major as it causes fatal errors, though only when using table prefixes.... like when running simpletests!
This module could do with some index simpletests :)
Comment #2
andypostmakes sense
Comment #3
drunken monkeyOK, I feel stupid now. Thanks a lot for spotting the problem and providing a patch!
Committed.