Problem/Motivation

The constant \DateTime::RFC3339 was removed in PHP 7.2 and should be replaced with \DateTimeInterface::RFC3339. Using the interface for constants is more future proof than assuming it will always be there on a class that implements the interface.

Drupal 9+ requires PHP 7.3+ as per https://www.drupal.org/docs/system-requirements/php-requirements

Steps to reproduce

Proposed resolution

Find/replace \DateTime::RFC3339 with \DateTimeInterface::RFC3339

Remaining tasks

MR
Review
Commit

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3222903

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

kim.pepper created an issue. See original summary.

dhirendra.mishra’s picture

Assigned: Unassigned » dhirendra.mishra

I am working on this

dhirendra.mishra’s picture

Assigned: dhirendra.mishra » Unassigned
Status: Active » Needs review
StatusFileSize
new44.95 KB

Please find my patch below..

Status: Needs review » Needs work

The last submitted patch, 3: 3222903-3.patch, failed testing. View results

kim.pepper’s picture

Status: Needs work » Needs review
StatusFileSize
new45 KB
new1.79 KB

@dhirendra.mishra a couple of instances of \DateTime::RFC3339 were replaced with nothing. Fixing here.

dpi’s picture

Bit out of scope, but many of the lines in the patch like
(new \DateTime())->setTimestamp($this->entity->getChangedTime())->setTimezone(new \DateTimeZone('UTC'))->format(\DateTimeInterface::RFC3339) lines can be updated to:
(new \DateTime('@' . $this->entity->getChangedTime())->format(\DateTimeInterface::RFC3339),
for readability. Since +0000 (UTC) is implied when using a timestamp directly:

php > echo (new \DateTime('@123456789'))->getTimeZone()->getName();
+00:00

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

john cook’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

The patch in #5 no longer applied cleanly, and I think there's one extra occurrence of DateTime::RFC3339 that needs to be changed.

@dpi, the default timezone cannot be relied on being UTC as it can be changed at the system level in php.ini, so we have to make sure that it is set correctly. See https://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone

dpi’s picture

@John Cook

When using the @ notation with the datetime constructor it will always interpret as a time stamp. A time stamp is always UTC. It doesn’t matter what the default time zone is.

Check an example at https://3v4l.org/OSXkV

echo (new \DateTime('9am'))->format('r') . "\n";
date_default_timezone_set('Australia/Sydney');
echo (new \DateTime('9am'))->format('r') . "\n";
echo (new \DateTime('@123456789'))->format('r') . "\n";
Tue, 12 Apr 2022 09:00:00 +0200
Wed, 13 Apr 2022 09:00:00 +1000
Thu, 29 Nov 1973 21:33:09 +0000
yogeshmpawar’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new45.94 KB
new13.39 KB

Updated patch with reroll diff

asha nair’s picture

Patch #10 could not apply. Tested on Drupal 9.3 and PHP 8.1. Got some errors and warnings.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

jhuhta’s picture

StatusFileSize
new45.94 KB
new1.49 KB

#10 worked ok on 9.5 already. I re-rolled it once more just to make it apply more cleanly against 9.5.x.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Category: Bug report » Task
Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative

This issue is being reviewed by the kind folks in Slack, #need-reveiw-queue. We are working to keep the size of Needs Review queue [2700+ issues] to around 200, following Review a patch or merge require as a guide.

D10 version needed
At this time we would need a D10.1.x patch or MR for this issue.

Since the aggregator module was removed in D10.

Also this may be more of a task vs a bug. If anyone disagrees feel free to change back but may need a special test or check for this? As it currently doesn't seem to break anything.

sahil rohilla01’s picture

Status: Needs work » Needs review
StatusFileSize
new40.91 KB

Patch updated against Drupal 10.1.x.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Took a while but the aggregator and hal modules were removed and BcTimestampNormalizerUnixTestTrait was deprecated.

Rest of the changes are included in the reroll.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 16: 3222903-16.patch, failed testing. View results

smustgrave’s picture

Status: Needs work » Reviewed & tested by the community

was a random failure before.

alexpott’s picture

Status: Reviewed & tested by the community » Needs review

This change feels a bit like change for change's sake. The issue summary needs to outline why we should do this. As per https://www.php.net/manual/en/class.datetime.php and https://3v4l.org/m7I6c the constant is still available on \DateTime - it's inherited from \DateTimeInterface.

What is the actual benefit of making this change?

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update

Per #20

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

quietone’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Novice

Answering the question in #20 is not suitable for a first time contributor to Drupal, so removing tag.

Since the MR doesn't need work right now, I am setting the status to what alexpott did.

@kim.pepper, your thoughts?

kim.pepper’s picture

IMO using the interface for constants is more future proof than assuming it will always be there on a class that implements the interface.

dcam’s picture

Status: Needs review » Needs work
Issue tags: +Needs merge request

Assuming that the answer given in #25 is accepted, then a merge request needs to be created. And it was requested that the justification for the change be added to the issue summary, so I'm leaving that tag.

quietone’s picture

Issue summary: View changes
Issue tags: -Needs issue summary update

Updated the issue summary

meeni_dhobale made their first commit to this issue’s fork.