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

Fixed accidental deletion of referenced cached rows when emptyResultSet is called #207

Merged
merged 3 commits into from Oct 1, 2018

Conversation

@MartinMystikJonas
Copy link
Contributor

MartinMystikJonas commented Oct 1, 2018

Fixed cause of #187

Adam Eda Zemek and others added 3 commits Sep 29, 2018
Adam Eda Zemek
…et is called (cause of #187)
@dg

This comment has been minimized.

Copy link
Member

dg commented Oct 1, 2018

Wow, thanks!

@dg dg merged commit 6650fbb into nette:master Oct 1, 2018
0 of 2 checks passed
0 of 2 checks passed
continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
dg added a commit that referenced this pull request Oct 1, 2018
…mptyResultSet is called (#187)(#207)
dg added a commit that referenced this pull request Oct 1, 2018
…mptyResultSet is called (#187)(#207)
dg added a commit that referenced this pull request Oct 1, 2018
…mptyResultSet is called (#187)(#207)
@MartinMystikJonas

This comment has been minimized.

Copy link
Contributor Author

MartinMystikJonas commented Oct 1, 2018

@Unlink This fix causes test deleteCahceBug to fail on sqlsrv. But I'm not sure what exactly is tested on line 61 where exception 'Nette\InvalidStateException: Database refetch failed; row with signature '4' does not exist!' is thrown. Could you please explain if it is problem?

@MartinMystikJonas

This comment has been minimized.

Copy link
Contributor Author

MartinMystikJonas commented Oct 1, 2018

@Unlink Nevermind. It failed even before this change.

@JanTvrdik

This comment has been minimized.

Copy link
Contributor

JanTvrdik commented Oct 2, 2018

@MartinMystikJonas May I ask how does the fix work? Why assigning null by reference is different to assigning null directly?

@f3l1x

This comment has been minimized.

Copy link
Member

f3l1x commented Oct 3, 2018

Yep, I'm interested too.

@MartinMystikJonas

This comment has been minimized.

Copy link
Contributor Author

MartinMystikJonas commented Oct 14, 2018

@JanTvrdik @f3l1x

@MartinMystikJonas May I ask how does the fix work? Why assigning null by reference is different to assigning null directly?

$cachedRows = [1,2,3];
$rows = &$cachedRows;
$rows = null;
// $rows = null
// $cachedRows = null

vs

$cachedRows = [1,2,3];
$rows = &$cachedRows;
$null = null;
$rows = &$null;
// $rows = null
// $cachedRows = [1,2,3]

When $rows value is reference to cache and null is assigned then referenced data in cache are corrupted. Assigning new reference moves reference to different location and left cached data intact.

Rows have assigned value by reference from cache here:

$this->rows = &$referencing[$hash]['rows'];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.