When trying to export variables that have a colon (":") in their names, like panelizer_node:article_allowed_layouts, using db_query() throws an exception due to confusion with PDO placeholders which also use ":".

Replacing

$result = db_query("SELECT * FROM {variable} WHERE name IN (:names)", array(':names' => $data));

with

$result = db_select('variable', 'v')
    ->fields('v', array('name', 'value'))
    ->condition('name', $data, 'IN')
    ->execute();

solves the problem.

Comments

skwashd’s picture

Status: Needs review » Reviewed & tested by the community

I didn't test this with a colon in the variable name. From previous experience it will solve the bug identified above.

I tested this patch with variables with upper case characters in the name, such as pathauto config when using language specific path patterns. It fixes this problem too.

As this patch solves 2 bugs it should be committed.

patcon’s picture

Rerolled patch to work against beta4 with drush make (ie. -p0)

Yippee-ki-yoh-kay-yay

univate’s picture

Also confirming the occurrence of this bug and have reviewed the patch and agree its good.

febbraro’s picture

Version: 7.x-2.x-dev » 6.x-2.1
Status: Reviewed & tested by the community » Patch (to be ported)

Committed to 7.x, thanks.

http://drupalcode.org/project/strongarm.git/commit/286647d

Needed for 6.x?

skwashd’s picture

Version: 6.x-2.1 » 7.x-2.x-dev
Status: Patch (to be ported) » Fixed

This doesn't need a backport to D6 as PDO was only introduced in D7. Using 6.x-2.1 I was able to export a variable called strongarm:test without any problems.

febbraro’s picture

Thanks for verifying.

Status: Fixed » Closed (fixed)

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