The CreatedItem field type is using REQUEST_TIME. It should use the time service instead.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim created an issue. See original summary.

joachim’s picture

Status: Fixed » Active

Oops. Cloning cloned the status too!

joachim’s picture

We should probably wait to see why patch at #2902896: Replace REQUEST_TIME with time service in ChangedItem is failing tests before working on this.

BramDriesen’s picture

Status: Active » Needs review
FileSize
697 bytes

Replaced REQUEST_TIME with \Drupal::time()->getRequestTime(). Don't think it's really related to the failed issue linked. So let's queue it for testing.

Status: Needs review » Needs work

The last submitted patch, 4: replace_request_time-2903549-4.patch, failed testing. View results

lmarkov’s picture

Counted from today, Me (@lmarkov), @valthebald and @lachezar.valchev would be taking up the task.

joachim’s picture

+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/CreatedItem.php
@@ -22,7 +22,7 @@ class CreatedItem extends TimestampItem {
+    $this->setValue(['value' => \Drupal::time()->getRequestTime()], $notify);

This is a plugin, so it should be able to have the service injected.

valthebald’s picture

Version: 8.4.x-dev » 8.5.x-dev
Status: Needs work » Needs review

Injecting time service into CreatedItem plugin

valthebald’s picture

Status: Needs review » Needs work

The last submitted patch, 9: 2903549-8.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

valthebald’s picture

Issue tags: -Novice

FieldType plugins are directly instantiated by TypedDataManager, which does not care about DI (see #2053415: Allow typed data plugins to receive injected dependencies). I have submitted a patch there, that would unblock this issue.

valthebald’s picture

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

alexpott’s picture

Thank you for your work on cleaning up Drupal core's use of deprecated APIs!

In order to deprecate APIs in a maintainable way, converting deprecated uses should be replaced across all of core for a given kind of usage, rather than in individual modules or files. Such issues should also always be part of an overall plan to ensure all usages are removed, rather than standalone patches.

For background information on why we usually will not commit cleanups that aren't scoped in that way, see the core issue scope guidelines. See the core deprecation policy for more information on how we handle deprecations.

Contributing to the overall plan above will help ensure that your cleanups for core's deprecated code improve core in a maintainable and minimally disruptive way.

We need come up with a plan that's not class by class, file by file, module by module.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

amateescu’s picture

Status: Needs work » Closed (duplicate)
Related issues: +#2809515: Simulate time passage instead of actually waiting in EntityTestMulChanged

This is being done for both CreatedItem and ChangedItem in #2809515: Simulate time passage instead of actually waiting in EntityTestMulChanged, so I'm going to close this one as a duplicate and credit everyone who worked on this patch.