User tests: Successful: Unsuccessful:
Removes use of strtotime()
in favor of string comparison for dates.
Use 32-bit version of PHP 8.0.0 RC1 or newer dev build.
Create an article. Don't set Finish Publishing
date.
View article list/blog/featured view containing the article in frontend.
View the article in frontend.
Warning: strtotime(): Epoch doesn't fit in a PHP integer
No warnings.
No.
Status | New | ⇒ | Pending |
Category | ⇒ | Front End com_content Layout Templates (site) |
@SharkyKZ
Can you also fix it here
joomla-cms/components/com_contact/tmpl/category/default_items.php
Lines 113 to 126 in a1ecbc2
@infograf768 Will do. But I'm starting to question the validity of this fix. It has a limited range:
The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 UTC to Tue, 19 Jan 2038 03:14:07 UTC. (These are the dates that correspond to the minimum and maximum values for a 32-bit signed integer.)
I guess we should account for values outside this range?
I was born after 1901 and 2038 would mean I would be 90. Can't project so far. ;)
But this says that anyway code will have to be modified in 2038.
https://www.unixtimestamp.com/ (unix starts in 1970 btw)
Do we even need strtotime()
here? Looks like we could be comparing date strings instead.
Dates returned from the databases should always be the same format, right?
@SharkyKZ Yes, but the question is not if it is the same format always but if this format means that alphabetical sorting is equal to sorting by date and time, and this is not given for a format like e.g. "DD.MM.YYYY hh:nn:ss". Alphabetical sorting is only equal to sorting by date and time if the order of the time periods "year, month, day ... seconds" is either ascending or descending with the length of these periods, and if the number of digits used for each period is always the same, i.e. it will not work when using only 1 digit for months 1 to 9.
So the ISO formats (short or long) fulfil this, they go from year down to second: "YYYY-MM-DD hh:mm:ss".
It would theoretically also work with "ss:mm:hh DD-MM-YYYY", but nobody really uses that.
So if you can be 100% sure that the string representation is always the same ISO format, then you can compare strings like times.
But if not, then you have to force this format.
But dates from the database are always going to be in YYYY-MM-DD hh:mm:ss
(or Y-m-d H:i:s
in PHP terms) format across all supported databases and locales?
We can't use strtotime()
because of the limitations. And we do only support Y-m-d H:i:s
format for database dates. Database API can support different formats but this doesn't concern the CMS.
I'll do that later. It's for 4.0 anyways. There's also same issue in calendar field on 4.0.
Like Richard I don have a 32-bit environment either, who does
I have tested this item
I tested on 64 bit PHP8. Added article. Added cat blog, cat list, single article, featured on the frontend. No errors. Couldn't find it broke anything.
I have tested this item
ups i forgot i'm a troll #30716 (comment)
ups i forgot i'm a troll #30716 (comment)
not sure what you mean with this but in this case it's important to know which version you tested. (I mean it's always a useful information)
if you read the comment you wll understand that asking by one who call you a troll is …
Exactly this behaviour was what I've meant.
Status | Pending | ⇒ | Ready to Commit |
RTC
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2020-12-07 16:06:32 |
Closed_By | ⇒ | HLeithner | |
Labels |
Added:
?
|
Thanks
Unfortunately I don't have the required testing environment, 32-bit version of PHP 8.0.0 RC1 or newer dev build.
But from code review it's absolutely clear what this PR does, and it makes sense, first check for the null date and then to a strtotime for the other check, and not vice versa.
@HLeithner What do you think? Would you count a good code review as a good test, too?