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 MartinMystikJonas commented Oct 1, 2018

Fixed cause of #187

@dg
Copy link
Member

@dg dg commented Oct 1, 2018

Wow, thanks!

@dg dg merged commit 6650fbb into nette:master Oct 1, 2018
0 of 2 checks passed
dg pushed a commit that referenced this issue Oct 1, 2018
dg pushed a commit that referenced this issue Oct 1, 2018
dg pushed a commit that referenced this issue Oct 1, 2018
@MartinMystikJonas
Copy link
Contributor Author

@MartinMystikJonas 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
Copy link
Contributor Author

@MartinMystikJonas MartinMystikJonas commented Oct 1, 2018

@Unlink Nevermind. It failed even before this change.

@JanTvrdik
Copy link
Contributor

@JanTvrdik 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
Copy link
Member

@f3l1x f3l1x commented Oct 3, 2018

Yep, I'm interested too.

@MartinMystikJonas
Copy link
Contributor Author

@MartinMystikJonas 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
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants