Back to Community

Resolving PHP Deprecated and Warning Errors in XML Sitemap Generator for Google

6 threads Sep 16, 2025 PluginXml sitemap generator for google

Content

Users of the 'XML Sitemap Generator for Google' plugin have reported several PHP notices and warnings, particularly after upgrading to newer PHP versions like 8.1. These errors do not typically break the plugin's core functionality but can clutter error logs and indicate code that needs updating for modern PHP standards. This guide covers the most common errors and their solutions.

Common Error 1: PHP Deprecated: set_time_limit(): Passing null to parameter #1 ($seconds)

Error Message:
PHP Deprecated: set_time_limit(): Passing null to parameter #1 ($seconds) of type int is deprecated in .../google-sitemap-generator/sitemap-core.php on line 1871

Why It Happens:
This deprecation notice appears in PHP 8.1 and above. The function set_time_limit() requires an integer argument, but the plugin's code was passing a null value from an empty setting.

Solution:
The 'XML Sitemap Generator for Google' team has acknowledged this issue for a future release. As a temporary workaround, ensure the plugin's Execution time limit setting contains a numeric value. Navigate to the plugin's settings and in the field for increasing the execution time limit, enter a number like 60. Leaving this field blank was a primary cause of the error.

Common Error 2: PHP Warning: Invalid argument supplied for foreach()

Error Message:
PHP Warning: Invalid argument supplied for foreach() in .../google-sitemap-generator/sitemap-builder.php on line 476

Why It Happens:
This warning occurs when the variable $pages is not an array but is passed into a foreach() loop, which expects an array or object.

Solution:
The community has identified a code modification that resolves this. To apply the fix, you must edit the plugin file directly. Warning: Editing plugin files is not recommended as changes will be lost during updates. This fix is intended as a temporary measure until an official update is released.

  1. Access your website's files via FTP or your hosting provider's file manager.
  2. Navigate to /wp-content/plugins/google-sitemap-generator/.
  3. Open the file sitemap-builder.php in a code editor.
  4. Find line 476, which should look like this:
    foreach($pages as $page) {
  5. Modify the line to this:
    foreach((array) $pages as $page) {
  6. Save the file and upload it back to the server, overwriting the old one.

Common Error 3: PHP Warning: Undefined array key

Error Message:
PHP Warning: Undefined array key 1 in .../sitemap-core.php on line 1002
PHP Warning: Undefined array key 2 in .../sitemap-core.php on line 1001

Why It Happens:
This warning suggests the code is trying to access specific keys in an array that do not exist. The code on these lines is attempting to split a time string into hours, minutes, and seconds but is occasionally receiving a string in an unexpected format (e.g., without all three parts).

Solution:
This issue has been reported to the 'XML Sitemap Generator for Google' team. A permanent fix will require a code change to validate the time string format before processing it. Users experiencing this warning should monitor the plugin's update log for a patch.

General Best Practices

  • Always back up your website before modifying any plugin files.
  • Be aware that editing plugins directly is a temporary solution; your changes will be overwritten when the plugin updates.
  • Keep your WordPress, PHP, and plugins updated to their latest stable versions to benefit from bug fixes and security patches.

While these community-identified workarounds can help suppress error logging, the long-term resolution depends on an official update from the 'XML Sitemap Generator for Google' development team.