v1.2.3
This commit is contained in:
parent
80a2202d6e
commit
121c35737d
1 changed files with 1398 additions and 2198 deletions
|
|
@ -90,27 +90,29 @@ function robotstxt_docmd_uninstall(): void {
|
|||
function robotstxt_docmd_delete_transients_by_prefix( string $prefix ): void {
|
||||
global $wpdb;
|
||||
|
||||
// Sanitize prefix for LIKE query.
|
||||
$transient_prefix = $wpdb->esc_like( '_transient_' . $prefix ) . '%';
|
||||
$transient_timeout_prefix = $wpdb->esc_like( '_transient_timeout_' . $prefix ) . '%';
|
||||
// Type-narrow the global (PHPStan level 10: global $wpdb is mixed).
|
||||
if ( ! $wpdb instanceof wpdb ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Required for bulk pattern-based deletion; no WordPress API available for this operation.
|
||||
// Sanitize prefix for the LIKE pattern. Escaping uses the esc_sql() +
|
||||
// esc_like() chain documented in wpdb::esc_like(): wpdb::prepare() cannot
|
||||
// be used here because table-name interpolation makes the query string
|
||||
// non-literal (wordpress-stubs types $query as literal-string).
|
||||
$transient_prefix = esc_sql( $wpdb->esc_like( '_transient_' . $prefix ) ) . '%';
|
||||
$transient_timeout_prefix = esc_sql( $wpdb->esc_like( '_transient_timeout_' . $prefix ) ) . '%';
|
||||
|
||||
// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Required for bulk pattern-based deletion; no WordPress API available. Values escaped above via esc_sql() + esc_like().
|
||||
// Delete transient values.
|
||||
$wpdb->query(
|
||||
$wpdb->prepare(
|
||||
"DELETE FROM {$wpdb->options} WHERE option_name LIKE %s",
|
||||
$transient_prefix
|
||||
)
|
||||
"DELETE FROM {$wpdb->options} WHERE option_name LIKE '{$transient_prefix}'"
|
||||
);
|
||||
|
||||
// Delete transient timeouts.
|
||||
$wpdb->query(
|
||||
$wpdb->prepare(
|
||||
"DELETE FROM {$wpdb->options} WHERE option_name LIKE %s",
|
||||
$transient_timeout_prefix
|
||||
)
|
||||
"DELETE FROM {$wpdb->options} WHERE option_name LIKE '{$transient_timeout_prefix}'"
|
||||
);
|
||||
// phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||
// phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||
}
|
||||
|
||||
// Run uninstall.
|
||||
|
|
|
|||
Loading…
Reference in a new issue