This error pops up on Postgres. Other engines seems silently to ignore it. Attached a very simple example view that allow you to enter a nid as argument.
Reproduce error
- Install on PostgreSQL 9.1/92
- Clean Drupal 7 and views (latest stable or HEAD).
- Install view
- Import attached view.
- If you like create a few test nodes.
- Load the views page and verify that it lists the nodes
- Enter a nid as a argument and verify that is works as expected.
- Enter a string as argument and you should get a beautiful PDOException
PDOException: SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: "foo" LINE 1: SELECT n.title FROM node n WHERE n.nid IN ('foo') ^: SELECT n.title FROM {node} n WHERE n.nid IN (:nids_0); Array ( [:nids_0] => foo ) in views_handler_argument_node_nid->title_query() (line 18 of /prototype/views/drupal-7.17/sites/all/modules/views/modules/node/views_handler_argument_node_nid.inc).
I think it is this code is what fails.
<?php
function validate_argument_basic($arg) {
if (!isset($arg) || $arg === '') {
return FALSE;
}
if (!empty($this->definition['numeric']) && !isset($this->options['break_phrase']) && !is_numeric($arg)) {
return FALSE;
}
return TRUE;
}
?>
Debugging this and I get this where it fails and it is indeed returning TRUE when I should return FALSE.
Is it numeric?: 1
break_phrase: 0
arg: sfdf
returns TRUE
Comment | File | Size | Author |
---|---|---|---|
views_argument.txt | 2.39 KB | steinmb |
Comments
Comment #1
dawehnerWhat happens if you choose "Numeric" as validator? From my understanding this should validate the actual argument in the way you want.
Comment #2
Chi CreditAttribution: Chi commentedYou need not install views to reproduce the bug. Just type something like node/blablabla on Postgres installation of Drupal.
Marking as duplicate of #1003788: PostgreSQL: PDOException:Invalid text representation when attempting to load an entity with a string or non-scalar ID.
Comment #3
Drupa1ish CreditAttribution: Drupa1ish commentedReopening. .. Even with #1003788: PostgreSQL: PDOException:Invalid text representation when attempting to load an entity with a string or non-scalar ID fixed, this issue occurs.
Comment #4
dcam CreditAttribution: dcam as a volunteer commentedWhich issue? The problem with Views arguments?
Comment #5
Drupa1ish CreditAttribution: Drupa1ish commented@dcam, yes