New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
text_date_timestamp field incorrectly displaying some timestamps #1448
Comments
I confirm, this bug is in version 2.10 (wrong specific dates on both versions: 18-01-2022 or 01/18/2022, 21-04-2022, 18-06-2022). |
Thank you for reporting. Can you test the changes on the develop branch to confirm the issue is fixed for your use-cases? |
Done, fixed. |
Thank you for your quick response. Yes, I can also confirm this is fixed. |
2.10.1 was just pushed to fix this. |
Describe the bug
On entering some dates the
text_date_timestamp
field type will display an incorrect date after the field has been saved.Steps to reproduce
text_date_timestamp
field as normal, I am using it on a custom post type, but this doesn't seem to matter.Possible Solution
I believe I have tracked the issue down to a change (commit 37c8763 I believe) to the
CMB2_Utils::make_valid_time_stamp()
function. Passing a valid timestamp throughstrtotime()
such as 1658534400 (which is the timestamp for 07/23/2022) does not always return false and so returns an unexpected timestamp such as 76687491533 which is 02/17/4400.Replicated on a fresh WordPress install, using a fresh download of the git repo. Also replicated by taking an unrelated project using an older version of CMB2 (2.7.0) and adding the changes implemented to
CMB2_Utils::make_valid_time_stamp()
. Doing so introduced the problem described above, and was fixed by reverting the code.I have rolled back to the code to from before the commit and that has fix the issue for my client's site. I believe the commit was required to help with dates from the API etc so that may not be the best overall solution.
CMB2 Field Registration Code:
Replicated in multiple projects. Using the registration code taken from the documentation for a
text_date_timestamp
field has reproduced this error during testing. For example:The code provided for the
text_date_timestamp
in theexample-functions.php
file can also be used.Your Environment
Replicated on multiple environments (Apache + Nginx), using PHP versions 7.4 and 8.0.
Additional Notes
The problem does not appear to be too disruptive as the timestamp is saved to the database correctly, it is just displayed in the admin field incorrectly. However if the page is saved while the incorrect date is shown in the field it appears to replace the date with the incorrect date causing disruption to the site.
The text was updated successfully, but these errors were encountered: