Table prefixing gets applied twice on CCK tables

EvanDonovan - July 25, 2008 - 16:36
Project:Node Find Replace
Version:5.x-1.2
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review
Description

When doing a node find replace on UrbanMinistry.org, we received this PHP error:
Table '[db_user].um_um_content_type_donations_discounts' doesn't exist query: select * from um_um_content_type_donations_discounts where field_how_to_get_this_format like '%http://www.urbanministry.org/wiki/youth-homicide-stats%'; in /home/urbmi5/public_html/includes/database.mysql.inc on line 172.

Note that the table name is um_um_content_type_donations_discounts. It should be um_content_type_donations_discounts. Table prefixing, for some reason, is being applied twice.

#1

regx - July 26, 2008 - 14:21

This was also fixed in the dev release. I have made a new official release DRUPAL-5--1-3. Please upgrade to that and let me know if you have any problems.

#2

regx - July 27, 2008 - 00:49

After taking a harder look, I am not sure that the table prefixing issue is fixed.
Please let me know if release DRUPAL-5--1-3 fixes this issue for you. If not, I will create a development environment using table prefixes and work out this issue.
I have been meaning to upgrade this module for a while anyway. It should really be using hooks so that other modules can utilize it.

PS. You are welcome. I am glad to know other people are using this. It has been quite useful for me.

#3

EvanDonovan - March 23, 2009 - 18:20

I finally had a chance to upgrade to 5.x-1.5 on this module today and I saw the following error: Table [db].um_um_content_type_audio_import doesn't exist query: select * from um_um_content_type_audio_import where field_audio_import_data like "%food processing%"

Looks like, at least in this case, the table is still getting prefixed twice.

#4

EvanDonovan - April 21, 2009 - 23:44
Status:active» needs review

I found out where this error is coming in.

The lines

<?php
/** Replace CCK content **/
             
$sql = "select * from {%s} where %s like '%s';";
             
$result = db_query($sql,$cck_table,$cck_field,'%'.$find_string.'%');
?>

should be
<?php
/** Replace CCK content **/
             
$sql = "select * from %s where %s like '%s';";
             
$result = db_query($sql,$cck_table,$cck_field,'%'.$find_string.'%');
?>

The SHOW TABLES statement a few lines earlier in the code already gets the table names with the correct prefixes.

I can roll up a proper patch if you want.

 
 

Drupal is a registered trademark of Dries Buytaert.