class-sitemap-news-settings
-
Subject: Bug Report: Incorrect callback syntax inclass-sitemap-news-settings.phpcausing PHP 8+ error
Hello,
I am writing to report a bug in the XML Sitemap & Google News plugin that is causing an "Uncaught Error" in PHP 8+.
File location:/wp-content/plugins/xml-sitemap-feed/inc/admin/class-sitemap-news-settings.php
The Issue: When accessing the plugin's settings page, the site throws an error:call_user_func_array(): Argument #1 ($callback) must be a valid callback, array must have exactly two members.
This happens because, in thesettings_page()method, theadd_actioncall forsidebar_priority_supportis using an array with three members instead of the two required by the PHP callback standard:
Original problematic code:array( __NAMESPACE__, 'Sitemap_News_Fields', 'sidebar_priority_support' )
The Fix: I have corrected the callback to properly reference the class and method as a two-member array:array( __NAMESPACE__ . '\Sitemap_News_Fields', 'sidebar_priority_support' )
Reasoning: Modern PHP (8.0+) versions are stricter regarding callback validation. Passing three elements in the array causes a mismatch where the engine fails to identify the class/method pair correctly. By concatenating the namespace with the class name correctly, we ensure the callback follows the standard[ClassName, MethodName]structure.
Applying this change solved the issue and restored the settings page functionality. I suggest updating this in your next plugin release to ensure compatibility for all users running modern PHP environments.
Best regards,
Rodrigo Lampugnani
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.