@@ -59,9 +59,6 @@ class Selection implements \Iterator, IRowContainer, \ArrayAccess, \Countable
5959 /** @var string */
6060 protected $ generalCacheKey ;
6161
62- /** @var array */
63- protected $ generalCacheTraceKey ;
64-
6562 /** @var string */
6663 protected $ specificCacheKey ;
6764
@@ -618,20 +615,20 @@ protected function query($query)
618615 }
619616
620617
621- protected function emptyResultSet ($ saveCache = TRUE , $ deleteRererencedCache = TRUE )
618+ protected function emptyResultSet ($ clearCache = TRUE , $ deleteRererencedCache = TRUE )
622619 {
623- if ($ this ->rows !== NULL && $ saveCache ) {
620+ if ($ this ->rows !== NULL && $ clearCache ) {
624621 $ this ->saveCacheState ();
625622 }
626623
627- if ($ saveCache ) {
628- // null only if missing some column
629- $ this ->generalCacheTraceKey = NULL ;
624+ if ($ clearCache ) {
625+ // not null in case of missing some column
626+ $ this ->previousAccessedColumns = NULL ;
627+ $ this ->generalCacheKey = NULL ;
630628 }
631629
632630 $ this ->rows = NULL ;
633631 $ this ->specificCacheKey = NULL ;
634- $ this ->generalCacheKey = NULL ;
635632 $ this ->refCache ['referencingPrototype ' ] = [];
636633 if ($ deleteRererencedCache ) {
637634 $ this ->refCache ['referenced ' ] = [];
@@ -687,15 +684,12 @@ protected function getGeneralCacheKey()
687684 }
688685
689686 $ key = [__CLASS__ , $ this ->name , $ this ->sqlBuilder ->getConditions ()];
690- if (!$ this ->generalCacheTraceKey ) {
691- $ trace = [];
692- foreach (debug_backtrace (DEBUG_BACKTRACE_IGNORE_ARGS ) as $ item ) {
693- $ trace [] = isset ($ item ['file ' ], $ item ['line ' ]) ? $ item ['file ' ] . $ item ['line ' ] : NULL ;
694- };
695- $ this ->generalCacheTraceKey = $ trace ;
696- }
687+ $ trace = [];
688+ foreach (debug_backtrace (DEBUG_BACKTRACE_IGNORE_ARGS ) as $ item ) {
689+ $ trace [] = isset ($ item ['file ' ], $ item ['line ' ]) ? $ item ['file ' ] . $ item ['line ' ] : NULL ;
690+ };
697691
698- $ key [] = $ this -> generalCacheTraceKey ;
692+ $ key [] = $ trace ;
699693 return $ this ->generalCacheKey = md5 (serialize ($ key ));
700694 }
701695
@@ -735,8 +729,6 @@ public function accessColumn($key, $selectColumn = TRUE)
735729 }
736730
737731 if ($ selectColumn && $ this ->previousAccessedColumns && ($ key === NULL || !isset ($ this ->previousAccessedColumns [$ key ])) && !$ this ->sqlBuilder ->getSelect ()) {
738- $ this ->previousAccessedColumns = [];
739-
740732 if ($ this ->sqlBuilder ->getLimit ()) {
741733 $ generalCacheKey = $ this ->generalCacheKey ;
742734 $ sqlBuilder = $ this ->sqlBuilder ;
@@ -753,10 +745,12 @@ public function accessColumn($key, $selectColumn = TRUE)
753745 $ this ->wherePrimary ($ primaryValues );
754746
755747 $ this ->generalCacheKey = $ generalCacheKey ;
748+ $ this ->previousAccessedColumns = [];
756749 $ this ->execute ();
757750 $ this ->sqlBuilder = $ sqlBuilder ;
758751 } else {
759752 $ this ->emptyResultSet (FALSE );
753+ $ this ->previousAccessedColumns = [];
760754 $ this ->execute ();
761755 }
762756
0 commit comments