Download & Extend

PDOException for anonymous users and empty nodetype_acces permissions

Project:Nodetype access
Version:7.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

For anonymous users and empty nodetype_acces permissions I get the following error message (I'm using PostgreSQL 8.4):

PDOException: SQLSTATE[42804]: Datatype mismatch: 7 ERROR: argument of AND must be type boolean, not type integer LINE 6: WHERE (promote = '1') AND (status = '1') AND (0) ) subquery ^: SELECT COUNT(*) AS expression FROM (SELECT 1 AS expression FROM {node} n WHERE (promote = :db_condition_placeholder_0) AND (status = :db_condition_placeholder_1) AND (0) ) subquery; Array ( [:db_condition_placeholder_0] => 1 [:db_condition_placeholder_1] => 1 ) in PagerDefault->execute() (line 74 of .../drupal/includes/pager.inc).

Comments

#1

Status:active» needs review

This patch fixes the PDOException. Maybe I'm missing something, but I don't see the value of the removed where condition. Might be a PostgreSQL specific issue.

#2

Status:needs review» fixed

you read my answer in the other issue #1426702: EFQ test fails for empty nodetype array?
this should already be fixed in current dev and release.
please always use latest version.

feel free to reopen if this does not apply.

#3

Status:fixed» needs review

Yes, I'm using a current git checkout.

#4

Status:needs review» needs work

As far as I can see the issue still exists in the current git HEAD.

The problem is that postgresql has a stricter typesystem than mysql. Using the '0'
in a boolean comparison like the module does in the following where-condition

(promote = :db_condition_placeholder_0) AND (status = :db_condition_placeholder_1) AND (0)

will result in a comparison of the following types:

(bool) AND (bool) AND (integer)

This comparison is not possible as postgresql does not have a default cast for casting integers
to boolean values.

A fix which will work on both database systems is providing a expression instead of the '0'. The expression '1=0'
will evaluate to False in both databases and preserve the same query the module currently creates, while
also making it work on postgresql.

AttachmentSize
nodetype_access-fix_empty_types-1426702-3.patch 447 bytes

#5

Just noticed I attached the wrong patch in comment #4.
This is the correct one.

AttachmentSize
use_expression_instead_of_0-1750392-4.patch 596 bytes

#6

Status:needs work» fixed

great work nico. committed and released.

#7

Status:fixed» closed (fixed)

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

nobody click here