Problem/Motivation
The Brightcove module needs API access tokens, which expire every 5 minutes. Thereby it is using the KV expireable to invalidate these access tokens.
In a normal HTTP request, this is cool, but during a migration we ran into an issue, when the migration actually executes for longer than 5 minutes.
Along the long-running migration process, we REQUEST_TIME
used inside the KV expireable never changes, even the real world time moves on.
In short, REQUEST_TIME does not equal to the \Drupal::time()->getCurrentTime().
Proposed resolution
Use the actual time in \Drupal\Core\KeyValueStore\DatabaseStorageExpirable
. \Drupal\user\SharedTempStore
and \Drupal\user\PrivateTempStore
by leveraging the datetime.time
service and its ::getCurrentTime
method.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#49 | 2855457-49.patch | 23.39 KB | jungle |
| |||
#48 | interdiff-46-48.txt | 2.83 KB | jungle |
Comments
Comment #2
dawehnerComment #3
dawehnerComment #4
shadcn CreditAttribution: shadcn at Chapter Three commentedOK let's see what fails.
Comment #5
mpdonadioLooks good.
Nit, needs to have a comment on the line below it, something like "The injected Time service."
This is the only place in the patch where the time service is optional. The patch should be consistent; either do this on all of the constructors or non of them. Of the options, I think it should be mandatory. If it is mandatory, then the patch needs an empty post_update hook to make sure the container gets rebuilt (prob in system.module?).
Looks like missing a @param?
Comment #6
shadcn CreditAttribution: shadcn at Chapter Three commentedThanks @mpdonadio. I'll update the patch.
Comment #7
dawehnerIMHO ideally we would have some test coverage here. For example you could use an additional
sleep()
call here.Comment #8
shadcn CreditAttribution: shadcn at Chapter Three commentedOK let's test this one.
Comment #9
dawehnerI'm confused, I could not find a real test in your patch.
This is not needed as we will rebuild the container anyway when moving to 8.4.
Note: you can use
TimeInterface::class
Comment #10
mpdonadio@dawener, so this is a bug-report but we are only going to add it to 8.4.x and not cherry pick to 8.3.x? That is what I mentioned the post update hook. If that is the case, we should probably change this to a Task.
Comment #11
shadcn CreditAttribution: shadcn at Chapter Three commentedWhat kind of tests do we need here?
Do
\Drupal\KernelTests\Core\KeyValueStore\DatabaseStorageExpirableTest
,\Drupal\Tests\user\Unit\SharedTempStoreTest
and\Drupal\Tests\user\Unit\PrivateTempStoreTest
cover these?Comment #12
dawehnerPersonally I'd be totally fine with that.
Comment #15
borisson_#11, it looks like all of them are testing this, I think this can be a new test-method in the kernel test.
Setting to needs work to add the tests.
@dawehner, if you have a better idea where the test should go, I would be helpful to provide more direction.
Comment #16
dawehnerFor me at least
\Drupal\KernelTests\Core\KeyValueStore\DatabaseStorageExpirableTest
sounds like a perfectly appropriate place.Comment #18
nginex CreditAttribution: nginex at Drupal Ukraine Community commentedComment #19
mpdonadioThis is a messy reroll b/c the array syntax change and #2935617: Move User module's temp stores to core.
Comment #20
mpdonadioHere is a reroll, more of the re-do variety.
Comment #22
mpdonadioComment #25
mrweiner CreditAttribution: mrweiner commentedPatch from #22 seems to still apply cleanly on 8.8.x-dev
Comment #27
moltam CreditAttribution: moltam at EPAM Systems commentedI updated the patch and made it compatible with version 8.8.x.
Also fixed the issues that I've found.
Comment #28
thallesI fix some issues finded by Drupal phpcs in this patch.
Comment #30
jungleFix Drupal\Tests\ComposerIntegrationTest and 9 coding standards messages
Comment #37
smustgrave CreditAttribution: smustgrave at Mobomo commentedThis issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.
Tagging for framework managers thoughts as this feels like something that could be disruptive for other sites.
Tagging for IS update for remaining tasks as this will have to be rescoped for D10
Tagging for change record update on if this moves forward it will need one for sure.
Comment #38
kkalashnikov CreditAttribution: kkalashnikov as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedPatch for Drupal version 10.1.x
Comment #39
Rishabh Vishwakarma CreditAttribution: Rishabh Vishwakarma at OpenSense Labs for DrupalFit commentedResolved PHPCS errors from #38
Comment #40
smustgrave CreditAttribution: smustgrave at Mobomo commentedStill needs issue summary update and change record
Comment #41
sahil.goyal CreditAttribution: sahil.goyal as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedTrying to resolve CCF corresponding to #39, upload a patch and interdiff with it.
Comment #42
mukesh88 CreditAttribution: mukesh88 at Srijan | A Material+ Company for Drupal India Association commentedFixed the custom commands on #41
upload a patch and interdiff with it.
Comment #43
jungleI am on this. CR added. Constructor property promotion will be used.
Comment #44
jungleComment #45
jungleAdded "in short, REQUEST_TIME does not equal to \Drupal::time()->getCurrentTime()." to the IS.
Comment #46
jungleComment #48
jungleComment #49
jungleOops. 2855457-48.patch is empty.
Comment #50
smustgrave CreditAttribution: smustgrave at Mobomo commentedRemoved credit for #38, #39, #41, and #42 as it's expected the patch to be tested locally before uploading.
Reviewing #49
Changes look good but think we will need a simple kernel test (maybe Unit) for checking the deprecation of each of the constructors when a null time parameter is passed.
Going to post to the slack channel also for the framework feedback.
Comment #51
longwaveThe problem here is that we will have to remove the default for $table in Drupal 11 as you can't have mandatory arguments following optional ones. Is it worth doing the argument dance here so $time comes before $table?