doesn't seem to work with db table prefix

Bodo Maass - April 8, 2008 - 23:48
Project:#translatable
Version:5.x-1.2
Component:Code
Category:bug report
Priority:normal
Assigned:sun
Status:closed
Description

Hi, I just tried to translate a menu in a database called 'choir' that is also using table prefixes. I get the following error messages:

* user warning: Table 'choir.translatable_object' doesn't exist query: INSERT INTO translatable_object (tid,object_name,object_key,object_field,translation,locale) VALUES (3,'menu','133','title','Der Chor','de') in D:\wamp\drupal5\includes\database.mysql.inc on line 172.
* user warning: Table 'choir.translatable_object' doesn't exist query: INSERT INTO translatable_object (tid,object_name,object_key,object_field,translation,locale) VALUES (4,'menu','133','description','Über den Chor','de') in D:\wamp\drupal5\includes\database.mysql.inc on line 172.

It seems that the table prefix is not applied.

#1

Bodo Maass - April 9, 2008 - 12:06
Status:active» needs review

Ok, to fix this one has to change line 179 in translatable.database.inc into:

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

Patch is attached.

I presume that line 210 in this file is also not working with prefixes:

<?php
return db_query("UPDATE {$table} SET "...
?>

The curly braces will be parsed by php as delimiters of the variable name to be replaced. So one can either use two curly braces:

<?php
return db_query("UPDATE {{$table}} SET "...
?>

or pass the table name as a parameter to the db_query function:
<?php
return db_query("UPDATE {%s} SET  ...", $table
?>

AttachmentSize
translatable.database.inc_.patch 870 bytes

#2

sun - April 10, 2008 - 01:35
Version:5.x-1.x-dev» 5.x-1.2
Assigned to:Anonymous» sun

Thanks for this bug report. Please test attached patch.

AttachmentSize
translatable.database.inc_.patch 2.16 KB

#3

Bodo Maass - April 10, 2008 - 08:38

Seems to work fine on a system with table prefixes. I made sure both the insert and the update case were executed.

#4

sun - April 10, 2008 - 16:57
Status:needs review» fixed

Thanks, committed.

#5

Anonymous (not verified) - April 24, 2008 - 17:02
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.