2.6.4. breaks queries using objects as parameters #6304

Closed
opened 2026-01-22 15:30:26 +01:00 by admin · 10 comments
Owner

Originally created by @kdambekalns on GitHub (Sep 23, 2019).

Originally assigned to: @Ocramius on GitHub.

BC Break Report

Q A
BC Break yes
Version 2.6.4

Summary

Upgrading from 2.6.3 to 2.6.4 triggers an error related to obejct parameters in queries.

Previous behavior

It worked ;)

Current behavior

Catchable Fatal Error: Object of class Neos\ContentRepository\Domain\Model\Workspace could not be converted to string in /application/Packages/Libraries/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php line 77 - See also: 20190923101155fe8fe7.txt
19-09-23 10:12:56 1506       CRITICAL                       Exception in line 145 of /application/Packages/Libraries/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php: An exception occurred while executing 'SELECT n0_.persistence_object_identifier AS persistence_object_identifier_0, n0_.version AS version_1, n0_.pathhash AS pathhash_2, n0_.path AS path_3, n0_.parentpathhash AS parentpathhash_4, n0_.parentpath AS parentpath_5, n0_.identifier AS identifier_6, n0_.sortingindex AS sortingindex_7, n0_.removed AS removed_8, n0_.dimensionshash AS dimensionshash_9, n0_.lastmodificationdatetime AS lastmodificationdatetime_10, n0_.lastpublicationdatetime AS lastpublicationdatetime_11, n0_.hiddenbeforedatetime AS hiddenbeforedatetime_12, n0_.hiddenafterdatetime AS hiddenafterdatetime_13, n0_.dimensionvalues AS dimensionvalues_14, n0_.properties AS properties_15, n0_.nodetype AS nodetype_16, n0_.creationdatetime AS creationdatetime_17, n0_.hidden AS hidden_18, n0_.hiddeninindex AS hiddeninindex_19, n0_.accessroles AS accessroles_20, n0_.workspace AS workspace_21, n0_.contentobjectproxy AS contentobjectproxy_22, n0_.movedto AS movedto_23 FROM neos_contentrepository_domain_model_nodedata n0_ WHERE n0_.workspace IN (?) AND (EXISTS (SELECT n1_.persistence_object_identifier FROM neos_contentrepository_domain_model_nodedimension n1_ WHERE n1_.nodedata = n0_.persistence_object_identifier AND n1_.name = 'language' AND n1_.value IN (?)) OR NOT EXISTS (SELECT n2_.persistence_object_identifier FROM neos_contentrepository_domain_model_nodedimension n2_ WHERE n2_.nodedata = n0_.persistence_object_identifier AND n2_.name = 'language')) AND n0_.pathhash = ?' with params [{"Flow_Injected_Properties":["nodeDataRepository","publishingService","nodeService","now","reflectionService","persistenceManager"]}, "en", "476f5936360c6893a04fe012e80711fb"]:

How to reproduce

Update doctrine/orm from 2.6.3 to 2.6.4 and see it fail. The code is complex, but the main part involved should be:

        $queryBuilder->select('n')
            ->from(NodeData::class, 'n')
            ->where('n.workspace IN (:workspaces)')
            ->setParameter('workspaces', $workspaces, Connection::PARAM_STR_ARRAY);

My wild guess would that the fix #7527 in PR #7528 might cause it.

Originally created by @kdambekalns on GitHub (Sep 23, 2019). Originally assigned to: @Ocramius on GitHub. ### BC Break Report | Q | A |------------ | ------ | BC Break | yes | Version | 2.6.4 #### Summary Upgrading from 2.6.3 to 2.6.4 triggers an error related to obejct parameters in queries. #### Previous behavior It worked ;) #### Current behavior ``` Catchable Fatal Error: Object of class Neos\ContentRepository\Domain\Model\Workspace could not be converted to string in /application/Packages/Libraries/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php line 77 - See also: 20190923101155fe8fe7.txt 19-09-23 10:12:56 1506 CRITICAL Exception in line 145 of /application/Packages/Libraries/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php: An exception occurred while executing 'SELECT n0_.persistence_object_identifier AS persistence_object_identifier_0, n0_.version AS version_1, n0_.pathhash AS pathhash_2, n0_.path AS path_3, n0_.parentpathhash AS parentpathhash_4, n0_.parentpath AS parentpath_5, n0_.identifier AS identifier_6, n0_.sortingindex AS sortingindex_7, n0_.removed AS removed_8, n0_.dimensionshash AS dimensionshash_9, n0_.lastmodificationdatetime AS lastmodificationdatetime_10, n0_.lastpublicationdatetime AS lastpublicationdatetime_11, n0_.hiddenbeforedatetime AS hiddenbeforedatetime_12, n0_.hiddenafterdatetime AS hiddenafterdatetime_13, n0_.dimensionvalues AS dimensionvalues_14, n0_.properties AS properties_15, n0_.nodetype AS nodetype_16, n0_.creationdatetime AS creationdatetime_17, n0_.hidden AS hidden_18, n0_.hiddeninindex AS hiddeninindex_19, n0_.accessroles AS accessroles_20, n0_.workspace AS workspace_21, n0_.contentobjectproxy AS contentobjectproxy_22, n0_.movedto AS movedto_23 FROM neos_contentrepository_domain_model_nodedata n0_ WHERE n0_.workspace IN (?) AND (EXISTS (SELECT n1_.persistence_object_identifier FROM neos_contentrepository_domain_model_nodedimension n1_ WHERE n1_.nodedata = n0_.persistence_object_identifier AND n1_.name = 'language' AND n1_.value IN (?)) OR NOT EXISTS (SELECT n2_.persistence_object_identifier FROM neos_contentrepository_domain_model_nodedimension n2_ WHERE n2_.nodedata = n0_.persistence_object_identifier AND n2_.name = 'language')) AND n0_.pathhash = ?' with params [{"Flow_Injected_Properties":["nodeDataRepository","publishingService","nodeService","now","reflectionService","persistenceManager"]}, "en", "476f5936360c6893a04fe012e80711fb"]: ``` #### How to reproduce Update `doctrine/orm` from 2.6.3 to 2.6.4 and see it fail. The code is complex, but the main part involved should be: ``` $queryBuilder->select('n') ->from(NodeData::class, 'n') ->where('n.workspace IN (:workspaces)') ->setParameter('workspaces', $workspaces, Connection::PARAM_STR_ARRAY); ``` My _wild guess_ would that the fix #7527 in PR #7528 might cause it.
admin added the BugIncompleteMissing Tests labels 2026-01-22 15:30:26 +01:00
admin closed this issue 2026-01-22 15:30:26 +01:00
Author
Owner

@Ocramius commented on GitHub (Sep 23, 2019):

->setParameter('workspaces', $workspaces, Connection::PARAM_STR_ARRAY);

This should indeed not be converted to identifiers, since you're binding a string array, yet declared $workspaces, which I assume is a Workspace[]?

@Ocramius commented on GitHub (Sep 23, 2019): > `->setParameter('workspaces', $workspaces, Connection::PARAM_STR_ARRAY);` This should indeed not be converted to identifiers, since you're binding a string array, yet declared `$workspaces`, which I assume is a `Workspace[]`?
Author
Owner

@kdambekalns commented on GitHub (Sep 23, 2019):

Might be true… I am quite sure we did add that parameter hint on purpose, and it worked before. So… I'll try to fix that.

@kdambekalns commented on GitHub (Sep 23, 2019): Might be true… I am quite sure we did [add that parameter hint on purpose](https://github.com/neos/neos-development-collection/pull/2004), and it worked before. So… I'll try to fix that.
Author
Owner

@Ocramius commented on GitHub (Sep 23, 2019):

Can you maybe come up with a test case verifying your use-case (that is green on 2.6.3, and red on 2.6.4)?

@Ocramius commented on GitHub (Sep 23, 2019): Can you maybe come up with a test case verifying your use-case (that is green on `2.6.3`, and red on `2.6.4`)?
Author
Owner

@kdambekalns commented on GitHub (Sep 23, 2019):

I'll try the test-case, but removing the wrong parameter type hint or actually passing an array of strings solves the issue for our code. So I guess it's really a "side-effect we used so far" that has been removed. Too bad I cannot remeber what we actually fixed back then by adding it…

@kdambekalns commented on GitHub (Sep 23, 2019): I'll try the test-case, but removing the wrong parameter type hint or actually passing an array of strings solves the issue for our code. So I guess it's really a "side-effect we used so far" that has been removed. Too bad I cannot remeber what we actually fixed back then by adding it…
Author
Owner

@lcobucci commented on GitHub (Sep 23, 2019):

@kdambekalns should we close this issue, then?

@lcobucci commented on GitHub (Sep 23, 2019): @kdambekalns should we close this issue, then?
Author
Owner

@kdambekalns commented on GitHub (Sep 23, 2019):

Feel free, if I come around to creating a valid test case, I'll let you know. Thanks!

@kdambekalns commented on GitHub (Sep 23, 2019): Feel free, if I come around to creating a valid test case, I'll let you know. Thanks!
Author
Owner

@snebes commented on GitHub (Sep 25, 2019):

I've outlined this issue in more detail in #7832. In v2.6.3, the $type was verified before being used, where in v2.6.4, the $type is blindly accepted without type-checking.

@snebes commented on GitHub (Sep 25, 2019): I've outlined this issue in more detail in #7832. In v2.6.3, the $type was verified before being used, where in v2.6.4, the $type is blindly accepted without type-checking.
Author
Owner

@Ocramius commented on GitHub (Sep 25, 2019):

$type is blindly accepted without type-checking

This is the correct/expected behavior

@Ocramius commented on GitHub (Sep 25, 2019): > $type is blindly accepted without type-checking This is the correct/expected behavior
Author
Owner

@szambonurek commented on GitHub (Oct 17, 2019):

2.6.4 introduced bc breaking change. This code worked in 2.6.3 and befire. Now it fails

$ids = $qb->getQuery()->getArrayResult()
// ['id' => 1, 'id' => 2]
$qb2->setParameter('ids', $ids, Connection::PARAM_INT_ARRAY);

This change is causig this:
\Doctrine\ORM\Query::resolveParameterValue::435

if ($parameter->typeWasSpecified()) {
     return [$parameter->getValue(), $parameter->getType()];
}
@szambonurek commented on GitHub (Oct 17, 2019): 2.6.4 introduced bc breaking change. This code worked in 2.6.3 and befire. Now it fails ``` $ids = $qb->getQuery()->getArrayResult() // ['id' => 1, 'id' => 2] $qb2->setParameter('ids', $ids, Connection::PARAM_INT_ARRAY); ``` This change is causig this: **\Doctrine\ORM\Query::resolveParameterValue::435** ``` if ($parameter->typeWasSpecified()) { return [$parameter->getValue(), $parameter->getType()]; } ```
Author
Owner

@Ocramius commented on GitHub (Oct 17, 2019):

@szambonurek can you write a test case? I cannot see parameter binding in your example (specifically, query and parameter format)

$ids is supposed to be an int[] there: what do you have instead?

@Ocramius commented on GitHub (Oct 17, 2019): @szambonurek can you write a test case? I cannot see parameter binding in your example (specifically, query and parameter format) `$ids` is supposed to be an `int[]` there: what do you have instead?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6304