Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: use named parameters#54172

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
drupol wants to merge1 commit intosymfony:5.4fromdrupol:cache/doctrinedbaladapter/use-named-parameters
Closed

fix: use named parameters#54172

drupol wants to merge1 commit intosymfony:5.4fromdrupol:cache/doctrinedbaladapter/use-named-parameters

Conversation

@drupol
Copy link
Contributor

@drupoldrupol commentedMar 6, 2024
edited
Loading

QA
Branch?5.4
Bug fix?yes
New feature?no
Deprecations?no
LicenseMIT

Hello!

Today, my colleague@samsonradu and I noticed an issue while using Oracle database and regarding theDoctrineDbalAdapter, potentially introduced by PR#50507.

Basically, by making positional parameters lazily injected, the order of those parameters are no more preserved, and we end up with totally broken SQL queries. Here are more details:

Failed to save key "ulm_ac_rbac_action_roles" of type array: An exception occurred while executingMERGE INTO cache_items USING DUAL ON (item_id = ?) WHEN NOT MATCHED THEN INSERT (item_id, item_data, item_lifetime, item_time) VALUES (?, ?, ?, ?) WHEN MATCHED THEN UPDATE SET item_data = ?, item_lifetime = ?, item_time = ? with params [  3600,   1709126855,   3600,   1709126855,   "EeA4QGjhnZ:ulm_ac_rbac_action_roles",   "EeA4QGjhnZ:ulm_ac_rbac_action_roles",   "\x00...\x69..."]

The introduction of a lazy loading mechanism in this PR has led to issues with the ordering of bound values in SQL statements. New keys added by the lazy loading process are appended at the end of the parameters array, disrupting the intended logical order. See it here:

/app/vendor/symfony/cache/Adapter/DoctrineDbalAdapter.php:354:object(Doctrine\DBAL\Statement)[1878]  protected 'sql' => string 'MERGE INTO cache_items USING DUAL ON (item_id = ?) WHEN NOT MATCHED THEN INSERT (item_id, item_data, item_lifetime, item_time) VALUES (?, ?, ?, ?) WHEN MATCHED THEN UPDATE SET item_data = ?, item_lifetime = ?, item_time = ?' (length=223)  protected 'params' =>     array (size=8)      4 => int 3600      5 => int 1709713419      7 => int 3600      8 => int 1709713419      1 => string 'q55PWWD1R0:ulm_ac_rbac_action_roles' (length=35)      2 => string 'q55PWWD1R0:ulm_ac_rbac_action_roles' (length=35)      3 => string 'value1'      6 => string 'value1'

In here, you can see that theparams are not correctly ordered and this is breaking the SQL query.

IMHO, I think this issue should be fixed indoctrine/dbal with a simpleksort onparams, but I'm not sure, that's the reason why I comment in here.
Alternatively, we could implement explicit parameter mapping instead of positional indexes to ensure each bound value maintains its correct order, regardless of when it's added.

From thedoctrine/dbal doc, I see:

Support for positional and named prepared statements varies between the different database extensions. PDO implements its own client side parser so that both approaches are feasible for all PDO drivers. OCI8/Oracle only supports named parameters, but Doctrine implements a client side parser to allow positional parameters also.

Maybe this is something to fix somewhere else?

@carsonbot
Copy link

Hey!

To help keep things organized, we don't allow "Draft" pull requests. Could you please click the "ready for review" button or close this PR and open a new one when you are done?

Note that a pull request does not have to be "perfect" or "ready for merge" when you first open it. We just want it to be ready for a first review.

Cheers!

Carsonbot

@drupoldrupol changed the base branch from7.1 to5.4March 6, 2024 09:05
@nicolas-grekasnicolas-grekas changed the base branch from5.4 to7.1March 6, 2024 09:08
@drupoldrupol changed the base branch from7.1 to5.4March 6, 2024 09:13
@drupoldrupol marked this pull request as ready for reviewMarch 6, 2024 09:20
@carsonbotcarsonbot added this to the5.4 milestoneMar 6, 2024
Copy link
Member

@derrabusderrabus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I'm fine with the change, but can you please also submit a bug report for DBAL?

@drupol
Copy link
ContributorAuthor

Sure! Will submit a PR there too.

@nicolas-grekas
Copy link
Member

Closing per#50507 (comment) since it ain't broken. Thanks for the heads up.

@drupoldrupol deleted the cache/doctrinedbaladapter/use-named-parameters branchMarch 7, 2024 14:42
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@derrabusderrabusderrabus approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

4 participants

@drupol@carsonbot@nicolas-grekas@derrabus

[8]ページ先頭

©2009-2025 Movatter.jp