Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#47304 closed defect (bug) (fixed)

Feed <lastBuildDate> Bug

Reported by: onlanka's profile onlanka Owned by: desrosj's profile desrosj
Milestone: 5.2.1 Priority: normal
Severity: normal Version: 5.2
Component: Feeds Keywords: has-patch commit dev-reviewed
Focuses: Cc:

Description

My wordpress site's feed doesn't show latest post's date and time in the

<lastBuildDate>

Eg:

<lastBuildDate>Wed, 15 May 2019 10:42:52 +0000</lastBuildDate>
<pubDate>Fri, 17 May 2019 08:43:44 +0000</pubDate>

There is a gap of 2 days between latest post and Last Build Date!

I don't use any cache plugin.
PHP Version: 7.3

Please explain me how to fix this issue.

My website's feed URL:

https://www.onlanka.com/feed

Attachments (2)

47304.patch (779 bytes) - added by Rarst 5 years ago.
47304.diff (586 bytes) - added by mukesh27 5 years ago.
Patch.

Download all attachments as: .zip

Change History (15)

#1 @onlanka
5 years ago

I got confirmed, this is a database issue.
Wordpress sites older than 7-8 years could be affected.

Here what I did to get confirm the place of issue:

  1. I duplicated wordpress site into a subfolder (database also duplicated to seperate from main site)

New Test location: https://www.onlanka.com/wptest/

  1. Deactivated all the plugins.
  2. Deleted all the plugins.
  3. Activated wordpress default theme twentynineteen
  4. Then posted a new test post.
  5. Then checked https://www.onlanka.com/wptest/feed
  1. Still <lastBuildDate> not updating with latest posts.
  2. Also When I visit feed link https://www.onlanka.com/wptest/feed , it gives the file as feed but I checked another fresh installation of wordpress and it gives xcGddgR random letters as feed file name.
  1. Then I did wordpress fresh installation + fresh database and then did test post. It has no issues, Then I replaced database with my old database, Then issue came back as said above.

If you have a way to repair feed updating part in the database, this could be fixed.

Please give me a solution for this.

Last edited 5 years ago by onlanka (previous) (diff)

#2 @SergeyBiryukov
5 years ago

  • Keywords reporter-feedback added
  • Milestone changed from Awaiting Review to 5.2.2

Hi @onlanka, welcome to WordPress Trac! Thanks for the report.

Does the issue still happen with all plugins disabled and a default theme (Twenty Nineteen) activated?

Moving to 5.2.2 for visibility, could be introduced in [44948] / [45247].

#3 @onlanka
5 years ago

@SergeyBiryukov Yes, I disabled all the plugins, also activated default theme twentynineteen.

But it is still happening

My blog is older than 8 years, but I did regular updates in timely manner. only older WordPress installations affected.

Please release a patch to repair feed

Last edited 5 years ago by onlanka (previous) (diff)

#4 @onlanka
5 years ago

  • Keywords needs-dev-note dev-feedback added

Finally I fixed it, But this might be Not the correct way.
But I had to do this until official patch released for this issue.

What I did is, in wp-includes/feed-rss2.php

Code line 45 was:

<lastBuildDate><?php echo get_feed_build_date( 'r' ); ?></lastBuildDate>

I replaced it with:

<lastBuildDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ); ?></lastBuildDate>

This has fixed the problem, but again this might not the correct way to fix this problem!

I applied this fix to my live blog, it's feed URL is:

https://www.onlanka.com/feed

#5 @Rarst
5 years ago

  • Keywords has-patch added; needs-patch reporter-feedback needs-dev-note dev-feedback removed
  • Severity changed from critical to normal

Yeah, it's a bug in new function since it relies on string sort in max() after it applies arbitrary date format (so result is not all necessarily string sortable). Adding patch.

@Rarst
5 years ago

@mukesh27
5 years ago

Patch.

#6 @mukesh27
5 years ago

@Rarst added fix patch. i have not updated page so i can't get update and added patch.

#7 @SergeyBiryukov
5 years ago

  • Keywords commit added
  • Milestone changed from 5.2.2 to 5.2.1

#8 @desrosj
5 years ago

  • Owner set to desrosj
  • Status changed from new to reviewing

#9 @SergeyBiryukov
5 years ago

  • Keywords dev-reviewed added

Looks good to me.

#10 @desrosj
5 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 45367:

Feeds: Ensure a feed’s <lastBuildDate> has the correct date.

The maximum modified time for a is currently being determined after an arbitrary date format is applied. Because the string sort in max() is being used to return the highest (most recent) modified value, the incorrect date is sometimes returned. This was introduced in [45247].

Props onlanka, Rarsr, mukesh27.
Fixes #47304.

#11 @desrosj
5 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening to backport.

#12 @desrosj
5 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 45368:

Feeds: Ensure a feed’s <lastBuildDate> has the correct date.

The maximum modified time for a is currently being determined after an arbitrary date format is applied. Because the string sort in max() is being used to return the highest (most recent) modified value, the incorrect date is sometimes returned. This was introduced in [45247].

Merges [45367] to the 5.2 branch.

Reviewed by desrosj, SergeyBiryukov.
Props onlanka, Rarst, mukesh27.
Fixes #47304.

Note: See TracTickets for help on using tickets.