• I have a blog with hundreds of blog posts going back many years. No recent changes to my themes/HTML/CSS/JS, no problems with previous WP updates, everything worked great with WP 5.2, no problems indicated in the new Tools -> Site Health page.

    After the WP 5.3 update today about half of my blog post permalinks now cause 301 redirects back to the home page, while the other half of my post permalinks still work normally. I can’t find any common factor to the posts that are redirecting vs the ones that are working. It seems completely random. Is this a known bug in 5.3?

    The problem posts actually still exist and I see them in the editor (but can’t preview them however,the editor preview link does a 301 redirect to the home page as too).

    I tried regenerating my htaccess file by using the “save changes” button on the General -> Permalinks page and verified it created a new htaccess file but it had no effect on the problem.

    I’ve checked all the usual browser stuff (cleared cache, tried multiple browser types from multiple boxes, tried incognito mode, turned off caching completely, etc). Even used wget to check the actual results and verify the server is sending a 301 for some posts.

    Here are two examples of blog posts that still work:

    https://www.steevithak.com/2019/05/04/going-electric-part-3-bolt-ev-3000-mile-review/

    https://www.steevithak.com/2015/02/28/men-like-gods-by-h-g-wells/

    And here are two examples of blog posts that still exists but can’t be seen any more because you get 301 redirects when you try to view them:

    https://www.steevithak.com/2018/07/23/ecotopia-by-ernest-callenbach/

    https://www.steevithak.com/2015/02/15/the-origin-of-consciousness-in-the-breakdown-of-the-bicameral-mind-by-julian-jaynes/

    Should I just wait for 5.3.1 to fix this or does anyone have any other suggestions on what I can try?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Tellyworth

    (@tellyworth)

    Do you have a caching plugin installed? Or any plugins related to redirection, SEO, etc?

    This may be a plugin or theme conflict. Please attempt to disable all plugins, and use one of the default (Twenty*) themes. If the problem goes away, enable them one by one to identify the source of your troubles.

    If you can install plugins, install “Health Check”: https://wordpress.org/plugins/health-check/ On the troubleshooting tab, you can click the button to disable all plugins and change the theme for you, while you’re still logged in, without affecting normal visitors to your site.

    Thread Starter steevithak

    (@steevithak)

    No caching, seo, or redirect plugins are installed.

    I use one of the Twenty* themes (or a slight variation on one, anyway)

    I installed the Health Check plugin. I used it to turn off all other plugins and switch to the newest default theme. The problem still occurs with one slight difference. Instead of a 301 redirect I get a 404 with an error that says the page no longer exists. I’m guessing my live theme has a built-in redirect on the 404 page that sends users to the main page. Either way, though, it’s broken. The posts are actually in the data base and can still be seen in the editor view.

    Thread Starter steevithak

    (@steevithak)

    WOW, just made a breakthrough and found an interesting clue into the source of the bug! Over time, pages that used to get errors have started working and pages that were working a few hours ago are now getting errors. By capturing the URLs in the request header in the browser console and comparing them to the URLs in the page permalink display in the WP editor, I’ve found that the problem is due to a time mismatch in WP 53. There seems to be a time zone shift between the time WP uses to render the permalink in the live URLs used throughout the website and the permalink where the page really lives.

    For example compare these two URLs:

    https://www.steevithak.com/2018/07/22/ecotopia-by-ernest-callenbach/

    https://www.steevithak.com/2018/07/23/ecotopia-by-ernest-callenbach/

    The first one with a ’22’ in the day field is the real URL where the page really lives. It’s the URL that’s been indexed by Google. It’s the URL that was always used prior the WP 53 upgrade.

    The second URL, copied from the permalink display in the WP editor, from after the WP 53 upgrade, has the wrong day – BUT – not all of the time! The day field varies between ’22’ and ’23’ depending on what time of day it is! Part of the day I get the page error and part of the day the page works depending which day WP sticks in the links it displays on the site for that page.

    My conclusion is that WP is using the wrong time zone to render permalink times or blog timestamps. There’s some cross over between the time zone WP is using to build the live URL vs the Central time zone, where I live and which was used to put in the ’22’ when the page was created. Because midnight is out of sync between the two zones, there’s a period of time when it shifts between day 22 and 23.

    There’s probably a line of code where WP uses the Unix epoch time to render the permalink from the timestamp on the blog post and it’s supposed to render it using the user’s local time zone but is instead rendering it either as straight UTC time or in some other wrong time zone. And since this worked on WP 52 and older, I bet you could find it by checking the source code diff between WP 52 and 53.

    Thread Starter steevithak

    (@steevithak)

    I filed a bug report on this one and we’ve made some progress. There is actually a bug. It causes 404/301 errors on valid blog posts due to a one day shift in the day value in the dynamically generated permalink from get_permalink() vs the real permalink associated with the post. The bug seems to only affect a small percentage of posts, likely only those with a timestamp near midnight where a change in time zone could shift the day up or down by one.

    I found an experimental change that fixes the problem by reverting one line of code from 5.3 (I wouldn’t recommending making the change on a production site yet but I’m hopeful there will be some kind of real fix soon). Here’s a link to the bug report:

    https://core.trac.wordpress.org/ticket/48623

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘WP 5.3 Causing random 301 redirects’ is closed to new replies.