? Success

User tests: Successful: Unsuccessful:

avatar andrepereiradasilva
andrepereiradasilva
4 Dec 2016

Summary of Changes

In 3.7 JDate will override DateTime default behaviour to set the microseconds to current time (see #11890)

It seems that, as of php 7.1, the new DateTime() will do the same, ie, set the microseconds when creating a date with the current time.

DateTime and DateTimeImmutable now properly incorporate microseconds when constructed from the current time, either explicitly or with a relative string (e.g. "first day of next month"). This means that naive comparisons of two newly created instances will now more likely return FALSE instead of TRUE:

Source http://php.net/manual/en/migration71.incompatible.php#migration71.incompatible.datetime-microseconds

So probably is best to have a php version check here for pre-7.1 versions to not override php 7.1+ behaviour.

This is what this PR proposes.

Testing Instructions

  • Code review.
  • Add to protostar/isis index.php
$date1 = new JDate('now'); usleep(1000); $date2 = new JDate('now');
JFactory::getApplication()->enqueueMessage($date1->format('Y-m-d H:i:s.u') . '<br />' . $date2->format('Y-m-d H:i:s.u'), 'notice');
  • In pre-php 7.1 and in php 7.1+ the two dates should continue to have different microseconds.
    image

Note: don't have php 7.1 to test, if anyone can test if in php 7.1 is all ok

Documentation Changes Required

None.

avatar andrepereiradasilva andrepereiradasilva - open - 4 Dec 2016
avatar andrepereiradasilva andrepereiradasilva - change - 4 Dec 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 4 Dec 2016
Category Libraries
avatar andrepereiradasilva andrepereiradasilva - change - 4 Dec 2016
Title
[PHP 7.1] Adapt JDate to reflect that php now sets DateTime('now') with microseconds.
[PHP 7.1] Adapt JDate to reflect that php now sets DateTime() with microseconds
avatar andrepereiradasilva andrepereiradasilva - change - 4 Dec 2016
Title
[PHP 7.1] Adapt JDate to reflect that php now sets DateTime('now') with microseconds.
[PHP 7.1] Adapt JDate to reflect that php now sets DateTime() with microseconds
avatar andrepereiradasilva andrepereiradasilva - edited - 4 Dec 2016
avatar ralain
ralain - comment - 4 Dec 2016

I have tested this item successfully on 1dc5545

Tested with and without patch on PHP 5.6.27, 7.0.13 and 7.1. 1100-1300 microsecond difference in all cases.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/13079.

avatar ralain ralain - test_item - 4 Dec 2016 - Tested successfully
avatar csthomas
csthomas - comment - 10 Dec 2016

I have tested this item successfully on 1dc5545

Code review + tests on hhvm 3.15.3, php7.0.8, php7.1


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/13079.

avatar csthomas csthomas - test_item - 10 Dec 2016 - Tested successfully
avatar jeckodevelopment jeckodevelopment - change - 11 Dec 2016
Status Pending Ready to Commit
avatar jeckodevelopment
jeckodevelopment - comment - 11 Dec 2016

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/13079.

avatar jeckodevelopment jeckodevelopment - change - 11 Dec 2016
Milestone Added:
avatar rdeutz rdeutz - reference | 42dafa2 - 11 Dec 16
avatar rdeutz rdeutz - merge - 11 Dec 2016
avatar rdeutz rdeutz - close - 11 Dec 2016
avatar rdeutz rdeutz - change - 11 Dec 2016
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2016-12-11 20:27:25
Closed_By rdeutz
Labels Added: ?
avatar rdeutz rdeutz - close - 11 Dec 2016
avatar rdeutz rdeutz - merge - 11 Dec 2016
avatar andrepereiradasilva andrepereiradasilva - head_ref_deleted - 11 Dec 2016
avatar cpfeifer cpfeifer - reference | fb3e6ba - 22 Dec 16

Add a Comment

Login with GitHub to post a comment