Repository navigation
Fix: uninstall.php's announcement-delete query never actually runs - #94
Open
smtturkan-droid wants to merge 1 commit into
Open
smtturkan-droid wants to merge 1 commit into
smtturkan-droid wants to merge 1 commit into
Conversation
$wpdb->prepare( 'DELETE FROM %s WHERE post_type = "te_announcements"', $wpdb->posts ) uses the %s placeholder for a table name. prepare() escapes and quotes %s as a string literal, so the query wpdb actually runs is: DELETE FROM 'wp_posts' WHERE post_type = "te_announcements" A single-quoted table name isn't a valid identifier under default MySQL sql_mode, so this fails silently - the "delete announcement posts on uninstall" option never actually deletes anything. Fixed by interpolating the table name directly (it comes from $wpdb, not user input, so no escaping is needed) - the same pattern already used correctly elsewhere in this same file for $wpdb->prefix . 'options'. Verified with php -l (no syntax errors). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi Evan,
Small, scoped fix in
uninstall.php.What
%sin$wpdb->prepare()quotes its value as a string literal, so the query that actually runs is:A single-quoted table name isn't a valid identifier under default MySQL
sql_mode, so this fails silently - when a user enables "delete announcement posts on uninstall," nothing actually gets deleted.Fix
Interpolate
$wpdb->postsdirectly instead of going throughprepare()'s%s(it's an internal WP value, not user input, so no escaping is needed here) - the same pattern this file already uses correctly a few lines down for{$wpdb->prefix}options.What I did NOT touch
Nothing else in the file or the rest of the plugin.
Verification
php -l uninstall.php- no syntax errors. This only runs on uninstall so I couldn't easily exercise it end-to-end without a disposable WP install; happy to do that if you'd like before merging.🤖 Generated with Claude Code