• Resolved Name

    (@higvil)


    Hello Genius @ravanh.
    Is XML Sitemap & Google News compatible with WordPress6.0 & PHP 8.0?
    After upgrading WordPress6.0 & PHP 8.0, I got this Fatal error on “sitemap-posttype-news.*.xml”.

    
    2022/05/29 06:04:06 [error] 5806#0: *163418 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught TypeError: Illegal offset type in isset or empty in /home/my-site/DocumentRoot/wp-content/plugins/xml-sitemap-feed/controllers/class.xmlsf-sitemap.php:303
    Stack trace:
    #0 /home/my-site/DocumentRoot/wp-content/plugins/xml-sitemap-feed/views/feed-sitemap-posttype.php(13): XMLSF_Sitemap->prefetch_posts_meta()
    #1 /home/my-site/DocumentRoot/wp-includes/template.php(770): require_once('/home/...')
    #2 /home/my-site/DocumentRoot/wp-content/plugins/xml-sitemap-feed/controllers/functions.shared.php(186): load_template('/home/...')
    #3 /home/my-site/DocumentRoot/wp-includes/class-wp-hook.php(307): xmlsf_load_template(false, 'sitemap-posttyp...')
    #4 /home/my-site/DocumentRoot/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters('', Array)
    #5 /home/my-site/DocumentRoot/wp-includes/plugin.php(476): WP_Hook->do_action(Array)
    #6 /home/my-site/DocumentRoot/wp-includes/functions.php" while reading response header from upstream, client: 66.249.66.26, server: mysite.com, request: "GET /sitemap-posttype-news.202205.xml HTTP/2.0", upstream: "fastcgi://127.0.0.1:9000", host: "mysite.com"
    

    with PHP 8.0, “sitemap.xml” works fine but “sitemap-posttype-news.*.xml” gets Fatal error.
    with PHP 7.4, ALL works fine.

    I’m using…
    – PHP 8.0.19
    – WordPress 6.0
    – MariaDB 10.5.16
    – nginx/1.21.6
    – CentOS Linux release 7.9.2009
    – my server is on AWS EC2 t3a.micro
    – All other plugins are disabled
    – Default theme (Twenty Twenty-Two)

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi, thank you for reporting the issue. So you have a custom post type “News”? You write that all other plugins are disabled and you are using the default theme so I wonder how/where this custom post type is defined. And do you know the parameters that were used in register_post_type() for your custom post type?

    In any case, if you are prepared to edit the plugin files, you could fix it right now instead of waiting for the next release.

    Go to Plugins > Plugin File Editor, select the plugin XML Sitemap & Google News and browse to the file controllers > class.xmlsf-sitemap.php

    Find the ling 303 that should show this:

    
    if ( ! isset($this->post_types[$post_type]) ) return;
    

    and modify that to:

    
    if ( empty( $post_type ) || ! is_string( $post_type ) || ! isset($this->post_types[$post_type]) ) return;
    
    Thread Starter Name

    (@higvil)

    I apologize I forgot to say that I wrote these code on theme’s functions.php

    add_action( 'init', function () { 
    	register_post_type( 'news', [ 
    		'label' => 'Latest News!',
    		'public' => true,
    		'menu_position'=>30,
    		'supports' => array('title', 'editor', 'thumbnail' ), 		
    		'show_in_rest'=>true,
    		'has_archive' =>true, 
    	]);
    });

    Thank you very much for your answer. After modifying class.xmlsf-sitemap.php, Fatal errors disappeared. Fixed??
    I am looking forward to being next version released.????

    Strange. I tried to reproduce the issue with your register post type code on PHP 8.0.19, WP 6.0 and XML Sitemap & Google News 5.3.3 but I get no error message. Not even a notice…

    Anyway, good to hear the patch fixed it for you ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘compatible with WordPress6.0 & PHP 8.0?’ is closed to new replies.