WP Members Compatibility Fatal Error
-
Hey guys,
I’m getting a fatal error on searches that include indexed posts that have since been deleted.
The error is as follows:
PHP Fatal error: Uncaught TypeError: Cannot access offset of type WP_Error in isset or empty in /var/www/html/wp-content/plugins/relevanssi-premium/lib/compatibility/wp-members.php:35 Stack trace: #0 /var/www/html/wp-includes/class-wp-hook.php(324): relevanssi_wpmembers_compatibility() #1 /var/www/html/wp-includes/plugin.php(205): WP_Hook->apply_filters() #2 /var/www/html/wp-content/plugins/relevanssi-premium/premium/search-multi.php(193): apply_filters() #3 /var/www/html/wp-content/plugins/relevanssi-premium/lib/search.php(595): relevanssi_search_multi() #4 /var/www/html/wp-content/plugins/relevanssi-premium/lib/search.php(88): relevanssi_do_query() #5 /var/www/html/wp-includes/class-wp-hook.php(324): relevanssi_query() #6 /var/www/html/wp-includes/plugin.php(256): WP_Hook->apply_filters() #7 /var/www/html/wp-includes/class-wp-query.php(3146): apply_filters_ref_array() #8 /var/www/html/wp-includes/class-wp-query.php(3824): WP_Query->get_posts() #9 /var/...', referer: https://example.com/?s=test
Code responsible
relevanssi-premium/lib/compatibility/wp-members.php
:// function relevanssi_wpmembers_compatibility... $post_meta = get_post_meta($post_id, '_wpmem_block', true); // The next line fatals (line 35) $post_type = isset($wpmem->block[relevanssi_get_post_type($post_id)]) ? $wpmem->block[relevanssi_get_post_type($post_id)] : 0; if ('1' === $post_meta) { $post_ok = false; } elseif ('1' === $post_type && '0' !== $post_meta) { $post_ok = false; }
As you might imagine, if the post doesn’t exist anymore (but is still referenced in the index), the line
$post_type = isset($wpmem->block...
is a little brittle.One fix is to run a complete re-indexing, but I think the more permanent solution would be to resolve the code shortcoming here.
Thank you very much for an awesome plugin!
Cheers,
Ryan “Rohjay” Oeltjenbruns
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.