diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index fc0527b7..5fadbc8b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -55,3 +55,18 @@ jobs: with: eclint_args: | -exclude=dependencies/**/* + + plugincheck: + name: Plugin Check + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Run plugin check + uses: wordpress/plugin-check-action@v1 + with: + exclude-directories: '.github,dependencies,tests' + exclude-files: '.editorconfig,.gitattributes,.gitignore,phpunit.xml.dist' + # exclude-checks: '' diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a288b6e..c6e30c4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## Unreleased +- Added `Primary Branch` header +- Adhere to Plugin Check (PCP) +- Fixed rare replication mode issue + ## 2.5.4 - Respect `WP_REDIS_SCHEME` for Cluster connections diff --git a/includes/class-metrics.php b/includes/class-metrics.php index 29bdaf37..f4b723df 100644 --- a/includes/class-metrics.php +++ b/includes/class-metrics.php @@ -146,7 +146,7 @@ public function collect() { $info = $wp_object_cache->info(); - $this->id = substr( md5( uniqid( strval( mt_rand() ), true ) ), 12 ); + $this->id = substr( md5( uniqid( strval( wp_rand() ), true ) ), 12 ); $this->hits = $info->hits; $this->misses = $info->misses; $this->ratio = $info->ratio; diff --git a/includes/class-plugin.php b/includes/class-plugin.php index 0fee1938..9fd537e4 100644 --- a/includes/class-plugin.php +++ b/includes/class-plugin.php @@ -827,6 +827,7 @@ public function render_admin_bar( $wp_admin_bar ) { * @return string */ protected function admin_bar_style() { + // phpcs:disable Squiz.PHP.Heredoc.NotAllowed return << #wpadminbar ul li.redis-cache-error { @@ -838,7 +839,7 @@ protected function admin_bar_style() { color: #fff; } -HTML; +HTML; // phpcs:enable } /** @@ -851,6 +852,7 @@ protected function admin_bar_script() { $ajaxurl = esc_url( admin_url( 'admin-ajax.php' ) ); $flushMessage = __( 'Flushing cache...', 'redis-cache' ); + // phpcs:disable Squiz.PHP.Heredoc.NotAllowed return << (function (element) { @@ -895,7 +897,7 @@ protected function admin_bar_script() { document.querySelector('#wp-admin-bar-redis-cache-flush > a') ); -HTML; +HTML; // phpcs:enable } /** @@ -1076,15 +1078,13 @@ public function ajax_dismiss_notice() { * @return void */ public function ajax_flush_cache() { - if ( ! wp_verify_nonce( $_POST['nonce'] ) ) { - $message = 'Invalid Nonce.'; + if ( ! wp_verify_nonce( $_POST['nonce'] ?? '' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput + wp_die( esc_html__( 'Invalid Nonce.', 'redis-cache' ) ); } else if ( wp_cache_flush() ) { - $message = 'Object cache flushed.'; + wp_die( esc_html__( 'Object cache flushed.', 'redis-cache' ) ); } else { - $message = 'Object cache could not be flushed.'; + wp_die( esc_html__( 'Object cache could not be flushed.', 'redis-cache' ) ); } - - wp_die( __( $message , 'redis-cache' ) ); } /** @@ -1600,6 +1600,7 @@ public function current_user_can_manage_redis() { * @return void */ public function litespeed_disable_objectcache() { + // phpcs:ignore WordPress.Security.NonceVerification.Missing if ( isset( $_POST['LSCWP_CTRL'], $_POST['LSCWP_NONCE'], $_POST['object'] ) ) { $_POST['object'] = '0'; } diff --git a/includes/class-predis.php b/includes/class-predis.php index 9fbe687c..cb4e5099 100644 --- a/includes/class-predis.php +++ b/includes/class-predis.php @@ -206,6 +206,7 @@ protected function build_cluster_connection_array() { $cluster = array_values( WP_REDIS_CLUSTER ); foreach ( $cluster as $key => $server ) { + // phpcs:ignore WordPress.WP.AlternativeFunctions.parse_url_parse_url $components = parse_url( $server ); if ( ! empty( $components['scheme'] ) ) { diff --git a/includes/object-cache.php b/includes/object-cache.php index e491ae58..86367e6b 100644 --- a/includes/object-cache.php +++ b/includes/object-cache.php @@ -1877,6 +1877,7 @@ protected function lua_flush_closure( $salt, $escape = true ) { $salt = $escape ? $this->glob_quote( $salt ) : $salt; return function () use ( $salt ) { + // phpcs:disable Squiz.PHP.Heredoc.NotAllowed $script = <<redis_version) && version_compare( $this->redis_version, '5', '<' ) && version_compare( $this->redis_version, '3.2', '>=' ) ) { $script = 'redis.replicate_commands()' . "\n" . $script; @@ -1923,6 +1924,7 @@ function ( $group ) { $this->unflushable_groups ); + // phpcs:disable Squiz.PHP.Heredoc.NotAllowed $script = <<redis_version) && version_compare( $this->redis_version, '5', '<' ) && version_compare( $this->redis_version, '3.2', '>=' ) ) { $script = 'redis.replicate_commands()' . "\n" . $script; } @@ -2508,24 +2510,26 @@ public function decr( $key, $offset = 1, $group = 'default' ) { * @return void */ public function stats() { - ?> -

- Redis Status: - redis_status() ? 'Connected' : 'Not connected'; ?> -
- Redis Client: - diagnostics['client'] ?: 'Unknown'; ?> -
- Cache Hits: - cache_hits; ?> -
- Cache Misses: - cache_misses; ?> -
- Cache Size: - cache ) ) / 1024, 2 ); ?> KB -

- +

+ Redis Status: + redis_status() ? 'Connected' : 'Not connected'; ?> +
+ Redis Client: + diagnostics['client'] ?: 'Unknown'; ?> +
+ Cache Hits: + cache_hits; ?> +
+ Cache Misses: + cache_misses; ?> +
+ Cache Size: + cache ) ) / 1024, 2 ); ?> KB +

+ /wp-content/' ) . "

\n"; - wp_die( $message ); + wp_die( $message ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } /** @@ -3037,6 +3041,7 @@ protected function build_cluster_connection_array() { $cluster = array_values( WP_REDIS_CLUSTER ); foreach ( $cluster as $key => $server ) { + // phpcs:ignore WordPress.WP.AlternativeFunctions.parse_url_parse_url $components = parse_url( $server ); if ( ! empty( $components['scheme'] ) ) { diff --git a/includes/ui/settings.php b/includes/ui/settings.php index c3d7f843..d9c0a3e1 100644 --- a/includes/ui/settings.php +++ b/includes/ui/settings.php @@ -98,7 +98,7 @@ class="classes() ); ?>"
  • - +

    diff --git a/includes/ui/tabs/diagnostics.php b/includes/ui/tabs/diagnostics.php index 68cacbb7..bacf2ace 100644 --- a/includes/ui/tabs/diagnostics.php +++ b/includes/ui/tabs/diagnostics.php @@ -16,8 +16,8 @@

    - +

    diff --git a/includes/ui/widget.php b/includes/ui/widget.php index 2d2a25c9..df5728ac 100644 --- a/includes/ui/widget.php +++ b/includes/ui/widget.php @@ -34,7 +34,7 @@
  • - +