2020use Magento \Store \Model \Config \Processor \Fallback ;
2121use Magento \Framework \Encryption \Encryptor ;
2222use Magento \Store \Model \ScopeInterface as StoreScope ;
23+ use Magento \Framework \App \Cache \StateInterface ;
24+ use Magento \Framework \App \Cache \Type \Config ;
2325
2426/**
2527 * System configuration type
@@ -98,6 +100,12 @@ class System implements ConfigTypeInterface
98100 private $ lockQuery ;
99101
100102 /**
103+ * @var StateInterface
104+ */
105+ private $ cacheState ;
106+
107+ /**
108+ * System constructor.
101109 * @param ConfigSourceInterface $source
102110 * @param PostProcessorInterface $postProcessor
103111 * @param Fallback $fallback
@@ -110,6 +118,7 @@ class System implements ConfigTypeInterface
110118 * @param Encryptor|null $encryptor
111119 * @param LockManagerInterface|null $locker
112120 * @param LockGuardedCacheLoader|null $lockQuery
121+ * @param StateInterface|null $cacheState
113122 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
114123 * @SuppressWarnings(PHPMD.ExcessiveParameterList)
115124 */
@@ -125,7 +134,8 @@ public function __construct(
125134 Reader $ reader = null ,
126135 Encryptor $ encryptor = null ,
127136 LockManagerInterface $ locker = null ,
128- LockGuardedCacheLoader $ lockQuery = null
137+ LockGuardedCacheLoader $ lockQuery = null ,
138+ StateInterface $ cacheState = null
129139 ) {
130140 $ this ->postProcessor = $ postProcessor ;
131141 $ this ->cache = $ cache ;
@@ -136,6 +146,8 @@ public function __construct(
136146 ?: ObjectManager::getInstance ()->get (Encryptor::class);
137147 $ this ->lockQuery = $ lockQuery
138148 ?: ObjectManager::getInstance ()->get (LockGuardedCacheLoader::class);
149+ $ this ->cacheState = $ cacheState
150+ ?: ObjectManager::getInstance ()->get (StateInterface::class);
139151 }
140152
141153 /**
@@ -220,6 +232,10 @@ private function getWithParts($path)
220232 */
221233 private function loadAllData ()
222234 {
235+ if (!$ this ->cacheState ->isEnabled (Config::TYPE_IDENTIFIER )) {
236+ return $ this ->readData ();
237+ }
238+
223239 $ loadAction = function () {
224240 $ cachedData = $ this ->cache ->load ($ this ->configType );
225241 $ data = false ;
@@ -245,6 +261,10 @@ private function loadAllData()
245261 */
246262 private function loadDefaultScopeData ($ scopeType )
247263 {
264+ if (!$ this ->cacheState ->isEnabled (Config::TYPE_IDENTIFIER )) {
265+ return $ this ->readData ();
266+ }
267+
248268 $ loadAction = function () use ($ scopeType ) {
249269 $ cachedData = $ this ->cache ->load ($ this ->configType . '_ ' . $ scopeType );
250270 $ scopeData = false ;
@@ -271,6 +291,10 @@ private function loadDefaultScopeData($scopeType)
271291 */
272292 private function loadScopeData ($ scopeType , $ scopeId )
273293 {
294+ if (!$ this ->cacheState ->isEnabled (Config::TYPE_IDENTIFIER )) {
295+ return $ this ->readData ();
296+ }
297+
274298 $ loadAction = function () use ($ scopeType , $ scopeId ) {
275299 $ cachedData = $ this ->cache ->load ($ this ->configType . '_ ' . $ scopeType . '_ ' . $ scopeId );
276300 $ scopeData = false ;
@@ -393,6 +417,10 @@ public function clean()
393417 $ this ->cache ->clean (\Zend_Cache::CLEANING_MODE_MATCHING_TAG , [self ::CACHE_TAG ]);
394418 };
395419
420+ if (!$ this ->cacheState ->isEnabled (Config::TYPE_IDENTIFIER )) {
421+ return $ cleanAction ();
422+ }
423+
396424 $ this ->lockQuery ->lockedCleanData (
397425 self ::$ lockName ,
398426 $ cleanAction
0 commit comments