Problem/Motivation
NodeRevisionDeleteForm::submitForm runs a check to decide whether to redirect the user to the node page(if not remaining revisions) or the revision history page. This check, however, is a hardwired SQL query which not only fails with alternate storage engines but also if the route access check is changed.
Proposed resolution
Replace SQL query with a node storage revisions count.
Use the route access check, it just makes sense not to redirect to a page which ends up access denied.
Note that at least one test executes the changed code, core/modules/file/tests/src/Functional/FileFieldRevisionTest.php
Remaining tasks
Review
User interface changes
N/A
API changes
N/A
Data model changes
N/A
Release notes snippet
N/A
Problem/Motivation
N/A
Comments
Comment #1
chx commentedMy first attempt was path validator which didnt work out but the patch contained the use command. Removed unused interfaces.
Comment #2
tim.plunkettI think we'll end up spinning off the individual fixes from #2471613: FormState:setRedirect() should check access to the route, consider this the first one.
Comment #5
chx commentedBot fail.
Comment #6
xjmGood find. The read part of that diff made me make a "yeaghhh" noise.
I get that the hardwired check should work the same on the default storage engine, but what about the bit where it doesn't work if route access is changed? That sounds like a bug we should be able to add test coverage for.
Comment #15
quietone commentedThis needs a reroll and it is suitable for a novice.
Comment #16
ankithashettyRerolled the patch in #1, thanks!
Comment #20
quietone commentedUpdating IS
Comment #21
quietone commentedRemoving Novice tag because writing the test is not a first time task.
Comment #23
smustgrave 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.
Moving to NW for the tests
Did not test or review yet.
Comment #24
xjmComment #25
jidrone commentedAfter a deeper review I think the condition mentioned on this issue was misunderstood, because the intension is to know if there are existing revisions and redirect the user accordingly, if existing revisions go to the revisions history page, if not go to the node page.
It is also true that is needed to check if the user has access to the revisions history page, so we can take this opportunity to fix both things:
I improved the patch to remove the database service as well, because it is not used anymore for this test.
I'm improving the issue description and title.
Comment #26
jidrone commentedI forgot to move it to NR.
Comment #27
smustgrave commentedShouldn't the old parameter be deprecated vs replaced? Could this cause existing sites to now break
Comment #28
jidrone commentedThe problem is only with this line, so I think the way to get the existing revisions to redirect the user can be just changed to use the nodeStorage:
$this->nodeStorage->revisionIds($this->revision)As I did in the patch.
Comment #29
smustgrave commentedRemoving tests as they appear to be added.
I think the old parameter should be deprecated. If someone is overriding this form it could break for them I believe.
Will need a simple deprecation test once that's added.
Comment #30
jidrone commentedYou are right, we need to deprecate the connection argument, I did so and also I started a draft change record.
Comment #31
smustgrave commentedThanks!
Will also need a simple test case checking for the deprecation.
Comment #32
jidrone commentedAdded deprecation test.
Comment #33
smustgrave commentedThanks for sticking with this. Think this is good for a committer to take a look now.
Comment #35
longwaveCommitted and pushed to 10.1.x, thanks!
Fixed up grammar in some comments on commit:
Comment #37
quietone commentedPublished the change record.