Yoast/wpseo-news

Yoast SEO News introduces infinite recursion while Yoast SEO rebuilds its option cache

tr3pan opened this issue · 2 comments

What did you expect to happen?

The site not to crash.

What happened instead?

PHP-FPM process crashes with segmentation fault.

How can we reproduce this behavior?

Install wordpress, Yoast SEO and Yoast SEO News plugins. Install and enable php xdebug module. No additional configuration is needed for xdebug. Set WP_DEBUG to true, so you can see xdebug errors displayed on page.

Important part: Your user locale should be different than the Site language locate in site Settings -> General -> Site Language section. For example if the site is set in English, the user can be set to use German locale. Go to WP Admin -> Appearance -> Customize to preview the theme. You will get xdebug error Maximum function nesting level of '256' reached.

256 is the default value for xdebug.max_nesting_level xdebug setting. You can increase the number, but it is not gonig to help. If xdebug module is not enabled, there will be no error when the page loads . It is possible the PHP-FPM process to crash with segmentation fault and get 500 status code. This is when I started the investigation. I didn't get segmentation fault on my local VM. It is possible PHP-FPM crash to be because of another loaded PHP module.

You can see the loop in the xdebug stacktrace, but to save you time if you comment add_filter( 'wpseo_schema_article_post_types', [ $this, 'article_post_types' ] ); in schema.php file the loop will disappear. The reason is article_post_types is executed when wpseo_titles is read to be put in the cache. article_post_types indirectly calls a function is_excluded_through_terms in wpseo-news.php file that cas a call to WPSEO_Options::get( 'news_sitemap_exclude_terms', [] ). But we are already rebuilding the cache and the loop starts.

This only happens when the Yoast option cache is empty. Having the wp user a different locale than the site, WP_Customize_Manager class triggers change_locale action. change_locale action triggers create_initial_post_types which on triggers purging Yoast SEO option cache. If the use locale is the same as the site locale, the loop doesn't happen.

Going to Customize is one example that I am aware of to hit that edge case with infinite loop. There might be other cases.

Technical info

  • WordPress version: 5.5.3
  • Yoast SEO version: 15.3
  • Yoast SEO News version: 12.6

Am able to reproduce

  1. Have Yoast SEO 15.3 and News SEO v12.6 on site

  2. Enable debug Mode in WordPress

  3. Go to Settings-General and make sure it says one language like English

  4. Go to Users-Your Profile and select a different one like German

  5. Go to Admin -> Appearance -> Customize to preview the theme

6 See errors: Error: Maximum function nesting level of '256' reached, aborting! Looks to be related to the class-wp-object-cache.php file

Screen Shot 2020-12-02 at 10 02 03 AM

WordPress: 5.5.3
Yoast SEO: 15.3
News SEO: 12.6
PHP 7.4.1
Server: Apache

I was able to reproduce the issue, saw all connections drop, including any database connections. While that doesn't seem to directly cause problems, this does introduce potential corruption issues I can imagine. While working with the news plugin on other pages I was randomly running into segfaults that I could not place, those may be related to this as well.

@tr3pan thanks for the detailed report!

Internal bugreport: https://yoast.atlassian.net/browse/QAK-2522