How to deal with invalid placeholders?

Created on 2 May 2009, about 16 years ago
Updated 30 May 2025, 4 days ago

Today, I track down to test failures in SQLite to some of the recently converted queries that were using incorrect placeholders:

db_query("SELECT hidden FROM {menu_links} WHERE mlid = :mlid", array('mlid' => $mlid));

(from #451660: Menu creation / deletion test doing something silly β†’ , notice the 'mlid' instead of ':mlid')

and

db_query('SELECT t.*, tid1, tid2 FROM {taxonomy_term_relation}, {taxonomy_term_data} t WHERE (t.tid = tid1 OR t.tid = tid2) AND (tid1 = :tid1 OR tid2 = :tid2) AND t.tid != :tid ORDER BY weight, name', array(':tid' => $tid, ':tid1' => $tid, 'tid2' => $tid));

(from #451678: taxonomy_get_related() is broken β†’ , notice the 'tid2' instead of ':tid2')

Apparently PDO MySQL is very happy to silently convert those placeholders to their correct forms. I haven't tested on PostgreSQL yet, but on SQLite those generate weird issues because we replace numeric placeholders ourselves to workaround a bug of PDO_SQLite.

RFC, any idea on how to deal with this issue?

πŸ“Œ Task
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

database system

Created by

πŸ‡«πŸ‡·France Damien Tournoud

Live updates comments and jobs are added and updated live.
  • stale-issue-cleanup

    To track issues in the developing policy for closing stale issues, [Policy, no patch] closing older issues

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thank you for creating this issue to improve Drupal.

    We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.

    Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

Production build 0.71.5 2024