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
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:
- 3356845-error-on-autocompletion
changes, plain diff MR !3908
Comments
Comment #2
mounir_abid commentedComment #3
mounir_abid commentedComment #6
ranjit1032002Created MR!3908 for the issue mentioned, please review.
Thank You.
Comment #7
smustgrave commentedThis will need a test case showing the issue.
Comment #9
dcam commentedThe 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.
Comment #11
smustgrave commentedSince steps to reproduce haven't been provided going to close this one out. If still a bug please re-open updating summary with steps.