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

2.6.4. breaks queries using objects as parameters #7827

Closed
kdambekalns opened this issue Sep 23, 2019 · 10 comments
Closed

2.6.4. breaks queries using objects as parameters #7827

kdambekalns opened this issue Sep 23, 2019 · 10 comments

Comments

@kdambekalns
Copy link
Contributor

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.

@Ocramius
Copy link
Member

->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[]?

@kdambekalns
Copy link
Contributor Author

kdambekalns commented 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.

@Ocramius
Copy link
Member

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)?

@kdambekalns kdambekalns changed the title 2.6.4. breaks queries using objects as paarmeters 2.6.4. breaks queries using objects as parameters Sep 23, 2019
kdambekalns added a commit to kdambekalns/neos-development-collection that referenced this issue Sep 23, 2019
This "fixes" doctrine/orm#7827, by
actually passing the correct type as parameter. And the "type
hint" can be removed, as well.
@kdambekalns
Copy link
Contributor Author

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…

@lcobucci
Copy link
Member

@kdambekalns should we close this issue, then?

@kdambekalns
Copy link
Contributor Author

kdambekalns commented Sep 23, 2019

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

@Ocramius Ocramius self-assigned this Sep 23, 2019
neos-bot pushed a commit to neos/typo3cr that referenced this issue Sep 24, 2019
This "fixes" doctrine/orm#7827, by
actually passing the correct type as parameter. And the "type
hint" can be removed, as well.
@snebes
Copy link

snebes commented 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.

@Ocramius
Copy link
Member

$type is blindly accepted without type-checking

This is the correct/expected behavior

@szambonurek
Copy link

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()];
}

@Ocramius
Copy link
Member

@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?

neos-bot pushed a commit to neos/content-repository that referenced this issue Oct 30, 2020
This "fixes" doctrine/orm#7827, by
actually passing the correct type as parameter. And the "type
hint" can be removed, as well.
neos-bot pushed a commit to neos/content-repository that referenced this issue Dec 4, 2020
This "fixes" doctrine/orm#7827, by
actually passing the correct type as parameter. And the "type
hint" can be removed, as well.
neos-bot pushed a commit to neos/content-repository that referenced this issue Oct 7, 2022
This "fixes" doctrine/orm#7827, by
actually passing the correct type as parameter. And the "type
hint" can be removed, as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants