Skip to content

Commit 6007f23

Browse files
committed
chore: drop POC-misleading transient SQL in uninstall
Persistent object caches store transients outside wp_options, so the SQL DELETE patterns for _transient_page_for_* / _transient_timeout_* were a partial cleanup at best — they ran on every uninstall but did nothing useful on POC-enabled sites. The mapping-driven loop above already calls delete_transient(), which is POC-aware, so known-CPT transients are correctly cleaned in both storage modes. The SQL fallback is now narrowed to orphan page_for_* options only, with a comment explaining why transient orphans aren't covered.
1 parent 3d3ae8f commit 6007f23

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

uninstall.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
}
1515

1616
// Walk the aggregated mapping to clear known per-CPT options and transients
17-
// via the WP API. This handles object caches and the alloptions cache.
17+
// via the WP API. delete_transient is the only viable path when a persistent
18+
// object cache is enabled, since transients then don't live in wp_options.
1819
$pfcptMapping = get_option('pages_for_custom_post_type', []);
1920
if (is_array($pfcptMapping)) {
2021
foreach (array_keys($pfcptMapping) as $pfcptPostType) {
@@ -30,14 +31,15 @@
3031
delete_option('pages_for_custom_post_type');
3132
delete_option('pfcpt_db_version');
3233

33-
// Catch any orphaned rows in wp_options for CPTs no longer present in the
34-
// aggregated mapping (e.g. a CPT was unregistered without cleanup).
34+
// Catch any orphan page_for_* options for CPTs no longer in the aggregated
35+
// mapping. Transient orphans aren't covered: on sites with a persistent
36+
// object cache they don't have wp_options rows at all; on sites without one
37+
// the unbounded transients (set_transient(..., 0)) would persist, but this
38+
// is rare enough to accept rather than scan the whole options table.
3539
global $wpdb;
3640
$wpdb->query(
3741
$wpdb->prepare(
38-
"DELETE FROM {$wpdb->options} WHERE option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s",
39-
$wpdb->esc_like('page_for_') . '%',
40-
$wpdb->esc_like('_transient_page_for_') . '%',
41-
$wpdb->esc_like('_transient_timeout_page_for_') . '%'
42+
"DELETE FROM {$wpdb->options} WHERE option_name LIKE %s",
43+
$wpdb->esc_like('page_for_') . '%'
4244
)
4345
);

0 commit comments

Comments
 (0)