SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens

Created on 3 May 2021, over 3 years ago
Updated 12 April 2023, over 1 year ago

Since the latest updates I get the following error, when using contextual filter values for sorting:

SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens: SELECT node_field_data.langcode AS node_field_data_langcode, group_content_field_data_node_field_data.langcode AS group_content_field_data_node_field_data_langcode, node_field_data.sticky AS node_field_data_sticky, node_field_data.created AS node_field_data_created, node_field_data.nid AS nid, group_content_field_data_node_field_data.id AS group_content_field_data_node_field_data_id, CASE .nid WHEN :_nid THEN 0 ELSE 1 END AS arg_order6311 FROM {node_field_data} node_field_data LEFT JOIN {group_content_field_data} group_content_field_data_node_field_data ON node_field_data.nid = group_content_field_data_node_field_data.entity_id AND group_content_field_data_node_field_data.type IN ( :views_join_condition_0__0, :views_join_condition_0__1, :views_join_condition_0__2, :views_join_condition_0__3, :views_join_condition_0__4, :views_join_condition_0__5, :views_join_condition_0__6, :views_join_condition_0__7, :views_join_condition_0__8, :views_join_condition_0__9, :views_join_condition_0__10, :views_join_condition_0__11, :views_join_condition_0__12, :views_join_condition_0__13, :views_join_condition_0__14, :views_join_condition_0__15, :views_join_condition_0__16, :views_join_condition_0__17, :views_join_condition_0__18, :views_join_condition_0__19, :views_join_condition_0__20, :views_join_condition_0__21, :views_join_condition_0__22, :views_join_condition_0__23, :views_join_condition_0__24, :views_join_condition_0__25, :views_join_condition_0__26, :views_join_condition_0__27, :views_join_condition_0__28, :views_join_condition_0__29, :views_join_condition_0__30, :views_join_condition_0__31, :views_join_condition_0__32, :views_join_condition_0__33, :views_join_condition_0__34, :views_join_condition_0__35, :views_join_condition_0__36, :views_join_condition_0__37, :views_join_condition_0__38, :views_join_condition_0__39, :views_join_condition_0__40, :views_join_condition_0__41, :views_join_condition_0__42, :views_join_condition_0__43, :views_join_condition_0__44, :views_join_condition_0__45 ) WHERE ((group_content_field_data_node_field_data.gid IN(:group_content_field_data_gid__0, :group_content_field_data_gid__1, :group_content_field_data_gid__2, :group_content_field_data_gid__3, :group_content_field_data_gid__4, :group_content_field_data_gid__5, :group_content_field_data_gid__6, :group_content_field_data_gid__7, :group_content_field_data_gid__8, :group_content_field_data_gid__9))) AND ((node_field_data.status = :db_condition_placeholder_1) AND (node_field_data.promote = :db_condition_placeholder_2) AND (node_field_data.type IN (:db_condition_placeholder_3, :db_condition_placeholder_4, :db_condition_placeholder_5))) ORDER BY arg_order6311 ASC, node_field_data_sticky DESC, node_field_data_created DESC LIMIT 50 OFFSET 0; Array ( [:db_condition_placeholder_1] => 1 [:db_condition_placeholder_2] => 1 [:db_condition_placeholder_3] => group_details [:db_condition_placeholder_4] => shop_product [:db_condition_placeholder_5] => allgemeiner_inhaltstyp [:group_content_field_data_gid__0] => 1 [:group_content_field_data_gid__1] => 44 [:group_content_field_data_gid__2] => 83 [:group_content_field_data_gid__3] => 35 [:group_content_field_data_gid__4] => 78 [:group_content_field_data_gid__5] => 87 [:group_content_field_data_gid__6] => 95 [:group_content_field_data_gid__7] => 123 [:group_content_field_data_gid__8] => 124 [:group_content_field_data_gid__9] => 146 [:views_join_condition_0__0] => group_content_type_07f2807df3c4e [:views_join_condition_0__1] => group_content_type_085244e4f3887 [:views_join_condition_0__2] => group_content_type_1a213b0cdd02f [:views_join_condition_0__3] => group_content_type_23d4ba31dce30 [:views_join_condition_0__4] => group_content_type_2e4306102d310 [:views_join_condition_0__5] => group_content_type_3118930b67ac6 [:views_join_condition_0__6] => group_content_type_3320c84c364bf [:views_join_condition_0__7] => group_content_type_55b283aae8b66 [:views_join_condition_0__8] => group_content_type_5b53d77cc76d4 [:views_join_condition_0__9] => group_content_type_5f2744ad5857a [:views_join_condition_0__10] => group_content_type_669c6fba9e6fd [:views_join_condition_0__11] => group_content_type_75e0a994a4c9b [:views_join_condition_0__12] => group_content_type_77335871d4f2a [:views_join_condition_0__13] => group_content_type_78c352d75da4f [:views_join_condition_0__14] => group_content_type_78fcaf395cd2d [:views_join_condition_0__15] => group_content_type_7acce48510f6b [:views_join_condition_0__16] => group_content_type_805c6b76215e0 [:views_join_condition_0__17] => group_content_type_8c4dd1a6ace68 [:views_join_condition_0__18] => group_content_type_8df5f5c3cf64d [:views_join_condition_0__19] => group_content_type_90656ed319282 [:views_join_condition_0__20] => group_content_type_a4a6ba2e1b664 [:views_join_condition_0__21] => group_content_type_a67b5f096c00e [:views_join_condition_0__22] => group_content_type_a6cb4a88dcfc7 [:views_join_condition_0__23] => group_content_type_a82a861f2c8bf [:views_join_condition_0__24] => group_content_type_ac81fd6e9a95b [:views_join_condition_0__25] => group_content_type_c56180f295162 [:views_join_condition_0__26] => group_content_type_c77a712e812b5 [:views_join_condition_0__27] => group_content_type_c921f01b582e1 [:views_join_condition_0__28] => group_content_type_db86376b47b2a [:views_join_condition_0__29] => group_content_type_dd463a21dd38a [:views_join_condition_0__30] => group_content_type_ddca4bdfff437 [:views_join_condition_0__31] => group_content_type_e3b11aa2d95ef [:views_join_condition_0__32] => group_content_type_edc6e9244c1a8 [:views_join_condition_0__33] => me-group_node-at_t_todo [:views_join_condition_0__34] => me-group_node-shorturl [:views_join_condition_0__35] => me-group_node-tag [:views_join_condition_0__36] => me-group_node-target [:views_join_condition_0__37] => me-group_node-l_log [:views_join_condition_0__38] => community-group_node-tag [:views_join_condition_0__39] => public-group_node-at_t_todo [:views_join_condition_0__40] => public-group_node-shorturl [:views_join_condition_0__41] => public-group_node-tag [:views_join_condition_0__42] => public-group_node-target [:views_join_condition_0__43] => public-group_node-l_log [:views_join_condition_0__44] => domain-group_node-domain [:views_join_condition_0__45] => domain-group_node-l_log )

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡¦πŸ‡ΉAustria ViNCE

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

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

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

    So is this module unusable then? I see the last release was 2 years ago.

  • πŸ‡ΊπŸ‡ΈUnited States chucksimply
  • πŸ‡΅πŸ‡±Poland lamp5 Rzeszow

    Hmmm, do you see any major issue to commit or any new feature to mark new release?

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

    I just see this specific issue keeping the module unusable, and it going untouched for so long. I wish I could assist in contributing a solution, but it's beyond my skillset. Any further thoughts on this error/issue fix?

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

    @lamp5, can you provide an update on this issue. Looks like the module is dead without a fix for it.

  • πŸ‡ΊπŸ‡¦Ukraine _shy Ukraine, Lutsk πŸ‡ΊπŸ‡¦

    Hi guys.
    I just took a quick look at this issue and provided a very short and dirty way how we can skip errors for the case when using 'all' as a contextual filter argument.
    This patch shouldn't fix all cases and I created it only just as a workaround to handle specific cases.
    Feel free to upgrade it and improve.

  • πŸ‡΅πŸ‡±Poland Alexius

    Patch from #13 working for me. Thanks, Diakuju @_shy.

  • πŸ‡΅πŸ‡±Poland jsobiecki Wroclaw

    I'm affected by this problem, and unfortunately patch #13 doesn't work. After some debugging, my impression is that root cause of issue is usage of placeholder() method in ArgOrderStort plugin:

        // Attempt to determine the number appended to the query substitutes.
        // Calling the placeholder function increments the placeholder count by 1,
        // so we subtract one to get the number that was used before.
        $placeholder_suffix = str_replace(':' . $left_table . '_' . $left_field, '', $this->query->placeholder($left_table . '_' . $left_field));
        if (!empty($placeholder_suffix) && intval($placeholder_suffix) > 1) {
          $placeholder_suffix = intval($placeholder_suffix) - 1;
        }
    
    

    The placeholder generates a field placeholder name with dynamic suffix (number). It uses static variable to provide proper number for suffix. Each execution of placeholder() the method is increasing suffix for sql placeholder.

    My scenario is that I have few views that are using same base table. As static variable is not being restarted for each view, the placeholder is increased and provides false (from the views_arg_order_sort) arguments. I'll try to rewrite the code to avoid placeholder() method. It generates unexpected side effects.

  • πŸ‡΅πŸ‡±Poland jsobiecki Wroclaw

    I created the fix for reported issue. Instead of using placeholder() method, I decided to generate SQL query and use regular expression to count all suffixes. The project doesn't have regular test suite, but at my test cases this seemed to fix the issue.

  • πŸ‡΅πŸ‡±Poland jsobiecki Wroclaw
Production build 0.71.5 2024