Title: Undefined offset problem
Last modified: March 1, 2021

---

# Undefined offset problem

 *  Resolved [tommy4](https://wordpress.org/support/users/tommy4/)
 * (@tommy4)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/undefined-offset-problem/)
 * We have a lot of notices like this:
 * Undefined offset: 3 in […]wordpress/wp-content/plugins/wordpress-seo/inc/sitemaps/
   class-post-type-sitemap-provider.php on line 143
 * It seems that the problem is related to MySQL 8 and this query:
 *     ```
       $sql = "
       				SELECT post_modified_gmt
       				    FROM ( SELECT @rownum:=0 ) init
       				    JOIN {$wpdb->posts} USE INDEX( type_status_date )
       				    WHERE post_status IN ('" . implode( "','", $post_statuses ) . "')
       				      AND post_type = %s
       				      AND ( @rownum:=@rownum+1 ) %% %d = 0
       				    ORDER BY post_modified_gmt ASC
       				";
       ```
   
 * MySQL is dropping a warning about it:
    Warning: #1287 Setting user variables 
   within expressions is deprecated and will be removed in a future release. Consider
   alternatives: ‘SET variable=expression, …’, or ‘SELECT expression(s) INTO variables(
   s)’.
 * This query does not work on MySQL 8 and should be probably be rewritten to something
   like this:
 *     ```
       SET @row_number = 0;
       SELECT post_modified_gmt FROM wp_2_posts WHERE post_status IN ('publish') AND post_type = 'page' AND ( @row_number:=@row_number+1) % 1000 = 0 ORDER BY post_modified_gmt ASC
       ```
   
 * Or consider rewriting it to using ROW_NUMBER() function on MySQL 8.
 * The result of this error is lack of last modified date next to the sitemap file,
   which negatively affects SEO, so this bug should be considered important. See
   screenshot here:
    [https://ibb.co/VSTybRL](https://ibb.co/VSTybRL)

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [Pcosta88](https://wordpress.org/support/users/pcosta88/)
 * (@pcosta88)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/undefined-offset-problem/#post-14117985)
 * Hi [@tommy4](https://wordpress.org/support/users/tommy4/),
 * We are running MySQL v8.0.16 with PHP v7.4.1 on WordPress v5.6.2 with Yoast SEO
   v15.9 with debug mode on and we are not seeing those warnings drop into the log
   file. Indeed, all the last modified column data is appearing as expected. See
   image: [https://ibb.co/zmSS7Yg](https://ibb.co/zmSS7Yg).
 * We would like some more information.
 * 1. Can you confirm you are using WordPress 5.6.2? You can check by clicking on
   the W in the top left and selecting About. If you need to update, please check
   with your host provider. Please know that if you are using an older version of
   WordPress Core you may experience unexpected behavior with Yoast. This guide 
   explains more: https://yoast.com/why-we-dont-support-old-wordpress-versions/.
 * 2. Are all your non-Yoast plugins and themes also updated?
 * 3. We had another recent release. Can you confirm you are using the most recent
   Yoast SEO, v15.9? If you update, does the issue resolve?
 * 4. What is the version of MySQL you are using? Is it exactly v8.0.0?
 * 5. Are the last modified columns which are missing related to custom post types?
   If so, how were those custom post types made? Using code or a plugin like Custom
   Post Type UI?
 * 6. If you go to Settings-Permalinks and re-save does the issue resolve?
 * 7. Does clearing your caching from your theme, plugin, server, CDN like CloudFlare
   or browser resolve the issue? If you are not sure how to clear caching from theme/
   plugin please speak to those authors. If you want to clear cache from the server,
   please speak to your host provider. To clear the cache from a browser use this
   guide: [https://yoast.com/help/how-to-clear-my-browsers-cache/](https://yoast.com/help/how-to-clear-my-browsers-cache/)
 * 8. The notices that are appearing on your site are they appearing in the debug.
   log file, some other file, or on the page itself?
 * 9. Did you enable debug mode? We ask as we are trying to figure out where these
   error messages are appearing.
 * 10. Can you elaborate more on how the errors might be triggered? A re-save of
   a post or some other method?
 *  Thread Starter [tommy4](https://wordpress.org/support/users/tommy4/)
 * (@tommy4)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/undefined-offset-problem/#post-14118473)
 * Thank you for your quick response.
 * 1. Yes, we are running WordPress 5.6.2.
    2. Yes, we have wp-cli updating our 
   plugins daily and also our employee checks all plugin versions weekly (as some
   plugins wp-cli have troubles updating like YoastSEO Pro 🙂 3. We have multi-site
   installation and we have two plugins installed: YoastSEO and YoastSEO Pro, both
   with version 15.9. The plugins are not network active. Some websites have YoastSEO
   active (majority) and we have one website with YoastSEO Pro active because the
   owner of the domain paid for it, so we keep unpaid version for other domains 
   and paid version for that one. 4. Server version: 8.0.23-0ubuntu0.20.04.1 (Ubuntu)
   5. Please see screenshot in my first post – these are normal post and pages. 
   When I click on specific sitemap all of the items have modified time present.
   6. No, it doesn’t resolve. 7. No, clearing the Cloudflare cache (we do that via
   API during deployment), browser cache (CTRL+F5, incognito, another browser), 
   and clearing our memcached server doesn’t help 8. It appears on our error log,
   we have made custom error handling, but without it, it would appear on debug.
   log or on the page itself if we had display_errors on and error_reporting that
   includes E_NOTICE. 9. No, it appears on production so we do not have DEBUG mode
   on. 10. They show up every time we or someone access the file /sitemap_index.
   xml
 *  Thread Starter [tommy4](https://wordpress.org/support/users/tommy4/)
 * (@tommy4)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/undefined-offset-problem/#post-14118909)
 * Here is what happens when running the query in database:
 *     ```
       mysql> SELECT post_modified_gmt FROM ( SELECT @rownum:=0 ) init JOIN wp_2_posts USE INDEX( type_status_date ) WHERE post_status IN ('publish') AND post_type = 'page' AND ( @rownum:=@rownum+1 ) % 1000 = 0 ORDER BY post_modified_gmt ASC;
       Empty set, 2 warnings (0.00 sec)
   
       mysql> show warnings;
       +---------+------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
       | Level   | Code | Message                                                                                                                                                                                              |
       +---------+------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
       | Warning | 1287 | Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. |
       | Warning | 1287 | Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. |
       +---------+------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
       2 rows in set (0.00 sec)
       ```
   
 * And here is the result of modified query with deleted @rownum variables:
 *     ```
       SELECT post_modified_gmt FROM  wp_2_posts WHERE post_status IN ('publish') AND post_type = 'page' ORDER BY post_modified_gmt ASC;
       ```
   
 * [https://pastebin.com/KLHNMV4y](https://pastebin.com/KLHNMV4y)
 * The data seems to be ok.
    -  This reply was modified 5 years, 3 months ago by [tommy4](https://wordpress.org/support/users/tommy4/).
 *  Plugin Support [Michael Tiña](https://wordpress.org/support/users/mikes41720/)
 * (@mikes41720)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/undefined-offset-problem/#post-14120400)
 * Hi,
 * Regarding the missing dates in the sitemap, could you check on this article and
   see if it helps — [https://yoast.com/help/missing-or-invalid-date-in-xml-sitemap/](https://yoast.com/help/missing-or-invalid-date-in-xml-sitemap/)
 * You mentioned that you have an active subscription of Yoast SEO Premium. Is the
   issue regarding those notices and the missing last modified dates in the sitemap
   also occurring on the website with the premium plugin? If so, please also do 
   feel free to contact us directly so we can take a closer look at it — [https://yoast.com/help/support/#premium](https://yoast.com/help/support/#premium)
 *  Thread Starter [tommy4](https://wordpress.org/support/users/tommy4/)
 * (@tommy4)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/undefined-offset-problem/#post-14121301)
 * Unfortunately, that one website uses the Google XML Sitemap plugin for XML Sitemaps.
 * Anyway, the problem is present on multiple of our network websites and probably
   shows up when there are more than 1000 (or 2000) pages defined in WordPress. 
   I also see the code in YoastSEO Pro for the sitemap generation is the same.
 * Regarding the missing dates – we do not have missing dates in particular sitemaps–
   we have missing dates in the sitemap index (list of sitemaps). And this is not
   related to custom types.
    -  This reply was modified 5 years, 3 months ago by [tommy4](https://wordpress.org/support/users/tommy4/).
 *  [Md Mazedul Islam Khan](https://wordpress.org/support/users/mazedulislamkhan/)
 * (@mazedulislamkhan)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/undefined-offset-problem/#post-14137950)
 * Thanks for your clarification. We are sorry to hear that you’re still having 
   trouble with our plugin. Due to the nature of the issue, we’ll need to take a
   look at your setup. However, we are unable to do it here as this is a public 
   forum.
 * So, if you have an active [Yoast SEO Premium](https://yoast.com/wordpress/plugins/seo/)
   subscription or if you can consider buying one, we can investigate the issue 
   further directly on your setup privately through email.
 * However, if you don’t wish to get the Yoast SEO Premium subscription, that’s 
   completely fine. In this case, you’ll need to troubleshoot the issue further 
   on your setup as we are literally out of any clue at this moment without taking
   a look at the setup. So, someone from the community might step forward as well
   who has experienced the issue.
 * Thanks for your understanding!
 *  [devnihil](https://wordpress.org/support/users/devnihil/)
 * (@devnihil)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/undefined-offset-problem/#post-14167470)
 * We are going ahead and marking this issue as resolved due to inactivity. If you
   require any further assistance please create a new issue.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Undefined offset problem’ is closed to new replies.

 * ![](https://ps.w.org/wordpress-seo/assets/icon-256x256.gif?rev=3419908)
 * [Yoast SEO - Advanced SEO with real-time guidance and built-in AI](https://wordpress.org/plugins/wordpress-seo/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wordpress-seo/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wordpress-seo/)
 * [Active Topics](https://wordpress.org/support/plugin/wordpress-seo/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wordpress-seo/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wordpress-seo/reviews/)

## Tags

 * [undefined offset](https://wordpress.org/support/topic-tag/undefined-offset/)

 * 7 replies
 * 5 participants
 * Last reply from: [devnihil](https://wordpress.org/support/users/devnihil/)
 * Last activity: [5 years, 2 months ago](https://wordpress.org/support/topic/undefined-offset-problem/#post-14167470)
 * Status: resolved