Closed vmanthos closed 1 year ago
I was able to reproduce the problem
We are not checking the status of the table before making requests to it.
Like @Tabrisrp stated we need to do a check for every request we send to the rucss table.
we can add a method in WP_Rocket\Engine\Optimization\RUCSS\Database\Queries
like this
Private function table_exists() {
// Get the database interface
$db = $this->get_db();
// Bail if no database interface is available
if ( empty( $db ) ) {
return false;
}
// Query statement
$query = "SHOW TABLES LIKE %s";
$like = $db->esc_like( $this->table_name );
$prepared = $db->prepare( $query, $like );
$result = $db->get_var( $prepared );
// Does the table exist?
return $this->is_success( $result );
}
then we can either use this to do checks on every method that sends request to the table in WP_Rocket\Engine\Optimization\RUCSS\Database\Queries
or do the checks on WP_Rocket\Engine\Optimization\RUCSS\Controller\UsedCSS
Might need to update tests also.
Estimate the effort ✅ [S]
Reproduce the problem white_check_mark
I was able to reproduce the problem
Identify the root cause white_check_mark
We are not checking the status of the table before making requests to it.
Scope a solution white_check_mark
Like @Tabrisrp stated we need to do a check for every request we send to the rucss table. we can add a method in
WP_Rocket\Engine\Optimization\RUCSS\Database\Queries
like thisPrivate function table_exists() { // Get the database interface $db = $this->get_db(); // Bail if no database interface is available if ( empty( $db ) ) { return false; } // Query statement $query = "SHOW TABLES LIKE %s"; $like = $db->esc_like( $this->table_name ); $prepared = $db->prepare( $query, $like ); $result = $db->get_var( $prepared ); // Does the table exist? return $this->is_success( $result ); }
then we can either use this to do checks on every method that sends request to the table in
WP_Rocket\Engine\Optimization\RUCSS\Database\Queries
or do the checks onWP_Rocket\Engine\Optimization\RUCSS\Controller\UsedCSS
Might need to update tests also.
Estimate the effort white_check_mark [S]
@jeawhanlee can we check only on the first time we send a query? Normally the table as no reason to disappear for following queries and that would prevent from doubling every single request we do to the DB.
Before submitting an issue please check that you’ve completed the following steps:
3.12.1
Describe the bug
Database table errors like the following have been popping up in the
debug.log
during QA:or @Mai-Saad found this:
To Reproduce Steps to reproduce the behavior:
wpr_remove_unused_css
table.Expected behavior
We should prevent such errors from taking place. According to @Tabrisrp:
Additional context
Slack conversation: https://wp-media.slack.com/archives/GUT7FLHF1/p1652717738651909
Backlog Grooming (for WP Media dev team use only)