Relevanssi – A Better Search - Version 4.12.2

Version Description

  • Major fix: Stops more problems with ACF custom field indexing.
  • Major fix: Fixes a bug in search result caching that caused Relevanssi to make lots of unnecessary database queries.
Download this release

Release Info

Developer msaari
Plugin Icon 128x128 Relevanssi – A Better Search
Version 4.12.2
Comparing to
See all releases

Code changes from version 4.12.1 to 4.12.2

Files changed (5) hide show
  1. lib/common.php +11 -4
  2. lib/indexing.php +1 -1
  3. lib/options.php +2 -2
  4. readme.txt +8 -1
  5. relevanssi.php +2 -2
lib/common.php CHANGED
@@ -224,10 +224,15 @@ function relevanssi_default_post_ok( $post_ok, $post_id ) {
224
  * @global object $wpdb The WordPress database interface.
225
  *
226
  * @param array $matches An array of search matches.
 
227
  */
228
- function relevanssi_populate_array( $matches ) {
229
  global $relevanssi_post_array, $relevanssi_post_types, $wpdb;
230
 
 
 
 
 
231
  // Doing this makes life faster.
232
  wp_suspend_cache_addition( true );
233
 
@@ -243,8 +248,10 @@ function relevanssi_populate_array( $matches ) {
243
  $posts = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE id IN ( $id_list )", OBJECT ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
244
 
245
  foreach ( $posts as $post ) {
246
- $relevanssi_post_array[ $post->ID ] = $post;
247
- $relevanssi_post_types[ $post->ID ] = $post->post_type;
 
 
248
  }
249
  } while ( $ids );
250
 
@@ -528,7 +535,7 @@ function relevanssi_prevent_default_request( $request, $query ) {
528
  * value.
529
  */
530
  function relevanssi_tokenize( $string, $remove_stops = true, int $min_word_length = -1 ) : array {
531
- if ( ! $string ) {
532
  return array();
533
  }
534
  $string_for_phrases = is_array( $string ) ? implode( ' ', $string ) : $string;
224
  * @global object $wpdb The WordPress database interface.
225
  *
226
  * @param array $matches An array of search matches.
227
+ * @param int $blog_id The blog ID for multisite searches. Default -1.
228
  */
229
+ function relevanssi_populate_array( $matches, $blog_id = -1 ) {
230
  global $relevanssi_post_array, $relevanssi_post_types, $wpdb;
231
 
232
+ if ( -1 === $blog_id ) {
233
+ $blog_id = get_current_blog_id();
234
+ }
235
+
236
  // Doing this makes life faster.
237
  wp_suspend_cache_addition( true );
238
 
248
  $posts = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE id IN ( $id_list )", OBJECT ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
249
 
250
  foreach ( $posts as $post ) {
251
+ $cache_id = $blog_id . '|' . $post->ID;
252
+
253
+ $relevanssi_post_array[ $cache_id ] = $post;
254
+ $relevanssi_post_types[ $cache_id ] = $post->post_type;
255
  }
256
  } while ( $ids );
257
 
535
  * value.
536
  */
537
  function relevanssi_tokenize( $string, $remove_stops = true, int $min_word_length = -1 ) : array {
538
+ if ( ! $string || ( ! is_string( $string ) && ! is_array( $string ) ) ) {
539
  return array();
540
  }
541
  $string_for_phrases = is_array( $string ) ? implode( ' ', $string ) : $string;
lib/indexing.php CHANGED
@@ -361,7 +361,7 @@ function relevanssi_build_index( $extend_offset = false, $verbose = null, $post_
361
 
362
  if ( ( 0 === $size ) || ( count( $content ) < $size ) ) {
363
  $complete = true;
364
- update_option( 'relevanssi_indexed', 'done', false );
365
 
366
  // To prevent empty indices.
367
  $wpdb->query( "ANALYZE TABLE $relevanssi_table" ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.PreparedSQL.InterpolatedNotPrepared
361
 
362
  if ( ( 0 === $size ) || ( count( $content ) < $size ) ) {
363
  $complete = true;
364
+ update_option( 'relevanssi_indexed', 'done' );
365
 
366
  // To prevent empty indices.
367
  $wpdb->query( "ANALYZE TABLE $relevanssi_table" ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.PreparedSQL.InterpolatedNotPrepared
lib/options.php CHANGED
@@ -125,7 +125,7 @@ function update_relevanssi_options() {
125
  }
126
 
127
  if ( count( $index_post_types ) > 0 ) {
128
- update_option( 'relevanssi_index_post_types', array_keys( $index_post_types ), false );
129
  }
130
 
131
  if ( isset( $_REQUEST['relevanssi_index_fields_select'] ) ) {
@@ -212,7 +212,7 @@ function update_relevanssi_options() {
212
  'relevanssi_index_author' => false,
213
  'relevanssi_index_comments' => false,
214
  'relevanssi_index_excerpt' => false,
215
- 'relevanssi_index_image_files' => false,
216
  'relevanssi_log_queries_with_ip' => true,
217
  'relevanssi_log_queries' => true,
218
  'relevanssi_omit_from_logs' => true,
125
  }
126
 
127
  if ( count( $index_post_types ) > 0 ) {
128
+ update_option( 'relevanssi_index_post_types', array_keys( $index_post_types ) );
129
  }
130
 
131
  if ( isset( $_REQUEST['relevanssi_index_fields_select'] ) ) {
212
  'relevanssi_index_author' => false,
213
  'relevanssi_index_comments' => false,
214
  'relevanssi_index_excerpt' => false,
215
+ 'relevanssi_index_image_files' => true,
216
  'relevanssi_log_queries_with_ip' => true,
217
  'relevanssi_log_queries' => true,
218
  'relevanssi_omit_from_logs' => true,
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: search, relevance, better search, product search, woocommerce search
5
  Requires at least: 4.9
6
  Tested up to: 5.6.3
7
  Requires PHP: 7.0
8
- Stable tag: 4.12.1
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -131,6 +131,10 @@ Each document database is full of useless words. All the little words that appea
131
  * John Calahan for extensive 4.0 beta testing.
132
 
133
  == Changelog ==
 
 
 
 
134
  = 4.12.1 =
135
  * Major fix: Stops TypeError crashes from null custom field indexing.
136
 
@@ -211,6 +215,9 @@ Each document database is full of useless words. All the little words that appea
211
  * Minor fix: The category inclusion and exclusion setting checkboxes on the Searching tab didn't work. The setting was saved, but the checkboxes wouldn't appear.
212
 
213
  == Upgrade notice ==
 
 
 
214
  = 4.12.1 =
215
  * Stops TypeError crashes from null custom field indexing.
216
 
5
  Requires at least: 4.9
6
  Tested up to: 5.6.3
7
  Requires PHP: 7.0
8
+ Stable tag: 4.12.2
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
131
  * John Calahan for extensive 4.0 beta testing.
132
 
133
  == Changelog ==
134
+ = 4.12.2 =
135
+ * Major fix: Stops more problems with ACF custom field indexing.
136
+ * Major fix: Fixes a bug in search result caching that caused Relevanssi to make lots of unnecessary database queries.
137
+
138
  = 4.12.1 =
139
  * Major fix: Stops TypeError crashes from null custom field indexing.
140
 
215
  * Minor fix: The category inclusion and exclusion setting checkboxes on the Searching tab didn't work. The setting was saved, but the checkboxes wouldn't appear.
216
 
217
  == Upgrade notice ==
218
+ = 4.12.2 =
219
+ * Stops Relevanssi from crashing when saving posts with ACF fields, major performance boost.
220
+
221
  = 4.12.1 =
222
  * Stops TypeError crashes from null custom field indexing.
223
 
relevanssi.php CHANGED
@@ -13,7 +13,7 @@
13
  * Plugin Name: Relevanssi
14
  * Plugin URI: https://www.relevanssi.com/
15
  * Description: This plugin replaces WordPress search with a relevance-sorting search.
16
- * Version: 4.12.1
17
  * Author: Mikko Saari
18
  * Author URI: http://www.mikkosaari.fi/
19
  * Text Domain: relevanssi
@@ -67,7 +67,7 @@ $relevanssi_variables['database_version'] = 6;
67
  $relevanssi_variables['file'] = __FILE__;
68
  $relevanssi_variables['plugin_dir'] = plugin_dir_path( __FILE__ );
69
  $relevanssi_variables['plugin_basename'] = plugin_basename( __FILE__ );
70
- $relevanssi_variables['plugin_version'] = '4.12.1';
71
 
72
  require_once 'lib/admin-ajax.php';
73
  require_once 'lib/common.php';
13
  * Plugin Name: Relevanssi
14
  * Plugin URI: https://www.relevanssi.com/
15
  * Description: This plugin replaces WordPress search with a relevance-sorting search.
16
+ * Version: 4.12.2
17
  * Author: Mikko Saari
18
  * Author URI: http://www.mikkosaari.fi/
19
  * Text Domain: relevanssi
67
  $relevanssi_variables['file'] = __FILE__;
68
  $relevanssi_variables['plugin_dir'] = plugin_dir_path( __FILE__ );
69
  $relevanssi_variables['plugin_basename'] = plugin_basename( __FILE__ );
70
+ $relevanssi_variables['plugin_version'] = '4.12.2';
71
 
72
  require_once 'lib/admin-ajax.php';
73
  require_once 'lib/common.php';