Hi,
i use themekey module and i am very happy of it :)
I just came across of a little bug when trying to use a rule based on a taxonomy tid to switch the theme.
it happens in themekey_taxonomy_nid2tid
where the $result->rowCount())
is always 0 even if the query does returns results.
Actually, the documentation (http://php.net/manual/en/pdostatement.rowcount.php) states "For most databases, PDOStatement::rowCount() does not return the number of rows affected by a SELECT statement." and suggests a way to make it work.
I will upload the patch that i tried locally thet follows the documentation advice.
EDIT, i made a mistake writing fetchColumn() instead of rowCount() above, fixed it now
Comment | File | Size | Author |
---|---|---|---|
#10 | avoid_rowCount-2128887-10-version2x.patch | 3.23 KB | izus |
#8 | 2128887.patch | 4.13 KB | mkalkbrenner |
#1 | avoid_rowCount-2128887-1.patch | 997 bytes | izus |
Comments
Comment #1
izus CreditAttribution: izus commentedComment #2
mkalkbrennerWhich version of ThemeKey are you using?
Neither 2.x nor 3.x are using that code (anymore). The current code is
Comment #3
izus CreditAttribution: izus commentedthe patch is against the 2.5 version. (tried also on 2.3)
you're right about the current code that is used http://drupalcode.org/project/themekey.git/blob/refs/tags/7.x-2.5:/modul...
the issue is about the
if ($result->rowCount()) {
the patch in #1 is trying to avoid it by using a $result->fetchColumn() and db_query
Comment #4
izus CreditAttribution: izus commentedComment #5
izus CreditAttribution: izus commentedi understand the misunderstanding mkalkbrenner, i made a mistake in the issue description, i just fixed it with EDIT explication.
sorry about that !
Comment #6
izus CreditAttribution: izus commentedComment #7
mkalkbrennerOK, you're right.
rowCount() is used four times that way. We need to fix all all of them.
Comment #8
mkalkbrennerI think the patch is easier than proposed because the real count is not needed.
The error has been introduced by the port from D6 to D7. In D6 the result had to be checked before you iterate over it. In D7 such a check is not required at all and could therefor be skipped completely.
The other occurrences could be fixed by using db_merge().
Can you test this patch?
Comment #9
izus CreditAttribution: izus commentedi saw this was already merged in 3.x, tests in this branch are workin for me.
i tries to apply this in 2.x branch, it fails because we do not have modules/themekey.workbench_access.inc in 2.x branch
i will upload the working patch for 2.x (i greped and there is no rowCount left :))
Comment #10
izus CreditAttribution: izus commentedComment #11
izus CreditAttribution: izus commentedComment #12
mkalkbrennerI committed it to 7.x-2.x now. Thanks for your help.