Problem/Motivation
The system.prepare_modules_entity_uninstall route defines the following _title_callback value:
\Drupal\system\Form\PrepareModulesEntityUninstallForm::formTitle
This was introduced when the route itself was first introduced in #2688945: Allow removing a module's content entities prior to module uninstallation.
However, it never actually existed.
Thus, an error is thrown when attempting to retrieve the title via the title_resolver service manually. I can only suspect that this error is caught in the system when actually visiting the page since no one has actually caught this.
Proposed resolution
Add the _title_callback for this route and test coverage it can be called with the title resolver service
Remaining tasks
- Review and commit
User interface changes
None
API changes
None
Data model changes
None
| Comment | File | Size | Author |
|---|
Issue fork drupal-2862702
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:
Comments
Comment #2
markhalliwellComment #3
markhalliwellComment #4
markhalliwellComment #5
markhalliwellComment #6
arifkhn46 commentedI am facing the same issue, before seeing this ticket I created following ticket:
https://www.drupal.org/node/2876872
Comment #7
arifkhn46 commentedI applied the patch its working fine.
Comment #8
amateescu commentedLooks good to me as well :)
Comment #9
alexpottFeels like we're missing test coverage somewhere then. Why isn't \Drupal\system\Tests\Module\PrepareUninstallTest::testUninstall() broken? It is because of the theme we're testing in? And how do the title's appear correct?
I guess it because of
in \Drupal\Core\Form\ConfirmFormBase::buildForm()
Comment #10
heddnI got this from breadcrumbs. Do we not print breadcrumbs on this page by default?
Comment #11
alexpott@heddn breadcrumbs are on in the Seven theme.
Comment #14
hamrant commentedPatch #3 fixed my issue, thanks @markcarver
Comment #17
peter feddo commentedPatch #3 resolved my issue
The website encountered an unexpected error. Please try again later.</br></br><em class="placeholder">InvalidArgumentException</em>: The controller for URI "" is not callable.This error would occur when attempting to uninstall a module's entities. After applying the patch and perform a cache rebuild the error is resolved on Drupal 8.7.3 PHP 7.3.5.
Comment #18
alexpottI think we should make this exist so that the form title matches the actual form title. So something like:
And we're missing test coverage :(
Comment #20
liquidcms commentedthis not been fixed yet? I have 8.7.7 and still seeing this.
Comment #21
tobiberlin+1 for fixing this ;-)
Comment #22
mxr576this is 3 years old issue about restoring a form title :)
I do agree with #9 and #18 and I experienced on my own skin that confirm forms make things unpredictable, but the underlying core issue should be resolved in a followup task I believe. (Maybe there won't be a BC solution for confirm forms vs. page titles.)
Comment #23
mxr576How this could practically happen if there is a proper access checking on the route?
Comment #25
stefan.kornIn my case I could drag an issue with this down to Easy Breadcrumb module, see #3164758: Easy breadcrumb breaks the form for removing module content entities data before uninstallation.
But it still does not make sense to me that core defines a _title_callback that is not existing.
It seems that core is not validating (or even using) this _title_callback in its implementation of the PrepareModulesUninstallForm, therefore no error is raised. Easy Breadcrumb is using TitleResolver service and that breaks the form by raising an exception.
What would be the downside or risk of fixing this in core either by implementing the _title_callback in PrepareModulesEntityUninstallForm or using static title like proposed by @markcarver?
Comment #26
ankit agrawal commentedThank you stefan, I also faced the same issue with the easy breadcrumn module and the patch of easy breadcrumb module worked for me. I would definitely be good to have core defines a _title callback that is not existing.
Comment #28
nwom commentedThank you @Ankit Agrawal. My problem was related to Easy Breadcrumbs as well. Updating to the latest dev version fixed it for me.
Comment #29
mohit_aghera commented- Added the method
formTitleas mentioned in ##1- Added test case to ensure that title exists and as per the method's output
- Test to ensure that entity deletion process works as expected.
Comment #31
joseph.olstadPatch #29 works as expected on Drupal 8.9.14 so assuming it also applies cleanly to 9.0.x , 9.1.x as well as 8.9.x
Thanks so much for your work on this!
Great work everyone above!
Comment #32
joseph.olstadComment #33
catchCould we get a test-only patch to show it failing?
If I'm reading the issue correctly, when the page is actually visited, this title callback doesn't get called, because ConfirmForm takes over. Therefore the title callback is only getting called in edge cases like breadcrumbs - but if so I don't think the test coverage is actually exercising this.
Also needs an issue summary update.
Additionally, if this is really necessary, it needs a comment as to how we're running this code when the route ought to be a 404.
Comment #37
hswong3i commentedPR created from #29
Comment #38
perfectcu.be commentedThanks for the heads up @joseph.olstad and @mohit_aghera for the original patch! Moving to D9 is easier when you can uninstall modules that are getting in the way of a clean upgrade.
#29 worked for me on 8.9.20 with some fuzz:
Attached is a rerolled version (2862702-38.patch) of #29 that applies cleanly (no fuzz) on 8.9.20 and reroll_diff: reroll_diff-29-38.txt.
NOTE: the reroll name is based on the comment where it was originally posted (#29), not the file suffix on the original patch (-28_0)
Comment #39
mxr576Drupal 8 is EOL-ed, if this patch needs a reroll then the reroll should be for Drupal 9.4.x otherwise it never gets fixed in core :S
Comment #40
mxr576Hiding D8 patches, the MR above which needs review.
Comment #43
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.
Left a few comments in the MR.
Also needs issue summary update per #33
Comment #47
larowlan@dscl and I worked on this at DrupalSouth
it is ready for review now
Comment #48
mstrelan commentedLeft some comments on the MR
Comment #49
alexpottFWIW the test passes without the fix. That's because we're not actually calling any code results in the title callback being used.
Maybe we should go back to #3. Does this page actually need a title callback - hmmm maybe we do as I guess Easy Breadcrumb is using it.
Anyway to test this we need to use the title resolver service on this route. Visiting the page won't trigger the code because of the #title in the form.
Comment #50
larowlanAddressed feedback
Comment #51
smustgrave commentedOnly moving to NW for the issue summary update
Is that still true?
Comment #52
larowlanComment #53
larowlanComment #54
smustgrave commentedThanks! Summary now appears to match the MR.
Comment #57
catchCommitted/pushed to 11.x and cherry-picked to 10.3.x, thanks!