Problem/Motivation
A time service was added to 8.3.x in #2717207: Add a time service to provide consistent interaction with time()/microtime() and superglobals.
Core code should be updated to remove deprecated uses of REQUEST_TIME and time() and others.
For more informations, see the change record.
This issue deals specifically with replace those calls in plugins and classes with direct container access.
The plugins and classes with direct container access that were identified to have those calls are:
- \Drupal\comment\CommentForm
- \Drupal\content_translation\Controller\ContentTranslationController
- \Drupal\content_translation\ContentTranslationHandler
- \Drupal\locale\Form\TranslationStatusForm
- \Drupal\migrate_drupal_ui\Form\ReviewForm
- \Drupal\system\DateFormatListBuilder
- \Drupal\system\Form\DateFormatDeleteForm
- \Drupal\system\Form\DateFormatEditForm
- \Drupal\toolbar\Controller\ToolbarController
- \Drupal\user\Controller\UserController
Proposed resolution
- Remove deprecated uses of REQUEST_TIME and time() and others.
- When this issue is successful, there should be no suppressions left in core/phpstan-baseline.neon for the above mentioned classes with the message Call to deprecated constant REQUEST_TIME: Deprecated in drupal:8.3.0 and is removed from drupal:11.0.0. Use \Drupal::time()->getRequestTime();
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|
Issue fork drupal-3112298
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:
- 3112298-replace-requesttime-in
changes, plain diff MR !2607
Comments
Comment #2
mpdonadioOK, took the patch from 2902895-43.patch
- Isolated just the OO code (well, I tried); this includes classes w/ and w/o access to the container as a starting point
At this point will start going through `git diff --name-only 8.9.x` to isolate by path/namespace revert changes to classes that def don't have container access
Comment #3
mpdonadioPostponing on #3112295: Replace REQUEST_TIME in rest of OO code (except for tests) so there is better starting point. Also thinking that this may really need to two issues to wrangle impact
- container access b/c inheritance
- container access b/c DI
Comment #4
mpdonadioComment #5
mpdonadioSmaller starting point.
Comment #6
mpdonadioComment #7
mpdonadioYeah, I know it is postponed...
These don't have create/constructors yet:
core/modules/toolbar/src/Controller/ToolbarController.php
core/modules/history/src/Plugin/views/filter/HistoryUserTimestamp.php
core/modules/aggregator/src/FeedStorage.php
Comment #8
mpdonadioLet the fails fly!
Comment #13
mpdonadioCommit credits.
Comment #15
mpdonadioFixed the new constructs/creates and added a update hook to force rebuild the container.
Comment #16
daffie commentedAll the changes in this patch look good. Just one remark:
Why is this change necessary for this patch?
Comment #17
ravi.shankar commentedI have added a patch but not sure if it is enough or not.
Here I have removed the method system_update_8902() because I think it doesn't do anything.
Here again, we need to review the new patch @daffie.
Comment #18
daffie commentedAll the code changes look good.
For me it is RTBC.
Comment #19
longwaveDo we need to trigger deprecation notices where constructor arguments have been added?
Comment #20
alexpottThis needs to be done in D9 first. The patch doesn't apply there.
Comment #21
alexpottAnd the answer to #19 is yes which makes this issue 9.1.x really. Especially as REQUEST_TIME is hanging about till D10.
Comment #22
ravi.shankar commentedHere I have added patches for Drupal 8.9.x and Drupal 9.0.x
I have added drupal's version in patch name.
Comment #23
daffie commented@ravi.shankar: Could you post an interdiff.txt file for the changes you have made (for the 9.0 branch as 8.9 branch will never be committed). Thank you for working on this issue.
Comment #24
kristen polSee possibly related issues noted here:
https://www.drupal.org/project/drupal/issues/3112283#comment-13605217
Comment #28
andypostthis kind of changes require deprecation error about passing null and to be cleared in next major
Comment #29
andypostI think part of this changes could be reverted to use request time from current request
should use injection deprecation to explain that service will be required for injection
Comment #30
mondrakeComment #32
immaculatexavier commentedRerolled patch against 9.5
Comment #33
immaculatexavier commentedRerolled patch against 9.5
Comment #34
ranjith_kumar_k_u commentedComment #35
mondrakeI'd suggest to target D10 first since this impacts the PHPStan baseline, and then backport.
Comment #36
ankithashettyUploading a rerolled patch to 10.0.x version, thanks!
Comment #37
daffie commentedThe testbot is not happy. See: https://www.drupal.org/pift-ci-job/2393088
Comment #38
smustgrave commentedComment #39
smustgrave commentedComment #40
smustgrave commentedComment #41
spokjeComment #42
spokjeConfirmed with @catch what branch this should be against: https://drupal.slack.com/archives/C014CT1CN1M/p1659679942164229
10.1.xit is.Comment #44
spokjeComment #45
spokjeComment #46
spokjeComment #47
spokjeComment #48
mondrakeHow painful, it’s way more deprecation tests than actual changes… some comments in MR
Comment #49
spokjeComment #50
spokjeComment #51
mondrakesome digging in the MR
Comment #53
spokjeComment #54
mondrakeOne consideration on whether we can update the property definition with
readonlyand remove the @var tag - that repeats several times. I see there are alredy some cases where this was committed but would not like to get into coding standards discussions.Three points I think need more work.
Comment #56
spokjeComment #57
spokjeComment #58
spokje- Updated IS
- Updated CR
- Addressed threads from review by @mondrake (thanks!)
- Rebased MR on
11.xComment #59
spokjeComment #60
spokjeComment #61
mondrakeAll good for me, thanks. There are also deprecation tests for missing constructor arguments, which I think are no longer required, but it's a plus.
Comment #62
quietone commentedI'm triaging RTBC issues. I read the IS and the comments. I didn't find any unanswered questions.
I skimmed the patch and found quite a few out of scope formatting changes which I think these are limited to changing the _construct methods to be multi line. And this change is inconsistent. I then looked at the size of the change and determined it is 65K and,
29 files + 681 − 116lines. That is well above the recommended patch size of 10-40K. This likely needs to be split into two issues.I am setting to NW and assigning to myself to remove the out of scope changes to see how much that helps. I will get back to this after a short break.
Oh, I also updated credit.
Comment #63
quietone commentedThis needed a rebase which I did. I then had to restore a .js file, core/modules/ckeditor5/js/build/drupalMedia.js from 11.x, which I somehow got wrong in the rebase.
Removing the out of scope changes is not sufficient. I am going to look at splitting this into two issues while tests run for the rebase.
Comment #64
quietone commentedIt is still rather large but I hope this is a bit easier to review now without the plugins. I have updated the title and the CR.
Comment #65
smustgrave commentedDo we need a followup for the plugins?
Also would it be worth it to create a trait for time? If not changes in scope seem good.
Comment #66
alexpottDiscussed all the new tests added here with @catch. There's no need to add the constructor tests here. They don't really test anything.
I've updated the MR to deprecate for 10.3.0 and to use autowiring instead of create where this issue was adding a create.
Comment #67
alexpottCommitted a9b4000 and pushed to 11.x. Thanks!
Comment #68
alexpottAfter discussion with @catch I decided to delete the change record because it's not adding anything beyond the deprecation message and the constructor documentation.