@@ -867,22 +867,24 @@ private function convertationOfOldScriptsIsAllowed(array $request)
867867 * @param array $request
868868 * @return void
869869 */
870- public function installDataFixtures (array $ request = [])
870+ public function installDataFixtures (array $ request = [], $ keepCacheStatuses = false )
871871 {
872872 $ frontendCaches = [
873873 PageCache::TYPE_IDENTIFIER ,
874874 BlockCache::TYPE_IDENTIFIER ,
875875 LayoutCache::TYPE_IDENTIFIER ,
876876 ];
877877
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+ }
886888
887889 /** @var \Magento\Framework\Registry $registry */
888890 $ registry = $ this ->objectManagerProvider ->get ()->get (\Magento \Framework \Registry::class);
@@ -899,8 +901,10 @@ function ($value, string $key) use ($frontendCaches) {
899901 $ this ->handleDBSchemaData ($ setup , 'data ' , $ request );
900902 $ this ->log ->log ('Enabling caches: ' );
901903 $ 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+ }
904908
905909 $ registry ->unregister ('setup-mode-enabled ' );
906910 }
0 commit comments