I am on Drupal 7.22 on two different environments (dev and stage). They are the same in every way, hopefully. I am trying to create a new menu on stage, and the query is failing, but it's working on dev. Why would one environment be passing in the current path (very weird, and failing) and the other pass in a numeric id?

Here's the error in psql:

ERROR: invalid input syntax for integer: "/structure/menu/manage/menu-eu-menu" at character 579

Here's the error in my Drupal log:

DOException: SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: "/structure/menu/manage/menu-eu-menu" LINE 5: WHERE (base.nid IN ('/structure/menu/manage/menu-eu-menu... ^: SELECT revision.vid AS vid, base.uid AS uid, revision.title AS title, revision.log AS log, revision.status AS status, revision.comment AS comment, revision.promote AS promote, revision.sticky AS sticky, revision.vuuid AS vuuid, base.nid AS nid, base.type AS type, base.language AS language, base.created AS created, base.changed AS changed, base.tnid AS tnid, base.translate AS translate, base.uuid AS uuid, revision.timestamp AS revision_timestamp, revision.uid AS revision_uid FROM
{node}
base INNER JOIN
{node_revision}
revision ON revision.vid = base.vid WHERE (base.nid IN (:db_condition_placeholder_0)) ; Array ( [:db_condition_placeholder_0] => /structure/menu/manage/menu-main-menu-eu ) in DrupalDefaultEntityController->load() (line 196 of /var/www/drupal-7.22/includes/entity.inc).

Here are the queries that I'm seeing in the database logs:

ON MY DEV ENVIRONMENT:
======================

SELECT revision.vid AS vid, base.uid AS uid, revision.title AS title, revision.log AS log, revision.status AS status, revision.comment AS comment, revision.promote AS promote, revision.sticky AS sticky, revision.vuuid AS vuuid, base.nid AS nid, base.type AS type, base.language AS language, base.created AS created, base.changed AS changed, base.tnid AS tnid, base.translate AS translate, base.uuid AS uuid, revision.timestamp AS revision_timestamp, revision.uid AS revision_uid
FROM
node base
INNER JOIN node_revision revision ON revision.vid = base.vid
WHERE (base.nid IN ('29'))

ON MY STAGE ENVIRONMENT:
========================

SELECT revision.vid AS vid, base.uid AS uid, revision.title AS title, revision.log AS log, revision.status AS status, revision.comment AS comment, revision.promote AS promote, revision.sticky AS sticky, revision.vuuid AS vuuid, base.nid AS nid, base.type AS type, base.language AS language, base.created AS created, base.changed AS changed, base.tnid AS tnid, base.translate AS translate, base.uuid AS uuid, revision.timestamp AS revision_timestamp, revision.uid AS revision_uid
FROM
node base
INNER JOIN node_revision revision ON revision.vid = base.vid
WHERE (base.nid IN ('/structure/menu/manage/menu-eu-menu'))

Comments

jessicachan’s picture

Does anyone know where in the codebase this query is assembled?

alinouman’s picture

Hi jessica,
I have a suggestion this issues might arises from Postgres not automatically casting between data types (Mysql does - I think not per standards, but not sure). The fix is relatively easy - cast the value in PHP before passing it into the query.
so in includes/entity.inc at line 196.

  $query = $this->buildQuery($ids, $conditions, $revision_id);
      $queried_entities = $query
        ->execute()
        ->fetchAllAssoc($this->idKey);

could be

  $query = $this->buildQuery(intval($ids), $conditions, intval($revision_id));
      $queried_entities = $query
        ->execute()
        ->fetchAllAssoc($this->idKey);
    }

but i guess it might not solve problems because some how that ids is /structure/menu/manage/menu-eu-menu. Inspect ids and revision id and see wht you get.

jessicachan’s picture

Thanks @alinouman -- it's really puzzling me as to why /structure/menu/manage/menu-eu-menu is being passed in. That is an admin path and has no real meaning in the query being constructed, and I'm not sure why this is suddenly happening :( Since it isn't happening in any other Drupal installation I have going on.