WPML + “Did you mean” function error
-
I recently updated WordPress and all of the plugins on our site including WPML and Relevanssi. After doing so, a coworker found out that searching for the acronym “TROOP” caused the results page to break. It may be relevant that we get zero results searching for “TROOP.” I did some digging and found out that there was an error. Here’s the stack trace for it:
PHP Fatal error: Uncaught Error: Cannot use object of type WP_Error as array in /var/www/vhosts/our-site/wp-content/plugins/relevanssi/lib/utils.php:417 Stack trace: #0 /var/www/vhosts/our-site/wp-content/plugins/relevanssi/lib/stopwords.php(95): relevanssi_get_current_language() #1 /var/www/vhosts/our-site/wp-content/plugins/relevanssi/lib/common.php(594): relevanssi_fetch_stopwords() #2 /var/www/vhosts/our-site/wp-content/plugins/relevanssi/lib/didyoumean.php(159): relevanssi_tokenize() #3 /var/www/vhosts/our-site/wp-content/plugins/relevanssi/lib/didyoumean.php(68): relevanssi_simple_generate_suggestion() #4 /var/www/vhosts/our-site/wp-content/plugins/relevanssi/lib/didyoumean.php(31): relevanssi_simple_didyoumean() #5 /var/www/vhosts/our-site/wp-content/themes/our-theme/search.php(221): relevanssi_didyoumean() #6 /var/www/vhosts/our-site/wp-includes/template-loader.php(106): include('/var/www/vhosts...') #7 /var/www/vhosts/our-site/wp-blog-header.php(19): require_once('/var/www/vhosts...') #8 /var/www/vhosts/our-site/index.php(17): require('/var/www/vhosts...') #9 {main} thrown in /var/www/vhosts/our-site/wp-content/plugins/relevanssi/lib/utils.php on line 417
The error seemed to happen with any phrase that contained “oop” at the end of it (loop, goop, boop, etc.) except for another acronym on our site, “MOOP.” I eventually determined that disabling WPML allowed us to search those specific terms without error. The “Limit results to current language” WPML searching setting did not solve the problem.
With WPML enabled, I was able to avoid the error by commenting out the block which started on search.php(221) from the stack trace. It was the entire section that runs the relevanssi_didyoumean function.
<?php if (function_exists('relevanssi_didyoumean')) { relevanssi_didyoumean(get_search_query(), "<p>Did you mean: ", "?</p>", 5); } ?> <?php if( have_posts() ) : ?> <div class="search-count"> <p><?php echo sprintf( __( 'Results %s - %s of %s', 'medicareinteractive' ), $range_start, $range_end, $search_count ); ?></p> </div> <?php endif; ?>
This has been within our template since we installed Relevanssi. We don’t have search logging enabled and, it’s my understanding that this is required for the did you mean function to work with the free version of Relevanssi.
Is this problem reproduceable or is there anything from recent updates that may have caused the did you mean function to error out like that?
Thank you!
- The topic ‘WPML + “Did you mean” function error’ is closed to new replies.