Opened 5 years ago
Last modified 5 years ago
#48006 new defect (bug)
post_date not as expected
Reported by: | marrank | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 5.2.3 |
Component: | Posts, Post Types | Keywords: | has-patch has-unit-tests |
Focuses: | Cc: |
Description
I have noticed this when scheduling a post.
1) From wp-admin choose Pages.
2) Add new.
3) Change from publish immediately to selecting time and date.
4) Select a date, for example, 2019-09-09 17:00
5) Save the post.
6) Look in the wp_posts table in the database for the post and the post_date column will be something like 2019-09-09 17:00:21
It is not really as expected since you, as a user, are not able to set which second the page should be published you assume it would be at 00. In this case you expect that is is 17:00:00. The problem is that if you have a scheduled crontab that runs every 5 minutes (*/5) it will get missed schedule the first time since the cron will run at 17:00:00 and the publish time of the post is 17:00:21. From my experience most users choose the schedule at top of the hour so we get this missmatch a lot. For us it would be easier if assumed that it is 00 seconds always.
Attachments (4)
Change History (18)
#5
@
5 years ago
Hi!
Thanks for looking into this so quickly! The fix does unfortunately not working for me. I see the code, it makes sense what you have done but it does not look like it runs when I am saving the post. So I am still getting current second in my post_date.
#7
@
5 years ago
Hi! I did the steps 1-6 in the original ticket. Ie logging in to wp-admin and creating a page with a future date. It looks like wp_insert_post is run when i press add new page, but not when I save when is which the future date is set.
#8
@
5 years ago
Try to look in the screenshot above @marrank. Posts ID 45
and 47
are scheduled and as you can see their seconds are :00
.
Just to confirm a few things.
- How are you applying the patch? Try to build the source files with the command
npm run build
to make sure that the changes are applied.
- The fix is only applied to the actual
post
and not withrevisions
.
#9
@
5 years ago
@donmhico Ok!
1) I manually went inte wp-include/post.php and added it.
2) Ok yes
Have you created those post through wp-admin or through your unit test?
#10
@
5 years ago
Thanks for your response @marrank. Yes i've tested it manually. The screenshot I gave above is from a manual created post.
Here are my steps.
- Go to /wp-admin.
- Create a post with Publish: "Immediately" changed to a future time.
- Save post.
#11
follow-up:
↓ 12
@
5 years ago
Hmm ok yes then we have the same workflow. I guess it could be a plugin or something that is messing it up. I will try with a clean install! Can you also send your post.php for reference?
#12
in reply to:
↑ 11
@
5 years ago
Replying to marrank:
Hmm ok yes then we have the same workflow. I guess it could be a plugin or something that is messing it up. I will try with a clean install!
I'm hoping this might be helpful: wp-include/post.php has seen other changes since the latest release, so make sure you're applying the patch to a development copy (such as https://wordpress.org/nightly-builds/wordpress-latest.zip).
#13
in reply to:
↑ 2
@
5 years ago
Replying to donmhico:
I've attached a patch, 48006.diff, that should address the issue.
The code comment in the main patch and the unit test name both refer to the top of the "hour". I believe that should be top of the "minute"? I'd be happy to update the patches, if that would help.
#14
@
5 years ago
@donmhico Sorry, but I cant get this to work.
Now I did
1) wp core download --version="nightly"
2) In wp-admin dashboard it says WordPress 5.3-alpha-46152
3) Create post with changed Immediately to a set date.
However when I inspect in database it still uses seconds. Not sure why it not working. @jonbakke Maybe you could try it as well? That would be really helpful for my sanity :-D
Hello @marrank. Thank you for the report ticket and welcome to the WordPress trac. I've attached a patch, 48006.diff, that should address the issue.