PluginProbe
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services / 5.0.2
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services v5.0.2
8.7.8 8.7.7 8.7.6 8.7.5 8.7.4 8.7.3 8.7.2 8.7.1 8.7.0 8.6.9 8.6.8 8.6.7 8.6.6 8.6.5 8.6.4 8.6.2 8.6.1 8.6.0 8.5.9 8.5.8 8.5.7 8.5.6 8.5.5 8.5.4 8.5.3 All 534 releases
← All changes | includes/class-wpwbot-cache.php +17 -16 8.7.55.0.2 View file →
@@ -52,9 +52,9 @@
52 52 * Check if cache table exist
53 53 */
54 54 private function is_cache_table_not_exist() {
55 55 global $wpdb;
56 - return ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $wpdb->esc_like( $this->cache_table_name ) ) ) != $this->cache_table_name ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
56 + return ( $wpdb->get_var( "SHOW TABLES LIKE '{$this->cache_table_name}'" ) != $this->cache_table_name );
57 57 }
58 58 /*
59 59 * Create cache table
60 60 */
@@ -71,37 +71,38 @@
71 71 /*
72 72 * Insert data into cache table
73 73 */
74 74 public function insert_into_cache_table( $cache_option_name, $result_array ) {
75 -
76 75 global $wpdb;
77 -
78 - $query = $wpdb->prepare("INSERT IGNORE INTO {$this->cache_table_name}
76 + $values = $wpdb->prepare(
77 + "(%s, %s)",
78 + $cache_option_name, json_encode( $result_array )
79 + );
80 + $query = "INSERT IGNORE INTO {$this->cache_table_name}
79 81 (`name`, `value`)
80 - VALUES (%s, %s)", $cache_option_name, json_encode( $result_array ));
81 -
82 - $wpdb->query( $query ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
83 -
82 + VALUES $values
83 + ";
84 + $wpdb->query( $query );
84 85 if ( $wpdb->last_error ) {
85 86 if ( $this->is_cache_table_not_exist() ) {
86 87 $this->create_cache_table();
87 88 }
88 89 }
89 -
90 90 }
91 91 /*
92 92 * Get data from cache table
93 93 */
94 94 public function get_from_cache_table( $cache_option_name ) {
95 -
96 95 global $wpdb;
97 -
98 96 $result = '';
99 -
100 - $safe_sql = $wpdb->prepare("SELECT * FROM {$this->cache_table_name} WHERE `name` LIKE %s", $cache_option_name);
101 -
102 - $cache_content = $wpdb->get_results( $safe_sql, ARRAY_A ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
103 -
97 + $where = $wpdb->prepare( " name LIKE %s", $cache_option_name );
98 + $sql = "SELECT *
99 + FROM
100 + {$this->cache_table_name}
101 + WHERE
102 + {$where}
103 + ";
104 + $cache_content = $wpdb->get_results( $sql, ARRAY_A );
104 105 if ( ! $wpdb->last_error ) {
105 106 if (!empty($cache_content) && !is_wp_error($cache_content) && is_array($cache_content)) {
106 107 $result = $cache_content[0]['value'];
107 108 }