The SelectQuery produced by SelectQuery::countQuery() replaces the connection information in the SelectQuery with the active connection (it uses db_select to form the new query, instead of the select() method of the original query's connection). This caused Drupal to attempt to run a SELECT COUNT(*) query on the wrong database when I was attempting to use Migrate module on an external database.

I marked this Needs Work because I would like someone wiser than I to verify that it should be
$this->connection->select($count) rather than
$count->connection->select($count)

I don't know that it matters, but it seems like it'd be good to check.

CommentFileSizeAuthor
countQueryPatch.patch391 bytesquartsize
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quartsize’s picture

Status: Needs work » Needs review

Marking Needs Review, so the testbot will find it (and Crell says $this vs. $count shouldn't make a difference).

Crell’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Quick fix

Both $count and $this should have identical connection objects at that point, since $count was a clone of $this.

And Bah! that we let that bug creep in there. Thanks, quartsize.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

Status: Fixed » Closed (fixed)
Issue tags: -Quick fix

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