20
20
use Magento \Store \Model \Config \Processor \Fallback ;
21
21
use Magento \Framework \Encryption \Encryptor ;
22
22
use Magento \Store \Model \ScopeInterface as StoreScope ;
23
+ use Magento \Framework \App \Cache \StateInterface ;
24
+ use Magento \Framework \App \Cache \Type \Config ;
23
25
24
26
/**
25
27
* System configuration type
@@ -98,6 +100,12 @@ class System implements ConfigTypeInterface
98
100
private $ lockQuery ;
99
101
100
102
/**
103
+ * @var StateInterface
104
+ */
105
+ private $ cacheState ;
106
+
107
+ /**
108
+ * System constructor.
101
109
* @param ConfigSourceInterface $source
102
110
* @param PostProcessorInterface $postProcessor
103
111
* @param Fallback $fallback
@@ -110,6 +118,7 @@ class System implements ConfigTypeInterface
110
118
* @param Encryptor|null $encryptor
111
119
* @param LockManagerInterface|null $locker
112
120
* @param LockGuardedCacheLoader|null $lockQuery
121
+ * @param StateInterface|null $cacheState
113
122
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
114
123
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
115
124
*/
@@ -125,7 +134,8 @@ public function __construct(
125
134
Reader $ reader = null ,
126
135
Encryptor $ encryptor = null ,
127
136
LockManagerInterface $ locker = null ,
128
- LockGuardedCacheLoader $ lockQuery = null
137
+ LockGuardedCacheLoader $ lockQuery = null ,
138
+ StateInterface $ cacheState = null
129
139
) {
130
140
$ this ->postProcessor = $ postProcessor ;
131
141
$ this ->cache = $ cache ;
@@ -136,6 +146,8 @@ public function __construct(
136
146
?: ObjectManager::getInstance ()->get (Encryptor::class);
137
147
$ this ->lockQuery = $ lockQuery
138
148
?: ObjectManager::getInstance ()->get (LockGuardedCacheLoader::class);
149
+ $ this ->cacheState = $ cacheState
150
+ ?: ObjectManager::getInstance ()->get (StateInterface::class);
139
151
}
140
152
141
153
/**
@@ -220,6 +232,10 @@ private function getWithParts($path)
220
232
*/
221
233
private function loadAllData ()
222
234
{
235
+ if (!$ this ->cacheState ->isEnabled (Config::TYPE_IDENTIFIER )) {
236
+ return $ this ->readData ();
237
+ }
238
+
223
239
$ loadAction = function () {
224
240
$ cachedData = $ this ->cache ->load ($ this ->configType );
225
241
$ data = false ;
@@ -245,6 +261,10 @@ private function loadAllData()
245
261
*/
246
262
private function loadDefaultScopeData ($ scopeType )
247
263
{
264
+ if (!$ this ->cacheState ->isEnabled (Config::TYPE_IDENTIFIER )) {
265
+ return $ this ->readData ();
266
+ }
267
+
248
268
$ loadAction = function () use ($ scopeType ) {
249
269
$ cachedData = $ this ->cache ->load ($ this ->configType . '_ ' . $ scopeType );
250
270
$ scopeData = false ;
@@ -271,6 +291,10 @@ private function loadDefaultScopeData($scopeType)
271
291
*/
272
292
private function loadScopeData ($ scopeType , $ scopeId )
273
293
{
294
+ if (!$ this ->cacheState ->isEnabled (Config::TYPE_IDENTIFIER )) {
295
+ return $ this ->readData ();
296
+ }
297
+
274
298
$ loadAction = function () use ($ scopeType , $ scopeId ) {
275
299
$ cachedData = $ this ->cache ->load ($ this ->configType . '_ ' . $ scopeType . '_ ' . $ scopeId );
276
300
$ scopeData = false ;
@@ -393,6 +417,10 @@ public function clean()
393
417
$ this ->cache ->clean (\Zend_Cache::CLEANING_MODE_MATCHING_TAG , [self ::CACHE_TAG ]);
394
418
};
395
419
420
+ if (!$ this ->cacheState ->isEnabled (Config::TYPE_IDENTIFIER )) {
421
+ return $ cleanAction ();
422
+ }
423
+
396
424
$ this ->lockQuery ->lockedCleanData (
397
425
self ::$ lockName ,
398
426
$ cleanAction
0 commit comments