From c3314bff9b5f1a3536f5b0a1e9dee1da43c651d8 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 19 Jan 2026 11:13:06 +0100 Subject: [PATCH 1/2] Spring cleaning --- .travis.yml | 73 ------------------------ behat.yml | 7 +++ composer.json | 15 +++-- phpcs.xml.dist | 92 ++++++++++++++----------------- src/WP_Super_Cache_CLI_Loader.php | 10 +++- src/WP_Super_Cache_Command.php | 6 +- wp-super-cache-cli.php | 6 +- 7 files changed, 75 insertions(+), 134 deletions(-) delete mode 100644 .travis.yml create mode 100644 behat.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9f1b70c..0000000 --- a/.travis.yml +++ /dev/null @@ -1,73 +0,0 @@ -sudo: false -dist: trusty - -language: php -php: 7.2 - -notifications: - email: - on_success: never - on_failure: change - -branches: - only: - - master - -cache: - directories: - - $HOME/.composer/cache - -env: - global: - - PATH="$TRAVIS_BUILD_DIR/vendor/bin:$PATH" - - WP_CLI_BIN_DIR="$TRAVIS_BUILD_DIR/vendor/bin" - -before_install: - - | - # Remove Xdebug for a huge performance increase: - if [ -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ]; then - phpenv config-rm xdebug.ini - else - echo "xdebug.ini does not exist" - fi - - | - # Raise PHP memory limit to 2048MB - echo 'memory_limit = 2048M' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - - composer validate - -install: - - composer install - - composer prepare-tests - -script: - - composer phpunit - - composer behat - -jobs: - include: - - stage: sniff - script: - - composer lint - - composer phpcs - env: BUILD=sniff - - stage: test - php: 7.2 - env: WP_VERSION=latest - - stage: test - php: 7.1 - env: WP_VERSION=latest - - stage: test - php: 7.0 - env: WP_VERSION=latest - - stage: test - php: 5.6 - env: WP_VERSION=latest - - stage: test - php: 5.6 - env: WP_VERSION=3.7.11 - - stage: test - php: 5.6 - env: WP_VERSION=trunk - - stage: test - php: 5.4 - env: WP_VERSION=5.1 diff --git a/behat.yml b/behat.yml new file mode 100644 index 0000000..d6ee862 --- /dev/null +++ b/behat.yml @@ -0,0 +1,7 @@ +default: + suites: + default: + contexts: + - WP_CLI\Tests\Context\FeatureContext + paths: + - features diff --git a/composer.json b/composer.json index a938f95..af60977 100644 --- a/composer.json +++ b/composer.json @@ -17,21 +17,20 @@ } ], "require": { - "php": ">=5.4", + "php": ">=7.2", "wp-cli/wp-cli": "^2" }, "require-dev": { "wp-cli/extension-command": "^2", - "wp-cli/wp-cli-tests": "^2.0.7" + "wp-cli/wp-cli-tests": "^5" }, "config": { - "platform": { - "php": "5.4" - }, + "lock": false, "process-timeout": 7200, "sort-packages": true, "allow-plugins": { - "dealerdirect/phpcodesniffer-composer-installer": true + "dealerdirect/phpcodesniffer-composer-installer": true, + "phpstan/extension-installer": true } }, "autoload": { @@ -46,13 +45,17 @@ "prefer-stable": true, "scripts": { "behat": "run-behat-tests", + "behat-rerun": "rerun-behat-tests", "lint": "run-linter-tests", "phpcs": "run-phpcs-tests", + "phpstan": "run-phpstan-tests", + "phpcbf": "run-phpcbf-cleanup", "phpunit": "run-php-unit-tests", "prepare-tests": "install-package-tests", "test": [ "@lint", "@phpcs", + "@phpstan", "@phpunit", "@behat" ] diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 4252e09..0a98170 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -1,61 +1,53 @@ - - Custom ruleset for WP-CLI + + Custom ruleset for WP-CLI core-command + + + + + . - - + + - - . - - */.git/* - */ci/* - */features/* - */packages/* - */tests/* - */utils/* - */vendor/* - - - - - - - - - - - - - - + + - - + + - - - */php/commands/src/CLI_Command.php - + - - - - - - - + + + + + + - - + + - + + + + - diff --git a/src/WP_Super_Cache_CLI_Loader.php b/src/WP_Super_Cache_CLI_Loader.php index 1f463d0..8272b23 100755 --- a/src/WP_Super_Cache_CLI_Loader.php +++ b/src/WP_Super_Cache_CLI_Loader.php @@ -75,6 +75,7 @@ private function register_hooks() { * @return void */ public function init_cache_base() { + // phpcs:ignore WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase global $WPSC_HTTP_HOST; if ( ! defined( 'WPCACHEHOME' ) ) { @@ -89,6 +90,7 @@ public function init_cache_base() { $_SERVER['HTTP_HOST'] = $this->parse_home_url( PHP_URL_HOST ); } + // phpcs:ignore WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase if ( empty( $WPSC_HTTP_HOST ) ) { $this->maybe_include_file( 'include', 'wp-cache-base.php' ); } @@ -120,6 +122,7 @@ private function maybe_load_config() { WP_CLI::warning( 'Default cache config file loaded - ' . str_replace( ABSPATH, '', $wp_cache_config_file_sample ) ); } + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound $wp_cache_home_path = trailingslashit( $this->parse_home_url( PHP_URL_PATH ) ); } @@ -186,6 +189,7 @@ private function multisite_override_settings() { if ( ! is_multisite() ) { // Prevents PHP notices for single site installation. if ( ! isset( $blog_cache_dir ) ) { + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound $blog_cache_dir = $cache_path; } @@ -193,7 +197,9 @@ private function multisite_override_settings() { } if ( is_object( $current_site ) ) { - $blogcacheid = trim( is_subdomain_install() ? $current_site->domain : $current_site->path, '/' ); + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound + $blogcacheid = trim( is_subdomain_install() ? $current_site->domain : $current_site->path, '/' ); + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound $blog_cache_dir = $cache_path . 'blogs/' . $blogcacheid . '/'; } } @@ -241,6 +247,7 @@ private function maybe_include_file( $func, $filename, $run = '' ) { global $wp_cache_mobile, $wp_cache_mobile_enabled, $wp_cache_mobile_browsers, $wp_cache_mobile_prefixes; // Globals from other files. global $wp_cache_config_file, $wp_cache_config_file_sample, $cache_domain_mapping; + // phpcs:ignore WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase global $WPSC_HTTP_HOST, $blogcacheid, $blog_cache_dir; $file = $this->get_wpsc_filename( $filename ); @@ -338,6 +345,7 @@ private function is_wpsc_plugin_active() { private function parse_home_url( $component ) { return function_exists( 'wp_parse_url' ) ? (string) wp_parse_url( get_option( 'home' ), $component ) + // phpcs:ignore WordPress.WP.AlternativeFunctions.parse_url_parse_url : (string) parse_url( get_option( 'home' ), $component ); } } diff --git a/src/WP_Super_Cache_Command.php b/src/WP_Super_Cache_Command.php index 4ce03c5..15390f1 100644 --- a/src/WP_Super_Cache_Command.php +++ b/src/WP_Super_Cache_Command.php @@ -92,6 +92,7 @@ public function status( $args = array(), $assoc_args = array() ) { $cache_stats = get_option( 'supercache_stats' ); if ( ! empty( $cache_stats ) ) { if ( $cache_stats['generated'] > time() - 3600 * 24 ) { + // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date WP_CLI::line( 'Cache content on ' . date( 'r', $cache_stats['generated'] ) . ': ' ); WP_CLI::line(); WP_CLI::line( ' WordPress cache:' ); @@ -176,7 +177,10 @@ public function preload( $args = array(), $assoc_args = array() ) { WP_CLI::error( 'The WP Super Cache is not enabled.' ); } - if ( defined( 'DISABLESUPERCACHEPRELOADING' ) && true == DISABLESUPERCACHEPRELOADING ) { + if ( + defined( 'DISABLESUPERCACHEPRELOADING' ) && + ( true === DISABLESUPERCACHEPRELOADING || 'true' === DISABLESUPERCACHEPRELOADING ) + ) { WP_CLI::error( 'Cache preloading is not enabled.' ); } diff --git a/wp-super-cache-cli.php b/wp-super-cache-cli.php index 81a0ffe..db79821 100644 --- a/wp-super-cache-cli.php +++ b/wp-super-cache-cli.php @@ -1,9 +1,9 @@ Date: Mon, 19 Jan 2026 11:30:51 +0100 Subject: [PATCH 2/2] Plugin requires WP 6.7 these days --- .github/workflows/testing.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 1044b79..2752bbf 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -12,3 +12,5 @@ on: jobs: test: uses: wp-cli/.github/.github/workflows/reusable-testing.yml@main + with: + minimum-wp: 6.7