18
18
* @copyright Copyright (c) 2016 Fastly, Inc. (http://www.fastly.com)
19
19
* @license BSD, see LICENSE_FASTLY_CDN.txt
20
20
*/
21
+
21
22
namespace Fastly \Cdn \Setup ;
22
23
23
24
use Fastly \Cdn \Helper \Data ;
@@ -94,7 +95,8 @@ public function __construct(
94
95
Data $ helper ,
95
96
ProductMetadataInterface $ productMetadata ,
96
97
SerializerInterface $ serializeInterface
97
- ) {
98
+ )
99
+ {
98
100
$ this ->date = $ date ;
99
101
$ this ->scopeConfig = $ scopeConfig ;
100
102
$ this ->configWriter = $ configWriter ;
@@ -111,7 +113,7 @@ public function __construct(
111
113
*
112
114
*
113
115
* @param ModuleDataSetupInterface $setup
114
- * @param ModuleContextInterface $context*
116
+ * @param ModuleContextInterface $context *
115
117
*/
116
118
public function upgrade (ModuleDataSetupInterface $ setup , ModuleContextInterface $ context )
117
119
{
@@ -122,36 +124,36 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
122
124
}
123
125
124
126
$ oldConfigPaths = [
125
- 'stale_ttl ' => 'system/full_page_cache/fastly/stale_ttl ' ,
126
- 'stale_error_ttl ' => 'system/full_page_cache/fastly/stale_error_ttl ' ,
127
- 'purge_catalog_category ' => 'system/full_page_cache/fastly/purge_catalog_category ' ,
128
- 'purge_catalog_product ' => 'system/full_page_cache/fastly/purge_catalog_product ' ,
129
- 'purge_cms_page ' => 'system/full_page_cache/fastly/purge_cms_page ' ,
130
- 'soft_purge ' => 'system/full_page_cache/fastly/soft_purge ' ,
131
- 'enable_geoip ' => 'system/full_page_cache/fastly/enable_geoip ' ,
132
- 'geoip_action ' => 'system/full_page_cache/fastly/geoip_action ' ,
133
- 'geoip_country_mapping ' => 'system/full_page_cache/fastly/geoip_country_mapping ' ,
127
+ 'stale_ttl ' => 'system/full_page_cache/fastly/stale_ttl ' ,
128
+ 'stale_error_ttl ' => 'system/full_page_cache/fastly/stale_error_ttl ' ,
129
+ 'purge_catalog_category ' => 'system/full_page_cache/fastly/purge_catalog_category ' ,
130
+ 'purge_catalog_product ' => 'system/full_page_cache/fastly/purge_catalog_product ' ,
131
+ 'purge_cms_page ' => 'system/full_page_cache/fastly/purge_cms_page ' ,
132
+ 'soft_purge ' => 'system/full_page_cache/fastly/soft_purge ' ,
133
+ 'enable_geoip ' => 'system/full_page_cache/fastly/enable_geoip ' ,
134
+ 'geoip_action ' => 'system/full_page_cache/fastly/geoip_action ' ,
135
+ 'geoip_country_mapping ' => 'system/full_page_cache/fastly/geoip_country_mapping ' ,
134
136
];
135
137
136
138
$ newConfigPaths = [
137
139
'stale_ttl '
138
- => 'system/full_page_cache/fastly/fastly_advanced_configuration/stale_ttl ' ,
140
+ => 'system/full_page_cache/fastly/fastly_advanced_configuration/stale_ttl ' ,
139
141
'stale_error_ttl '
140
- => 'system/full_page_cache/fastly/fastly_advanced_configuration/stale_error_ttl ' ,
142
+ => 'system/full_page_cache/fastly/fastly_advanced_configuration/stale_error_ttl ' ,
141
143
'purge_catalog_category '
142
- => 'system/full_page_cache/fastly/fastly_advanced_configuration/purge_catalog_category ' ,
144
+ => 'system/full_page_cache/fastly/fastly_advanced_configuration/purge_catalog_category ' ,
143
145
'purge_catalog_product '
144
- => 'system/full_page_cache/fastly/fastly_advanced_configuration/purge_catalog_product ' ,
146
+ => 'system/full_page_cache/fastly/fastly_advanced_configuration/purge_catalog_product ' ,
145
147
'purge_cms_page '
146
- => 'system/full_page_cache/fastly/fastly_advanced_configuration/purge_cms_page ' ,
148
+ => 'system/full_page_cache/fastly/fastly_advanced_configuration/purge_cms_page ' ,
147
149
'soft_purge '
148
- => 'system/full_page_cache/fastly/fastly_advanced_configuration/soft_purge ' ,
150
+ => 'system/full_page_cache/fastly/fastly_advanced_configuration/soft_purge ' ,
149
151
'enable_geoip '
150
- => 'system/full_page_cache/fastly/fastly_advanced_configuration/enable_geoip ' ,
152
+ => 'system/full_page_cache/fastly/fastly_advanced_configuration/enable_geoip ' ,
151
153
'geoip_action '
152
- => 'system/full_page_cache/fastly/fastly_advanced_configuration/geoip_action ' ,
154
+ => 'system/full_page_cache/fastly/fastly_advanced_configuration/geoip_action ' ,
153
155
'geoip_country_mapping '
154
- => 'system/full_page_cache/fastly/fastly_advanced_configuration/geoip_country_mapping '
156
+ => 'system/full_page_cache/fastly/fastly_advanced_configuration/geoip_country_mapping '
155
157
];
156
158
157
159
$ setup ->startSetup ();
@@ -173,6 +175,10 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
173
175
} elseif (version_compare ($ magVer , '2.2 ' , '< ' )) {
174
176
$ setup ->endSetup ();
175
177
}
178
+
179
+ if (version_compare ($ version , '1.0.15 ' , '<= ' )) {
180
+ $ this ->changeConstValueInDb ($ setup );
181
+ }
176
182
}
177
183
178
184
/**
@@ -241,4 +247,31 @@ private function upgrade1010($newConfigPaths)
241
247
$ this ->configWriter ->save ($ newConfigPaths ['geoip_country_mapping ' ], $ newData );
242
248
$ this ->cacheManager ->clean ([\Magento \Framework \App \Cache \Type \Config::TYPE_IDENTIFIER ]);
243
249
}
250
+
251
+ /**
252
+ * Chanhe old const value from 'fastly' to '42'
253
+ *
254
+ * @param ModuleDataSetupInterface $setup
255
+ */
256
+ private function changeConstValueInDb (ModuleDataSetupInterface $ setup ): void
257
+ {
258
+ $ select = $ setup ->getConnection ()->select ()->from (
259
+ $ setup ->getTable ('core_config_data ' ),
260
+ ['value ' ]
261
+ )->where (
262
+ 'path = ? ' ,
263
+ \Magento \PageCache \Model \Config::XML_PAGECACHE_TYPE
264
+ );
265
+ $ value = $ setup ->getConnection ()->fetchOne ($ select );
266
+ if ($ value == 'fastly ' ) {
267
+ $ row = [
268
+ 'value ' => \Fastly \Cdn \Model \Config::FASTLY
269
+ ];
270
+ $ setup ->getConnection ()->update (
271
+ $ setup ->getTable ('core_config_data ' ),
272
+ $ row ,
273
+ ['path = ? ' => \Magento \PageCache \Model \Config::XML_PAGECACHE_TYPE ]
274
+ );
275
+ }
276
+ }
244
277
}
0 commit comments