Yoast page-sitemap....
 
Notifications
Clear all

Script Yoast page-sitemap.xml critical error regex bug in core plugin.

4 Posts
2 Users
2 Reactions
310 Views
Posts: 2
Topic starter
(@tfjoel)
New Member
Joined: 5 months ago

So I believe I have figured out why Yoast Sitemaps are incompatible with wpForo (Version 2.3.1) and there have been multiple reports of this critical error issue (example: https://wpforo.com/community/general-forums-bug-reports/26039/#post-75400)

The file /wpforo/classes/SEO.php has a regex that is falsely catching the /page-sitemap.xml URL.

In /wpforo/classes/SEO.php see line 344 in the public function "redirect"

	public function redirect( $current_object, $wpf_url_parse ) {
		$pattern = '#^[\r\n\t\s\0]*(?<type>\w*)-?sitemap(?:(?<paged>\d*)|_index)\.xml[\r\n\t\s\0]*$#iu';
		if( ! empty( $wpf_url_parse[0] ) && preg_match( $pattern, basename( (string) $wpf_url_parse[0] ), $match ) ) {
			$current_object['template'] = 'sitemap';

			$query = [ 'type' => '', 'paged' => 1 ];
			$query = wpforo_parse_args( $match, $query );
			$type  = trim( (string) $query['type'] );
			$paged = absint( $query['paged'] );
			if( ! $paged ) $paged = 1;

			if( $sitemap = $this->get_sitemap( $type, $paged ) ) {
				$this->output( $sitemap );
				$this->sitemap_close();
			} else {
				$current_object['is_404'] = true;
			}
		}

		return $current_object;
	}

The regex in question is below:

#^[\r\n\t\s\0]*(?<type>\w*)-?sitemap(?:(?<paged>\d*)|_index)\.xml[\r\n\t\s\0]*$#iu

If you run a regex testing tool with that regex against the following string, you'll see that it matches it, and then proceeds to load the forum template. The URL page-sitemap.xml is Yoast's page sitemap, so wpforo should not be running any code for this url.

page-sitemap.xml

I believe the proper solution is to update this regex in the core wpForo plugin's code to something more precise so it does not override the yoast sitemap.

=== 

The error we are receiving in full is below for reference.

PHP Fatal error: Uncaught Error: Call to undefined function wpforo_thread_forum_template() in /nas/content/live/sitename/wp-content/plugins/wpforo/themes/2022/layouts/4/forum.php:85\nStack trace:\n
#0 /nas/content/live/sitename/wp-content/plugins/wpforo/themes/2022/forum.php(41): include()\n
#1 /nas/content/live/sitename/wp-content/plugins/wpforo/includes/functions-template.php(2196): include('/nas/content/li...')\n
#2 /nas/content/live/sitename/wp-content/plugins/wpforo/themes/2022/index.php(26): wpforo_template('forum')\n
#3 /nas/content/live/sitename/wp-content/plugins/wpforo/includes/hooks.php(230): include('/nas/content/li...')\n
#4 /nas/content/live/sitename/wp-includes/shortcodes.php(433): wpforo\\wpforo->{closure}(Array, '', 'wpforo')\n
#5 [internal function]: do_shortcode_tag(Array)\n
#6 /nas/content/live/sitename/wp-includes/shortcodes.php(273): preg_replace_callback('/\\\\[(\\\\[?)(wpforo...', 'do_shortcode_ta...', '[wpforo]\\n')\n
#7 /nas/content/live/sitename/wp-content/plugins/so-widgets-bundle/widgets/editor/editor.php(108): do_shortcode('[wpforo]\\n')\n
#8 /nas/content/live/sitename/wp-content/plugins/so-widgets-bundle/base/siteorigin-widget.class.php(194): SiteOrigin_Widget_Editor_Widget->get_template_variables(Array, Array)\n
#9 /nas/content/live/sitename/wp-content/plugins/siteorigin-panels/inc/renderer.php(835): SiteOrigin_Widget->widget(Array, Array)\n
#10 /nas/content/live/sitename/wp-content/plugins/siteorigin-panels/inc/renderer.php(1195): SiteOrigin_Panels_Renderer->the_widget(Array, Array, 2, 0, 0, true, true, 45, '')\n
#11 /nas/content/live/sitename/wp-content/plugins/siteorigin-panels/inc/renderer.php(1163): SiteOrigin_Panels_Renderer->render_widget(45, 2, 0, 0, Array, true)\n
#12 /nas/content/live/sitename/wp-content/plugins/siteorigin-panels/inc/renderer.php(1072): SiteOrigin_Panels_Renderer->render_cell(45, 2, 0, Array, Array, Array)\n
#13 /nas/content/live/sitename/wp-content/plugins/siteorigin-panels/inc/renderer.php(553): SiteOrigin_Panels_Renderer->render_row(45, 2, Array, Array)\n
#14 /nas/content/live/sitename/wp-content/plugins/siteorigin-panels/compat/yoast.php(44): SiteOrigin_Panels_Renderer->render(45, false)\n
#15 /nas/content/live/sitename/wp-includes/class-wp-hook.php(324): siteorigin_yoast_sitemap_images_compat(Array, 45)\n
#16 /nas/content/live/sitename/wp-includes/plugin.php(205): WP_Hook->apply_filters(Array, Array)\n
#17 /nas/content/live/sitename/wp-content/plugins/wordpress-seo/inc/sitemaps/class-sitemap-image-parser.php(127): apply_filters('wpseo_sitemap_u...', Array, 45)\n
#18 /nas/content/live/sitename/wp-content/plugins/wordpress-seo/inc/sitemaps/class-post-type-sitemap-provider.php(664): WPSEO_Sitemap_Image_Parser->get_images(Object(WP_Post))\n
#19 /nas/content/live/sitename/wp-content/plugins/wordpress-seo/inc/sitemaps/class-post-type-sitemap-provider.php(211): WPSEO_Post_Type_Sitemap_Provider->get_url(Object(WP_Post))\n
#20 /nas/content/live/sitename/wp-content/plugins/wordpress-seo/inc/sitemaps/class-sitemaps.php(379): WPSEO_Post_Type_Sitemap_Provider->get_sitemap_links('page', 1000, 1)\n
#21 /nas/content/live/sitename/wp-content/plugins/wordpress-seo/inc/sitemaps/class-sitemaps.php(279): WPSEO_Sitemaps->build_sitemap('page')\n
#22 /nas/content/live/sitename/wp-includes/class-wp-hook.php(324): WPSEO_Sitemaps->redirect(Object(WP_Query))\n
#23 /nas/content/live/sitename/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array)\n
#24 /nas/content/live/sitename/wp-includes/plugin.php(565): WP_Hook->do_action(Array)\n
#25 /nas/content/live/sitename/wp-includes/class-wp-query.php(1881): do_action_ref_array('pre_get_posts', Array)\n
#26 /nas/content/live/sitename/wp-includes/class-wp-query.php(3824): WP_Query->get_posts()\n
#27 /nas/content/live/sitename/wp-includes/class-wp.php(696): WP_Query->query(Array)\n
#28 /nas/content/live/sitename/wp-includes/class-wp.php(816): WP->query_posts()\n
#29 /nas/content/live/sitename/wp-includes/functions.php(1336): WP->main('')\n
#30 /nas/content/live/sitename/wp-blog-header.php(16): wp()\n
#31 /nas/content/live/sitename/index.php(17): require('/nas/content/li...')\n
#32 {main}\n thrown in /nas/content/live/sitename/wp-content/plugins/wpforo/themes/2022/layouts/4/forum.php on line 85
3 Replies
Sofy
Posts: 4584
 Sofy
Admin
(@sofy)
Support Team
Joined: 7 years ago

I've already asked the developers to check the issue. I'll keep you updated on any progress.

Reply
2 Replies
Sofy
 Sofy
Admin
(@sofy)
Joined: 7 years ago

Support Team
Posts: 4584

Hi @tfjoel,

Please wait for the next update of the wpForo plugin (it'll come very soon). After updating the plugin, clear the error.log file and inform us if you see any further issues.

Reply
(@tfjoel)
Joined: 5 months ago

New Member
Posts: 2

@sofy thank you for the quick response, will do!

Reply