Fix strtotime() warnings on PHP 8#30921
Fix strtotime() warnings on PHP 8#30921HLeithner merged 7 commits intojoomla:stagingfrom SharkyKZ:j3/php8/strtotime
Conversation
|
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? |
|
@SharkyKZ 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:
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. ;) |
|
Do we even need |
@SharkyKZ Where do you mean? For the greater than or lower than comparisons we can only use strings if we can 100% be sure that they are in ISO format. |
|
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 |
@SharkyKZ Exactly that's what I'm not 100% sure about. At least on MS SQL Server it might be different. |
|
@SharkyKZ I'd stay with the strtotime to play safe. |
|
We can't use |
|
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 🤔 However code review looks good. |
|
@roland-d can you test on a 64bit system? |
|
also @roland-d will you see if Patch Tester gives you this PR in PHP8? :) |
|
I have tested this item ✅ successfully on bbcb7bf This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30921. |
|
I have tested this item ✅ successfully on bbcb7bf This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30921. |
|
@Gostn Which PHP version did you use? 8? If so: 32 or 64 bit? |
|
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 … |
|
ok @Gostn but still no answer for the version |
|
Exactly this behaviour was what I've meant. |
as long as i´m called a troll and no apologize for that … |
|
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30921. |
|
Thanks |
• fix batch/copy on php 8 ([#31536](joomla/joomla-cms#31536)) • Fix strtotime() warnings on PHP 8 ([#30921](joomla/joomla-cms#30921))
Summary of Changes
Removes use of
strtotime()in favor of string comparison for dates.Testing Instructions
Use 32-bit version of PHP 8.0.0 RC1 or newer dev build.
Create an article. Don't set
Finish Publishingdate.View article list/blog/featured view containing the article in frontend.
View the article in frontend.
Actual result BEFORE applying this Pull Request
Expected result AFTER applying this Pull Request
No warnings.
Documentation Changes Required
No.