Problem/Motivation

In the field "Authored by" on node edition, in autocomplétion mode, when I write something, the autocompletion request ends with error.

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

SELECT "base_table"."uid" AS "uid", "base_table"."uid" AS "base_table_uid" FROM "users" "base_table" INNER JOIN 
"users_field_data" "users_field_data" ON "users_field_data"."uid" = "base_table"."uid" WHERE ("users_field_data"."name" LIKE :db_condition_placeholder_1 ESCAPE '\\') 
OR (((anonymous_name LIKE :db_condition_placeholder_0 ESCAPE '\\')) AND ("base_table"."uid" = :db_condition_placeholder_2)) GROUP BY "base_table"."uid" LIMIT 10 OFFSET 0; 

Array  [:db_condition_placeholder_1] => %username% 
[:db_condition_placeholder_0] => %username%     
[:anonymous_name] => Anonyme    
 [:db_condition_placeholder_2] => 0 )  

in Drupal\Core\Entity\Query\Sql\Query->result() (line 272 of /opt/drupal/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php).

Steps to reproduce

Activate the "authored by" field with autocompletion

Proposed resolution

in core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php (line 248), if I remove the

$query->escapeField('anonymous_name')

in the str_replace, I don't have the error anymore.

-   ->where(str_replace($query->escapeField('anonymous_name'), ':anonymous_name', (string) $value_part), $value_part->arguments() + [':anonymous_name' => \Drupal::config('user.settings')->get('anonymous')])

+  ->where(str_replace('anonymous_name', ':anonymous_name', (string) $value_part), $value_part->arguments() + [':anonymous_name' => \Drupal::config('user.settings')->get('anonymous')])

Issue fork drupal-3356845

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mounir_abid created an issue. See original summary.

mounir_abid’s picture

Issue summary: View changes
mounir_abid’s picture

Issue summary: View changes

Ranjit1032002 made their first commit to this issue’s fork.

ranjit1032002’s picture

Status: Active » Needs review

Created MR!3908 for the issue mentioned, please review.
Thank You.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative, +Needs tests

This will need a test case showing the issue.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

dcam’s picture

Status: Needs work » Postponed (maintainer needs more info)
Issue tags: +Needs steps to reproduce

The given steps to reproduce the issue are not sufficient. Please provide step-by-step instructions beginning with a fresh install of Drupal Core. I used the autocomplete Authored By field both while creating and editing content without any error.

smustgrave’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)
Issue tags: +Bug Smash Initiative

Since steps to reproduce haven't been provided going to close this one out. If still a bug please re-open updating summary with steps.