Needs work
Project:
Drupal core
Version:
main
Component:
base system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
29 Mar 2020 at 04:09 UTC
Updated:
10 Jan 2023 at 11:51 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #3
nitesh624Comment #4
nitesh624Comment #5
nitesh624Comment #6
jungleThanks for working on this. Tests did not pass.
Comment #7
nitesh624Comment #8
nitesh624Comment #9
nitesh624Comment #10
nitesh624Comment #11
jungleComment #12
sanjayk commentedComment #13
sanjayk commentedReroll the patch
Comment #14
sanjayk commentedComment #15
hardik_patel_12 commentedThanks for working on this.
It's not just replacing \Drupal::time() with \Drupal::service('datetime.time') , but
It's to replace \Drupal::time() and \Drupal::service('datetime.time') with IoC injection where possible.
Kindly see the Parent issue for more info.
Comment #16
junglePer the parent issue, rescoping this to do it for non-test code.
So i have to set this back to NW, sorry!
Comment #17
clayfreemanIf
\Drupal::time()is not being removed, then why replace it with\Drupal::service('datetime.time')? Aren't these two expressions functionally equivalent?I'd assume that the issue is referring to adding the service via dependency injection where possible.
Comment #18
jungle@clayfreeman, please ignore the patch/what have done here. The patch #13 is meaningless ATM to me, I do not think @sanjayk understood the scope here, partially, it's my bad, the issue summary is not very clear, sorry! See a fixed sibling issue for what we have done for simliar ones, for instance: #3123210: Replace non-test usages of \Drupal::theme() with IoC injection or visit the parent issue for more if you are interested in.
Comment #19
vsujeetkumar commented@jungle According to me I have found only two places where I have done with the changes(Service via dependency injection), Please have a look and advise.
Comment #20
jungleNeeds fixing the tests.
Comment #21
vsujeetkumar commentedFixed the test, Please review.
Comment #22
hardik_patel_12 commentedAdding changed record and deprecation error message.
Comment #25
clayfreemanPlease note that
Drupal\Core\Queue\DatabaseQueueandDrupal\Core\Queue\MemoryQueueare currently usingtime(), but will be switched to\Drupal::time()after #3116478: Add a way to silently keep an item locked when processing a queue via cron is committed.The reason that we cannot use dependency injection right away is explained in #54.
Comment #26
clayfreemanComment #27
clayfreemanThe related issue in my last comment has been committed (see 0f10d21).
The scope of this issue will need to be adjusted accordingly to accommodate the changes therein.
Comment #30
guilhermevp commentedRe-rolled patch, updated summary.
Comment #32
clayfreemanComment #33
clayfreemanMR !910 simply adds IoC injection to all non-static, non-test references to
\Drupal::time()without consideration for whether it makes sense or not; I figure code review can be used to determine where we consider this change to actually be useful.Two areas worth highlighting:
_batch_queue($batch_set)In order to use IoC for the queue subsystem, we're going to have to solidify some potentially-shoddy API surrounding the queue subsystem's usage in the Batch API. I went ahead and made this change, but I fully expect that we'll either want to improve the Batch API's invocation of the queue subsystem, or ignore this change for now.
\Drupal\update\ProjectSecurityRequirementUsing IoC for this class felt a bit silly while I was implementing it, but I went ahead with it anyway for completeness. I figure this will be another area that will require a bit of discussion to line out.
Tagging with "Needs framework manager review" since it doesn't seem practical to set the component for each subsystem. Affected subsystems (as best as I can tell):
Comment #37
smustgrave commentedHiding the patches as this appears to be worked on in merge requests.
Can we please get the MR updated to point to 10.1.x
Comment #38
andypostit needs new MR or patch for 10.1.x
@clayfreeman please change MR branch if it's doable
Comment #39
rpayanmComment #40
smustgrave commentedCommit check failures
The last patch doesn't pass commit checks, could you make sure to run
./core/scripts/dev/commit-code-check.shbefore uploading a patch to make sure there are no issues with code formatting. see https://www.drupal.org/docs/develop/development-tools/running-core-devel...@rpayanm please check your patches before uploading..
Comment #41
rpayanmComment #42
smustgrave commentedSeems there were some errors
Comment #44
spokjeAdded new 10.1.x MR, the old one had no comments/threads, so no need to c/p them.
Comment #46
spokjeunsure if this actually needs a framework manager review.
Comment #47
andypostPushed one commit to fix own feedback
Changed messages to 10.1.0, added types and cleaned up
andypost authored 4 minutes ago
- message is for 10.1.x (formalized)
- properties should be typed to interface
- static method also needs injection
- testing could mock less
- use interfaces in mocks
also fixed CR
Comment #48
spokjeThanks @andypost, got a bit too sloppy in my haste there.
I've already tried removing the always-NULL parameter
Connection $connection = NULLfrom\Drupal\Core\Queue\Memory::construct, but that didn't end well: https://www.drupal.org/pift-ci-job/2536193By the looks of the current TestBot run, we'll end up with the same result.
Comment #49
andypostoh, missed that, thanks for pointer!
Comment #50
andypostI'm thinking to file new blocker bug - properly pass arguments to queue constructor in _batch_queue
Comment #51
spokjeMakes sense to me, at least far more sense than keeping an always-NULL parameter in the middle of a constructor...
Comment #52
andypostFiled #3325158: Properly instantiate a queue in _batch_queue()
Comment #53
andypostIt's green after random failure, just not sure about
form.incchangesComment #54
andypostProbably better re-purpose #3325158 as follow-up for 11.0.x to remove the bridge code
Comment #55
smustgrave commentedReviewing the MR looks like the deprecation is correct. The MR will have to be rebased though.
Should this be postponed until framework manager reviews.
Comment #56
spokjeComment #58
smustgrave commented#57 appears to be a rebase click.
Reviewing the MR I see all the instances have been addressed.
When I checked locally SqlContentEntityStorageSchema::getTemporaryTableMappingPrefix() I see one more instance I think should be replaced.
Comment #59
andypostThis method is static so it can't use DI for service
Maybe it could use follow-up to add argument to inject service but better not
Comment #60
andypostAdded fix for #58 https://git.drupalcode.org/project/drupal/-/merge_requests/3062/diffs?co...
Comment #61
smustgrave commentedConfirmed the point in #58 is addressed. That was my only note. Good to mark this one.
Comment #62
alexpottI think we can add a deprecation to allow us to remove the \Drupal::time() from
\Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::getTemporaryTableMappingPrefixComment #63
spokjeComment #64
alexpottAdded some review comments to the MR.
Comment #65
spokjeComment #66
spokjeThanks @alexpott, left one thread open since PHPCS didn't like it
Comment #67
spokjeComment #68
spokjeThanks @mondrake for the (per usual) excellent threads in the MR. Answered them inline over there.
Comment #69
mondrakeAdded a comment to the MR.
Comment #70
spokjeThanks @mondrake, added
readonlyeverywhere.Comment #71
mondrakeOne significant point in the MR, then, alas, I think we need deprecation tests.
Comment #72
spokjeI'm gonna need some help with this test failure:
No clue why calling the constructor of
SqlContentEntityStoragecauses this?Comment #73
smustgrave commentedWas able to fix locally by adding
Also had to update the deprecation message expected.
Didn't push the changes so I can stay in the reviewer side.
Comment #74
spokjeTHanks @smustgrave, that was indeed the missing piece of the puzzle.
Comment #75
larowlanLeft some comments, removing the tag for now, but will keep an eye on the issue/MR comments
Comment #76
spokjeThanks @larowlan for the review.
Back to NW for the open threads in the MR.
I'm going to let somebody else step in, because I've ran out of time/steam/joy working on this one.