Skip to content

Conversation

@MartinMystikJonas
Copy link
Contributor

Fixed cause of #187

@dg
Copy link
Member

dg commented Oct 1, 2018

Wow, thanks!

@dg dg merged commit 6650fbb into nette:master Oct 1, 2018
dg pushed a commit that referenced this pull request Oct 1, 2018
dg pushed a commit that referenced this pull request Oct 1, 2018
dg pushed a commit that referenced this pull request Oct 1, 2018
@MartinMystikJonas
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
Copy link
Contributor Author

@Unlink Nevermind. It failed even before this change.

@JanTvrdik
Copy link
Contributor

@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 commented Oct 3, 2018

Yep, I'm interested too.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants