In my case problem happens only when many languages enabled:

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens: SELECT 1 AS expression                      [error]
FROM
{xmlsitemap} xmlsitemap
WHERE (type = :db_condition_placeholder_0) AND (id = :db_condition_placeholder_1) AND (language =
:db_condition_placeholder_2:db_condition_placeholder_3:db_condition_placeholder_4:db_condition_placeholder_5:db_condition_placeholder_6) AND (status = :db_condition_placeholder_7) AND (access =
:db_condition_placeholder_8)
LIMIT 1 OFFSET 0; Array
(
    [:db_condition_placeholder_0] => node
    [:db_condition_placeholder_1] => 385
    [:db_condition_placeholder_2] => en-001
    [:db_condition_placeholder_3] => en-au
    [:db_condition_placeholder_4] => en-eu
    [:db_condition_placeholder_5] => en-gb
    [:db_condition_placeholder_6] => en-za
    [:db_condition_placeholder_7] => 1
    [:db_condition_placeholder_8] => 1
)
 in Drupal\xmlsitemap\XmlSitemapLinkStorage->checkChangedLinks() (line 220 of xmlsitemap/src/XmlSitemapLinkStorage.php).

Reason:

    $query = db_select('xmlsitemap');
    $query->addExpression('1');
    foreach ($conditions as $field => $value) {
      $query->condition($field, $value); // <== $value can be array.
    }
    $query->range(0, 1);
    $changed = $query->execute()->fetchField();
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chilic created an issue. See original summary.

chilic’s picture

chilic’s picture

Dave Reid’s picture

Status: Active » Needs review
FileSize
5.08 KB

I found a couple more places where this could happen, and I fixed the service to inject the database connection.

  • Dave Reid committed c1c5654 on 8.x-1.x
    Issue #2991052 by chilic, Dave Reid: Fixed Invalid parameter number...
Dave Reid’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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