@@ -867,22 +867,24 @@ private function convertationOfOldScriptsIsAllowed(array $request)
867
867
* @param array $request
868
868
* @return void
869
869
*/
870
- public function installDataFixtures (array $ request = [])
870
+ public function installDataFixtures (array $ request = [], $ keepCacheStatuses = false )
871
871
{
872
872
$ frontendCaches = [
873
873
PageCache::TYPE_IDENTIFIER ,
874
874
BlockCache::TYPE_IDENTIFIER ,
875
875
LayoutCache::TYPE_IDENTIFIER ,
876
876
];
877
877
878
- $ cacheManager = $ this ->objectManagerProvider ->get ()->create (\Magento \Framework \App \Cache \Manager::class);
879
- $ disabledCaches = array_filter (
880
- $ cacheManager ->getStatus (),
881
- function ($ value , string $ key ) use ($ frontendCaches ) {
882
- return $ value == false && in_array ($ key , $ frontendCaches );
883
- },
884
- ARRAY_FILTER_USE_BOTH
885
- );
878
+ if ($ keepCacheStatuses ){
879
+ $ cacheManager = $ this ->objectManagerProvider ->get ()->create (\Magento \Framework \App \Cache \Manager::class);
880
+ $ disabledCaches = array_filter (
881
+ $ cacheManager ->getStatus (),
882
+ function ($ value , string $ key ) use ($ frontendCaches ) {
883
+ return $ value == false && in_array ($ key , $ frontendCaches );
884
+ },
885
+ ARRAY_FILTER_USE_BOTH
886
+ );
887
+ }
886
888
887
889
/** @var \Magento\Framework\Registry $registry */
888
890
$ registry = $ this ->objectManagerProvider ->get ()->get (\Magento \Framework \Registry::class);
@@ -899,8 +901,10 @@ function ($value, string $key) use ($frontendCaches) {
899
901
$ this ->handleDBSchemaData ($ setup , 'data ' , $ request );
900
902
$ this ->log ->log ('Enabling caches: ' );
901
903
$ this ->updateCaches (true , $ frontendCaches );
902
- $ this ->log ->log ('Return disabled caches back to their old state: ' );
903
- $ this ->updateCaches (false , array_keys ($ disabledCaches ));
904
+ if ($ keepCacheStatuses && !empty ($ disabledCaches )){
905
+ $ this ->log ->log ('Disabling pre-disabled caches: ' );
906
+ $ this ->updateCaches (false , array_keys ($ disabledCaches ));
907
+ }
904
908
905
909
$ registry ->unregister ('setup-mode-enabled ' );
906
910
}
0 commit comments