Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix missing null check on AbstractQuery#setResultCacheProfile()#6748

Merged
lcobucci merged 1 commit into
doctrine:masterfrom
KonstantinKuklin:patch1
Dec 17, 2017
Merged

Fix missing null check on AbstractQuery#setResultCacheProfile()#6748
lcobucci merged 1 commit into
doctrine:masterfrom
KonstantinKuklin:patch1

Conversation

@KonstantinKuklin
Copy link
Copy Markdown
Contributor

subject

@Ocramius
Copy link
Copy Markdown
Member

Ocramius commented Oct 4, 2017

While the failure is trivial, we still need a test case for this

@KonstantinKuklin
Copy link
Copy Markdown
Contributor Author

@Ocramius done

Comment thread tests/Doctrine/Tests/ORM/QueryTest.php Outdated
{
$query = $this->_em->createQuery('SELECT u FROM ' . CmsUser::class . ' u');
$result = $query->setResultCacheProfile(null);
self::assertEquals($result, $query);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should be using $this instead of self:: like the rest of the code base right?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Strictly speaking, the assert* methods in PHPUnit are static, so they should be called using self::assert*, not $this->assert*. IIRC @Ocramius and @lcobucci have started changing these in new tests and for v3.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't we assert that the cache profile was NOT configured?

@KonstantinKuklin
Copy link
Copy Markdown
Contributor Author

so, any updates here guys?
@Ocramius , @jwage

Comment thread tests/Doctrine/Tests/ORM/QueryTest.php Outdated
/**
* setResultCacheProfile should works correct with null
*/
public function testSetResultCacheProfile()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment thread tests/Doctrine/Tests/ORM/QueryTest.php Outdated
public function testSetResultCacheProfile()
{
$query = $this->_em->createQuery('SELECT u FROM ' . CmsUser::class . ' u');
$result = $query->setResultCacheProfile(null);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a bit misleading, $result is not the query result but rather the query

Comment thread tests/Doctrine/Tests/ORM/QueryTest.php Outdated
{
$query = $this->_em->createQuery('SELECT u FROM ' . CmsUser::class . ' u');
$result = $query->setResultCacheProfile(null);
self::assertEquals($result, $query);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't we assert that the cache profile was NOT configured?

@Majkl578
Copy link
Copy Markdown
Contributor

Majkl578 commented Dec 8, 2017

Linking #6861 fixing the same bug, but missing tests.

To ensure that `AbstractQuery#setResultCacheProfile()` doesn't raise
errors when being called with `null`.
lcobucci added a commit to lcobucci/doctrine2 that referenced this pull request Dec 17, 2017
@lcobucci lcobucci added this to the 2.5.14 milestone Dec 17, 2017
@lcobucci lcobucci self-assigned this Dec 17, 2017
@lcobucci lcobucci changed the title insufficient variable checks Fix missing null check on AbstractQuery#setResultCacheProfile() Dec 17, 2017
@lcobucci lcobucci merged commit c4a5e5c into doctrine:master Dec 17, 2017
@lcobucci
Copy link
Copy Markdown
Member

@KonstantinKuklin 🚢 and backported via 56ebf4b, thanks for your contribution!

@KonstantinKuklin KonstantinKuklin deleted the patch1 branch December 17, 2017 04:46
BourotBenjamin added a commit to BourotBenjamin/doctrine2 that referenced this pull request Dec 21, 2017
v2.5.14

This version backports bugfixes related to the generation of queries with joins
and configuration of the result set cache profile of a query.

Total issues resolved: **2**

Bug

- [6748: Fix missing null check on `AbstractQuery#setResultCacheProfile()`](doctrine#6748) thanks to @KonstantinKuklin
- [6812: Fix syntax error when join unrelated entity with discriminator entity](doctrine#6812) thanks to @Deltachaos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants