Table prefixes bug

gildedgod - December 22, 2008 - 11:51
Project:#translatable
Version:5.x-1.3
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:duplicate
Description

file:translatable.database.inc
line: 179
code:

<?php
  db_query
("INSERT INTO {$table} (". implode(',', $fields['columns']) .") VALUES (". implode(',', $fields['types']) .")", $fields['values']);
?>

I have drupal installed with table prefix "demo_" for all tables. Module raises error on new translation submit:

Table node_translatable doen't exists

It happens because according to PHP string variable behavior, after replacing "{$table}" by value of variable $table, PHP engine cleans tags "{" & "}", so, we need to apply this change in code for #translatable module to work with tables with prefixes:

<?php
  db_query
("INSERT INTO {".$table."} (". implode(',', $fields['columns']) .") VALUES (". implode(',', $fields['types']) .")", $fields['values']);
?>

#1

gildedgod - December 22, 2008 - 15:40

The same on 210 line too
- from:

<?php
 
return db_query("UPDATE {$table} SET ". implode(',', $fields['assigns']) ." WHERE ". $fields['where'], $fields['values']);
?>

- to:
<?php
 
return db_query("UPDATE {".$table."} SET ". implode(',', $fields['assigns']) ." WHERE ". $fields['where'], $fields['values']);
?>

#2

sun - December 26, 2008 - 19:06
Status:needs review» duplicate

This was already fixed in #244276: doesn't seem to work with db table prefix. You might want to consider updating to the latest development snapshot.

 
 

Drupal is a registered trademark of Dries Buytaert.