All calls to db_query() within this script do not specify an $options parameter such as array('target' => 'target_name'). This means that all db_query() calls will hit the default target of the connection. This means that if you have multiple targets within a single connection, the default target will get updated multiple times.

CommentFileSizeAuthor
#4 utf8mb4_convert-2787239.patch4.24 KBquicksketch

Comments

quicksketch created an issue. See original summary.

quicksketch’s picture

Rather than using `db_query()` at all, it might be safer and easier to create a connection and use the query method directly on the connection object. Then you won't have to specify target or manually switch databases with db_set_active():

Instead of:

db_set_active($target);
db_query($query, $params, array('target' => $target));

Switch to:

$connection = Database::getConnection($target, $database_key);
$connection->query($query, $params);
stefan.r’s picture

can anyone post a patch?

quicksketch’s picture

StatusFileSize
new4.24 KB

I think this should do it.

  • stefan.r committed 3ee3a27 on 7.x-1.x authored by quicksketch
    Issue #2787239 by quicksketch: A connection with multiple targets just...
stefan.r’s picture

Status: Active » Fixed

Looks good, thanks!

Status: Fixed » Closed (fixed)

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