PluginProbe
WebberZone Top 10 — Popular Posts / 4.5.1
WebberZone Top 10 — Popular Posts v4.5.1
4.5.1 4.5.0 4.4.3 4.4.2 4.4.1 4.4.0 4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 trunk 1.0 1.0.1 1.1 1.2 1.3 1.4 1.4.1 1.5 1.5.1 1.5.2 1.5.3 1.6 1.6.1 All 117 releases
← All changes | includes/admin/class-wpp-importer.php +21 -4 4.4.0 → 4.5.1 View file →
@@ -292,16 +292,33 @@
292 292 */
293 293 private function wpp_tables_exist(): bool {
294 294 global $wpdb;
295 295
296 + $tables = array(
297 + $wpdb->prefix . 'popularpostsdata',
298 + $wpdb->prefix . 'popularpostssummary',
299 + );
300 + $key = implode( '|', $tables );
301 + static $cache = array();
302 +
303 + if ( array_key_exists( $key, $cache ) ) {
304 + return $cache[ $key ];
305 + }
306 +
296 307 $tables_exist = true;
308 + foreach ( $tables as $table ) {
309 + $query = $wpdb->prepare( 'SELECT 1 FROM %i LIMIT 0', $table );
310 + $suppress_errors = $wpdb->suppress_errors();
297 311
298 - $data_table = $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}popularpostsdata'" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
299 - $summary_table = $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}popularpostssummary'" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
312 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
313 + if ( false === $wpdb->query( $query ) ) {
314 + $tables_exist = false;
315 + }
300 316
301 - if ( ! $data_table || ! $summary_table ) {
302 - $tables_exist = false;
317 + $wpdb->suppress_errors( $suppress_errors );
303 318 }
319 +
320 + $cache[ $key ] = $tables_exist;
304 321
305 322 return $tables_exist;
306 323 }
307 324