Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escaping in createNode() changed with PHP 8.1 #642

Open
sboden opened this issue Mar 14, 2023 · 0 comments
Open

Escaping in createNode() changed with PHP 8.1 #642

sboden opened this issue Mar 14, 2023 · 0 comments

Comments

@sboden
Copy link

sboden commented Mar 14, 2023

I'm using RawNodeContext::nodeCreate() to create a bundle that has an entity reference. This worked in Drupal 8/PHP 7. When upgrading to Drupal 9/PHP 8.1 my behats break.

As title of the entity reference to create in the bundle I used "0000000000 \- Enterprise". The actual title of the reference is "0000000000 - Behat enterprise". When I use the title without the "\" I get a "number of bound variables does not match number of tokens" error which I also had in Drupal 8/PHP 7. The difference is that "0000000000 \- Enterprise" now results in a query:


SELECT "base_table"."vid" AS "vid", "base_table"."nid" AS "nid"
FROM
"node" "base_table"
INNER JOIN "node_field_data" "node_field_data" ON "node_field_data"."nid" = "base_table"."nid"
│ WHERE ("node_field_data"."title" LIKE '0000000000 \\\\- Behat enterprise' ESCAPE '\\') AND ("node_field_data"."type" IN ('enterprise'))

4 \'s in the query for the title of the reference instead of the 2 \'s I would expect. The query with the 4 \'s doesn't match anything, when I manually change the query to 2 \'s I get the data I expect. 

Because of PHP 8 something seems to double escape.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant