Refactor: fix SQL interpolation, double file reads, silent failures, and @ error suppression#204
Draft
Refactor: fix SQL interpolation, double file reads, silent failures, and @ error suppression#204
Conversation
… bugs Co-authored-by: Jumaron <41344875+Jumaron@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor unoptimized code and fix potential bugs
Refactor: fix SQL interpolation, double file reads, silent failures, and @ error suppression
Mar 10, 2026
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.
Several files contained embedded variables in raw SQL, a file-read bug, swallowed exceptions with no trace, and widespread
@suppression hiding real failures.SQL — use
$wpdb->prepare()for$timeDatabaseOptimizer.phpinterpolated$timedirectly into three SQL strings ('$time'). Whiletime()is always an int, this violates WP coding standards. All three queries (oneSELECT COUNT, twoDELETE) now use$wpdb->prepare()with%d.Bug fix — double
file_get_contents()inremoveDropIns()The original condition called
file_get_contents($file)twice due to short-circuit evaluation:Fixed by reading once into
$content, with an explicit error log if the read fails.Silent exceptions → logged errors in
HTMLCache::processOutput()All five
catch (\Throwable $e) {}blocks (CriticalCSS, JS, CDN, Font, Media) were completely silent. Each now calls$this->logError(). The redundant@on$dom->loadHTML()is also removed —libxml_use_internal_errors(true)is already set immediately above it.@error suppression removedReplaced silent-failure patterns with proper error handling across:
Plugin::installAdvancedCache()—@copy()→copy()+error_log()on failurePlugin::secureCacheDirectory()—@file_get_contents()/@file_put_contents()witherror_log()on write failure; truthiness check corrected to!== falsePlugin::createRequiredDirectories()—@file_put_contents()removedAdminPanelManager::handleInstallObjectCache()—@copy()/@chmod()removedAdminPanelManager::handleRemoveObjectCache()—@unlink()removeduninstall.php—@file_put_contents()removed (guarded byis_writable());@opcache_reset()removed (guarded byfunction_exists())Original prompt
Created from VS Code.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.