From f7ab4a8595b729ed93c9f3e56b8657364c446b97 Mon Sep 17 00:00:00 2001 From: Hynek Vilimek Date: Wed, 27 May 2015 12:57:09 +0200 Subject: [PATCH] Selection: emptyResultSet invalidates referenced cache cs --- src/Database/Table/Selection.php | 1 + .../Table/bugs/Selection.emptyResultSet.phpt | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 tests/Database/Table/bugs/Selection.emptyResultSet.phpt diff --git a/src/Database/Table/Selection.php b/src/Database/Table/Selection.php index 01d61b19a..9c5f6af26 100644 --- a/src/Database/Table/Selection.php +++ b/src/Database/Table/Selection.php @@ -557,6 +557,7 @@ protected function emptyResultSet($saveCache = TRUE) $this->specificCacheKey = NULL; $this->generalCacheKey = NULL; $this->refCache['referencingPrototype'] = []; + $this->refCache['referenced'] = []; } diff --git a/tests/Database/Table/bugs/Selection.emptyResultSet.phpt b/tests/Database/Table/bugs/Selection.emptyResultSet.phpt new file mode 100644 index 000000000..1aa5f8764 --- /dev/null +++ b/tests/Database/Table/bugs/Selection.emptyResultSet.phpt @@ -0,0 +1,26 @@ +table('book'); + $selection->get(2)->author->name; //reading via reference + + $context->table('book')->get(2)->author->update(['name' => 'New name']); + $context->table('book')->get(2)->update(['title' => 'New book title']); + + $selection->limit(NULL); //should invalidate cache of data and references + $book = $selection->get(2); + + Assert::same('New book title', $book->title); //data cache invalidated + Assert::same('New name', $book->author->name); //references NOT invalidated +});