craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.28k stars 635 forks source link

Fixing date/time input for Arabic broke something #3528

Closed benface closed 5 years ago

benface commented 5 years ago

Description

Sorry, I couldn't come up with a better title because I'm not exactly sure what's going on, but I found that this commit causes the following issue. Maybe it is setup-dependent, so note that I'm using MAMP PRO 5.2 on macOS 10.14.2.

Steps to reproduce

  1. Entries > New Entry (any section, as long as there's a title field)
  2. Leave the title blank and try to save
  3. When the page reloads to highlight the required title field, notice the "Post Date" field is set to the wrong date. For me, there's an extra 5 hours. Note: if we had filled the title field instead of leaving it blank and the page hadn't reloaded, and we then returned to the entry's page, the "Post Date" would be correct, strangely.

Additional info

brandonkelly commented 5 years ago

What is your Timezone set to in Settings > General? Does changing it affect the behavior?

benface commented 5 years ago

@brandonkelly It's set to America/New_York (I am based in Montreal, Canada, so it's the same timezone). And yes, it does seem to affect the behavior. If I change it to UTC, then there is no difference between the value that is pre-filled in the field when there's an error, and the value that is saved when there is no error. So basically the "extra 5 hours" I mention in the issue ^ is the difference from UTC. I tried with UTC-3, and there was a 3 hour difference when the page refreshed due to a validation error.

brandonkelly commented 5 years ago

Unfortunately I’m not able to reproduce this. Whether the timezone is set to UTC, America/New_York, or America/Los_Angeles (my timezone), the selected Post Date is retained when saving a new entry, whether or not there are validation errors.

Do you have any plugins installed, or is there anything unique about your environment you can think of?

benface commented 5 years ago

@brandonkelly Nothing I can think of. I was able to reproduce on a different environment just now (on an actual server running PHP 7.1). Maybe the repro steps aren't clear enough, so here's a video of the issue: https://www.youtube.com/watch?v=AxzX34nwYNY

benface commented 5 years ago

Plugins installed are:

There's also a custom module but the issue occurs even if I disable it.

brandonkelly commented 5 years ago

Ahhh, that clears it up, thanks. I didn’t realize you were leaving the Post Date field blank and letting it get autogenerated by Craft. Fixed for tomorrow’s release.