Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ on:
jobs:
test:
uses: wp-cli/.github/.github/workflows/reusable-testing.yml@main
with:
minimum-wp: 6.7
73 changes: 0 additions & 73 deletions .travis.yml

This file was deleted.

7 changes: 7 additions & 0 deletions behat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
default:
suites:
default:
contexts:
- WP_CLI\Tests\Context\FeatureContext
paths:
- features
15 changes: 9 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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"
]
Expand Down
92 changes: 42 additions & 50 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -1,61 +1,53 @@
<?xml version="1.0"?>
<ruleset name="WP-CLI">
<description>Custom ruleset for WP-CLI</description>
<ruleset name="WP-CLI-core">
<description>Custom ruleset for WP-CLI core-command</description>

<!--
#############################################################################
COMMAND LINE ARGUMENTS
For help understanding this file: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml
For help using PHPCS: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage
#############################################################################
-->

<!-- What to scan. -->
<file>.</file>

<!-- For help in understanding this file: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
<!-- For help in using PHPCS: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage -->
<!-- Show progress. -->
<arg value="p"/>

<!-- What to scan -->
<file>.</file>
<!-- Ignoring Files and Folders:
https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-files-and-folders -->
<exclude-pattern>*/.git/*</exclude-pattern>
<exclude-pattern>*/ci/*</exclude-pattern>
<exclude-pattern>*/features/*</exclude-pattern>
<exclude-pattern>*/packages/*</exclude-pattern>
<exclude-pattern>*/tests/*</exclude-pattern>
<exclude-pattern>*/utils/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>

<!-- How to scan -->
<arg value="sp"/> <!-- Show sniff and progress -->
<arg name="colors"/> <!-- Show results with colors -->
<arg name="extensions" value="php"/> <!-- Limit to PHP files -->

<!-- Rules: Check PHP version compatibility - see
https://github.com/PHPCompatibility/PHPCompatibilityWP -->
<rule ref="PHPCompatibilityWP">
<!-- Polyfill package is used so array_column() is available for PHP 5.4- -->
<exclude name="PHPCompatibility.PHP.NewFunctions.array_columnFound"/>
<!-- Both magic quotes directives set in wp-settings-cli.php to provide consistent starting point. -->
<exclude name="PHPCompatibility.PHP.DeprecatedIniDirectives.magic_quotes_runtimeDeprecatedRemoved"/>
<exclude name="PHPCompatibility.PHP.DeprecatedIniDirectives.magic_quotes_sybaseDeprecatedRemoved"/>
</rule>
<!-- Strip the filepaths down to the relevant bit. -->
<arg name="basepath" value="./"/>

<!-- For help in understanding this testVersion:
https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
<config name="testVersion" value="5.4-"/>
<!-- Check up to 8 files simultaneously. -->
<arg name="parallel" value="8"/>

<!-- Ignore php_uname mode issue, we're conditionally providing a callback -->
<rule ref="PHPCompatibility.PHP.NewFunctionParameters.php_uname_modeFound">
<exclude-pattern>*/php/commands/src/CLI_Command.php</exclude-pattern>
</rule>
<!--
#############################################################################
USE THE WP_CLI_CS RULESET
#############################################################################
-->

<!-- Rules: WordPress Coding Standards - see
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards -->
<rule ref="WordPress-Core">
<exclude name="Squiz.PHP.DisallowMultipleAssignments.Found" />
<exclude name="WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar" />
<exclude name="WordPress.NamingConventions.ValidVariableName.MemberNotSnakeCase" />
<exclude name="WordPress.NamingConventions.ValidVariableName.NotSnakeCase" />
</rule>
<rule ref="WP_CLI_CS"/>

<!--
#############################################################################
PROJECT SPECIFIC CONFIGURATION FOR SNIFFS
#############################################################################
-->

<!-- For help understanding the `testVersion` configuration setting:
https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
<config name="testVersion" value="7.2-"/>

<!-- For help in understanding these custom sniff properties:
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties -->
<rule ref="WordPress.Files.FileName">
<!-- Verify that everything in the global namespace is either namespaced or prefixed.
See: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#naming-conventions-prefix-everything-in-the-global-namespace -->
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
<property name="strict_class_file_names" value="false"/>
<property name="prefixes" type="array">
<element value="WP_Super_Cache"/>
<element value="wpsc"/>
</property>
</properties>
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase" />
</rule>
</ruleset>
10 changes: 9 additions & 1 deletion src/WP_Super_Cache_CLI_Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) ) {
Expand All @@ -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' );
}
Expand Down Expand Up @@ -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 ) );
}

Expand Down Expand Up @@ -186,14 +189,17 @@ 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;
}

return;
}

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 . '/';
}
}
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
}
}
6 changes: 5 additions & 1 deletion src/WP_Super_Cache_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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:' );
Expand Down Expand Up @@ -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.' );
}

Expand Down
6 changes: 3 additions & 3 deletions wp-super-cache-cli.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

$autoload = dirname( __FILE__ ) . '/vendor/autoload.php';
$wpsc_autoload = __DIR__ . '/vendor/autoload.php';

if ( file_exists( $autoload ) ) {
require_once $autoload;
if ( file_exists( $wpsc_autoload ) ) {
require_once $wpsc_autoload;
}

if ( ! class_exists( 'WP_CLI' ) ) {
Expand Down