Skip to content

Commit

Permalink
Merge pull request #91 from wp-cli/fix/wpcs-3.0-issues
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy committed Aug 30, 2023
2 parents b4726ce + 7e341e3 commit b1be1fe
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 35 deletions.
2 changes: 1 addition & 1 deletion cache-command.php
Expand Up @@ -4,7 +4,7 @@
return;
}

$wpcli_cache_autoloader = dirname( __FILE__ ) . '/vendor/autoload.php';
$wpcli_cache_autoloader = __DIR__ . '/vendor/autoload.php';
if ( file_exists( $wpcli_cache_autoloader ) ) {
require_once $wpcli_cache_autoloader;
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -16,7 +16,7 @@
},
"require-dev": {
"wp-cli/entity-command": "^1.3 || ^2",
"wp-cli/wp-cli-tests": "^3.1"
"wp-cli/wp-cli-tests": "^4"
},
"config": {
"process-timeout": 7200,
Expand Down
1 change: 0 additions & 1 deletion src/Cache_Command.php
Expand Up @@ -406,5 +406,4 @@ public function flush_group( $args, $assoc_args ) {
}
WP_CLI::success( "Cache group '$group' was flushed." );
}

}
60 changes: 28 additions & 32 deletions src/Transient_Command.php
Expand Up @@ -466,8 +466,7 @@ private function delete_expired( $network ) {
time()
)
);
} else {
if ( ! is_multisite() ) {
} elseif ( ! is_multisite() ) {
// Non-Multisite stores site transients in the options table.
$count += $wpdb->query(
$wpdb->prepare(
Expand All @@ -481,21 +480,20 @@ private function delete_expired( $network ) {
time()
)
);
} else {
// Multisite stores site transients in the sitemeta table.
$count += $wpdb->query(
$wpdb->prepare(
"DELETE a, b FROM {$wpdb->sitemeta} a, {$wpdb->sitemeta} b
} else {
// Multisite stores site transients in the sitemeta table.
$count += $wpdb->query(
$wpdb->prepare(
"DELETE a, b FROM {$wpdb->sitemeta} a, {$wpdb->sitemeta} b
WHERE a.meta_key LIKE %s
AND a.meta_key NOT LIKE %s
AND b.meta_key = CONCAT( '_site_transient_timeout_', SUBSTRING( a.meta_key, 17 ) )
AND b.meta_value < %d",
Utils\esc_like( '_site_transient_' ) . '%',
Utils\esc_like( '_site_transient_timeout_' ) . '%',
time()
)
);
}
Utils\esc_like( '_site_transient_' ) . '%',
Utils\esc_like( '_site_transient_timeout_' ) . '%',
time()
)
);
}

// The above queries delete the transient and the transient timeout
Expand Down Expand Up @@ -553,8 +551,7 @@ private function delete_all( $network ) {
Utils\esc_like( '_transient_' ) . '%'
)
);
} else {
if ( ! is_multisite() ) {
} elseif ( ! is_multisite() ) {
// Non-Multisite stores site transients in the options table.
$deleted = $wpdb->query(
$wpdb->prepare(
Expand All @@ -575,28 +572,27 @@ private function delete_all( $network ) {
Utils\esc_like( '_site_transient_' ) . '%'
)
);
} else {
// Multisite stores site transients in the sitemeta table.
$deleted = $wpdb->query(
$wpdb->prepare(
"DELETE a, b FROM {$wpdb->sitemeta} a, {$wpdb->sitemeta} b
} else {
// Multisite stores site transients in the sitemeta table.
$deleted = $wpdb->query(
$wpdb->prepare(
"DELETE a, b FROM {$wpdb->sitemeta} a, {$wpdb->sitemeta} b
WHERE a.meta_key LIKE %s
AND a.meta_key NOT LIKE %s
AND b.meta_key = CONCAT( '_site_transient_timeout_', SUBSTRING( a.meta_key, 17 ) )",
Utils\esc_like( '_site_transient_' ) . '%',
Utils\esc_like( '_site_transient_timeout_' ) . '%'
)
);
Utils\esc_like( '_site_transient_' ) . '%',
Utils\esc_like( '_site_transient_timeout_' ) . '%'
)
);

$count += $deleted / 2; // Ignore affected rows for timeouts.
$count += $deleted / 2; // Ignore affected rows for timeouts.

$count += $wpdb->query(
$wpdb->prepare(
"DELETE FROM $wpdb->sitemeta WHERE meta_key LIKE %s",
Utils\esc_like( '_site_transient_' ) . '%'
)
);
}
$count += $wpdb->query(
$wpdb->prepare(
"DELETE FROM $wpdb->sitemeta WHERE meta_key LIKE %s",
Utils\esc_like( '_site_transient_' ) . '%'
)
);
}

if ( $count > 0 ) {
Expand Down

0 comments on commit b1be1fe

Please sign in to comment.