Skip to content

Commit 70d6f8f

Browse files
pfefferlematticbot
andauthored
Improve Surge wp-config handling (#1724)
Co-authored-by: Automattic Bot <[email protected]>
1 parent a29a16e commit 70d6f8f

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: fixed
3+
4+
Improved automated setup process for the Surge caching plugin.

integration/class-surge.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ public static function init() {
3737
* Add the Surge cache config.
3838
*/
3939
public static function add_cache_config() {
40+
if ( \defined( 'WP_CACHE_CONFIG' ) ) {
41+
return;
42+
}
43+
4044
$file = self::get_config_file_path();
4145

4246
if ( ! \wp_is_writable( $file ) ) {
@@ -72,6 +76,10 @@ public static function add_cache_config() {
7276
* Remove the Surge cache config.
7377
*/
7478
public static function remove_cache_config() {
79+
if ( ! \defined( 'WP_CACHE_CONFIG' ) ) {
80+
return;
81+
}
82+
7583
$file = self::get_config_file_path();
7684

7785
if ( ! \wp_is_writable( $file ) ) {

tests/integration/class-test-surge.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ public function get_active_plugins() {
147147
* @access public
148148
*/
149149
public function test_init_with_surge_inactive() {
150+
// Needs to be set, because of the dummy `wp-config.php` file.
151+
\define( 'WP_CACHE_CONFIG', 'dummy' );
150152
// phpcs:ignore
151153
\file_put_contents( Surge::get_config_file_path(), "<?php\n" . Surge::get_cache_config() . "\n\n/* That's all, stop editing! */" );
152154
\add_filter( 'pre_option_active_plugins', array( $this, 'get_inactive_plugins' ) );

0 commit comments

Comments
 (0)