We currently use rowCount() on SELECT queries to count the number of items in a table, which is an incorrect usage of this method:

http://php.net/manual/en/pdostatement.rowcount.php

Instead we should use a method similar to the Aggregator module:

function _aggregator_has_categories() {
  return user_access('access news feeds') && (bool) db_query_range('SELECT 1 FROM {aggregator_category}', 0, 1)->fetchField();
}

Comments

rszrama’s picture

Status: Active » Needs review
StatusFileSize
new4.97 KB

Alas, if only 'twere as simple as boolean queries. Instead for ours the count mattered because we used it in format_plural() messages to indicate how many of each item remained. It wasn't too difficult to overcome, but it involved a variety of new EntityFieldQueries and use of the countQuery() method on the db_select object to make do.

Let's let the testbot have a crack at it.

Status: Needs review » Needs work

The last submitted patch, 1377754.remove_rowCount.patch, failed testing.

rszrama’s picture

Status: Needs work » Needs review
StatusFileSize
new4.99 KB

Fix attached. Bad copy / paste.

rszrama’s picture

Status: Needs review » Fixed

And committed.

Status: Fixed » Closed (fixed)

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