Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to WPCS v3 #91

Merged
merged 2 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Fix all autofixable CS issues
  • Loading branch information
schlessera committed Aug 30, 2023
commit 7e341e35de88cd96a03e7eb94870804a7d836fcd
2 changes: 1 addition & 1 deletion cache-command.php
Original file line number Diff line number Diff line change
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
1 change: 0 additions & 1 deletion src/Cache_Command.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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