-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Add test and fix for date_constructor for PHP Versions lower 7.1.0 #15853
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
Conversation
libraries/joomla/date/date.php
Outdated
| if ($date === 'now' && version_compare(PHP_VERSION, '7.1.0', '>=')) | ||
| { | ||
| $date = parent::createFromFormat('U.u', number_format(microtime(true), 6, '.', ''), $tz)->format('Y-m-d H:i:s.u'); | ||
| $data = time(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$data or $date ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shit
If the PHP documentation is right then time() is not a valid value to create a datetime object
|
I did remove the version check, seems to me not really important if JDate has microseconds or not |
|
I have tested this item ✅ successfully on ccbe09d This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/15853. |
|
I have tested this item ✅ successfully on ccbe09d See http://gwsdev1.xyz Note all versions of PHP with PHP-FPM = On and also tested with PHP-FPM = Off Tests: PHP 7.1.14 without patch Timezone US/Central: Wed 05/10/2017 09:02 | Wed 05/10/2017 09:02 PHP 7.1.14 with patch Timezone US/Central: Wed 05/10/2017 09:07 | Wed 05/10/2017 09:07 PHP 5.6.30 without patch Timezone US/Central: Wed 05/10/2017 14:08 | Wed 05/10/2017 09:08 PHP 5.6.30 with patch Timezone US/Central: Wed 05/10/2017 09:09 | Wed 05/10/2017 09:09 PHP 7.0 without patch Timezone US/Central: Wed 05/10/2017 14:10 | Wed 05/10/2017 09:10 PHP 7.0 with patch |
|
RTC after two successful tests. |
Add test and fix for date_constructor for PHP Versions lower 7.1.0
Summary of Changes
Fix for JDate Constructor, integrates the test case from #15642 but with true as 2nd parameter for the format method (default is false and means that we get the time in GMT)
Testing Instructions
Test should be processed with two different PHP Versions one lower 7.1.0 and one 7.1.0 or greater. The results should be the "same" for all versions after the patch is applied.
Access your site
Change the PHP version
Access your site again
Apply patch
Access your site
Change the PHP version
Access your site again
Test is successful when after appling the patch you get correct results, time in a row must be the same expect the last line.
Results
Keep in mind your results are depending on your timezone and the time you are running the test. For me the 2 hour difference in the "Timezone not set" row is ok because I am on CEST what is GMT+2.
The Error is in the "Timezone US/Central" row for PHP Version lower 7.1.0, in my case 5.6.30.
Before Patch:
7.1.1 (local time 14:29)
Timezone US/Central: Sat 05/06/2017 07:29 | Sat 05/06/2017 07:29
Timezone UTC: Sat 05/06/2017 12:29 | Sat 05/06/2017 12:29
Timezone not set: Sat 05/06/2017 12:29 | Sat 05/06/2017 14:29
5.6.30 (local time 14:31)
Timezone US/Central: Sat 05/06/2017 12:31 | Sat 05/06/2017 07:31
Timezone UTC: Sat 05/06/2017 12:31 | Sat 05/06/2017 12:31
Timezone not set: Sat 05/06/2017 12:31 | Sat 05/06/2017 14:31
After Patch
7.1.1 (local time 14:35)
Timezone US/Central: Sat 05/06/2017 07:35 | Sat 05/06/2017 07:35
Timezone UTC: Sat 05/06/2017 12:35 | Sat 05/06/2017 12:35
Timezone not set: Sat 05/06/2017 12:35 | Sat 05/06/2017 14:35
5.6.30 (local time 14:34)
Timezone US/Central: Sat 05/06/2017 07:34 | Sat 05/06/2017 07:34
Timezone UTC: Sat 05/06/2017 12:34 | Sat 05/06/2017 12:34
Timezone not set: Sat 05/06/2017 12:34 | Sat 05/06/2017 14:34
Documentation Changes Required
None