WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#39581 closed defect (bug) (invalid)

Unexpected Date Modified after delete and re-import

Reported by: ChiefAlchemist Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.7.1
Component: Posts, Post Types Keywords:
Focuses: Cc:

Description

Mind you, this is a rare / odd use case, but the results are still unexpected, if not bug-esque.

I'm using the plugin WP RSS Aggregator + some custom code to import posts. BTW, I noticed this oddity in the process of dev'ing + testing my custom code.

Long to short, I import a feed, I see that it's working so delete those posts, and then empty the trash. I do some more coding and repeat the import process. Well, the Date of the new post - of the new import (of the same RSS items I just deleted) - shows "Last Modified..." (of a couple days ago).

How can Last Modified be a couple days ago if that version of the post is brand new? Is something not getting trashed when I Empty Trash?

Change History (3)

#1 @dd32
3 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Hi @ChiefAlchemist and welcome back to Trac.

Unfortunately your report doesn't leave much to go on - I'm not aware of any bugs similar to what you describe, and the caches would definitely be cleared as expected.

I'm assuming that this is something wrong with your code, or how it interacts with WordPress.

If you can reproduce it in a short PHP function, we'd be able to look at it further, but as it stands I'm marking this as invalid for now. If you can reproduce this in a consistent manner and can share some code to do so, please feel free to reopen the ticket.

#2 @ChiefAlchemist
3 years ago

hello @dd32 -

"I'm assuming that this is something wrong with your code, or how it interacts with WordPress."

Best I can tell, I don't think so. I'm not manipulating the dates at all. Just setting some properties and using wp_insert_post().

So I'm adding via wp_insert_post(). I manually delete and then trash (via admin). And then I "import" again using wp_insert_post().

There's not " much to go on" because that's is the gist of what is creating the problem :)

Can you tell me what the Date(s) should be reading for those "new" rows? Maybe what I'm seeing is correct? But seeing "last modified" when I know it's a new row makes no sense at all.

#3 @rmccue
3 years ago

It depends on how exactly you're importing here. When posts are first created, the modified time is set to the post date. On subsequent updates, the modified time is changed to the current time.

If you're only calling wp_insert_post a single time (to create the post), the post status is set to publish, and you're passing in a post date, then the modified time will be set to the supplied post date.

Note: See TracTickets for help on using tickets.