Problem/Motivation
After clicking 'continue' to install an obsolete module one gets:

Steps to reproduce
Create a test module with 'lifecycle: obsolete' and install it via the UI.
Proposed resolution
An obsolete module must not be installed. So the solution is to hide any obsolete modules from the UI. See #13 for more information. Obsolete modules will not be visible at the /admin/modules "Extend" page at all. However, in case an update to uninstall such a thing either wasn't properly released, or hasn't been run, obsolete modules are still visible at the "Uninstall" form (/admin/modules/uninstall), so if a site owner needs to manually remove such a module, they still can.
Remaining tasks
PatchTest- Review
User interface changes
Before:

After:

API changes
A new function isObsolete() added to /core/lib/Drupal/Core/Extension/Extension to validate if an extension is obsolete.
Release notes snippet
Extensionobjects now provide theisObsolete()function to check if an extension is marked obsolete.- Obsolete modules are no longer displayed on the "Extend" page (/admin/modules).
| Comment | File | Size | Author |
|---|---|---|---|
| #38 | interdiff_35-38.txt | 600 bytes | murilohp |
| #38 | 3258782-38.patch | 2.87 KB | murilohp |
| #35 | 3258782-35.patch | 2.86 KB | quietone |
| #35 | interdiff-22-25.txt | 745 bytes | quietone |
Comments
Comment #2
quietone commentedComment #3
spokjeAs far as I can tell this was a decision made on purpose:
Last lines from #3124762-124: Add 'lifecycle' key to .info.yml files:
From the IS:
There is already such a test, which expects the
ObsoleteExtensionExceptionbeing thrown here: https://git.drupalcode.org/project/drupal/-/blob/9.4.x/core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php#L143Comment #4
cilefen commentedSo that seems works as designed. But we could change our minds about that right here if this is known to be be significant to site owners. Or, we could could close or postpone this until we have more data.
Comment #5
spokjeFully agree with preventing enabling an obsolete extension through the UI, instead of a uncaught Exception.
Comment #6
quietone commentedApologies, I was not clear. I have updated the IS.
Comment #7
murilohp commentedHey, I think it's a good idea, instead of show a WSOD, it's better to display the error message. On this new patch, I tried to address this.
Comment #8
murilohp commentedComment #9
xjmThis is major because it causes a fatal in the user interface. The intent of the obsolete module API is to allow empty stubs that don't break the site owners site with a fatal on upgrade and then uninstall themselves. So if the API is also causing an uncaught exception, it's not fulfilling its intended purpose. :)
Comment #10
catchObsolete modules shouldn't be shown in the UI to be installed in the first place, if they are, then I think we should be fixing that instead.
Comment #11
quietone commentedFix the related issue link.
Comment #12
quietone commented@catch does that mean that the obsolete module should be shown in the module list but somehow not be installable? The same would apply to themes.
Comment #13
catch@quietone: obsolete modules should be completely hidden in the UI and impossible to install, so not in the module list at all. So you shouldn't ever get in a position where you're trying to install it.
Comment #14
catchI just applied the patch from #3261957: Properly deprecate migrate_drupal_multilingual for future removal and went to the extend page, and migrate_drupal_multilingual wasn't shown there - that appears to be correct, so I'm not sure how it's possible to get to that confirm form at all? Was the obsolete module a dependency of another module or something?
Comment #15
murilohp commentedHey @catch, I was able to reproduce the error using a recent version of D9.4(so I have #3261957 fixed), I created a new obsolete contrib module, using the following data on .info.yml file:
It is possible to hide the module on the extend page using hidden:true on .info file, but this key is not mandatory when a module is obsolete, I like the idea of removing obsoletes modules from the extend page. I created a new patch removing the obsoletes modules just from the UI, the modules will keep being discovered.
I'll keep this to needs works to see the testbot and check if it's the best solution to just hide it from the UI.
Thanks!
Comment #16
quietone commented@murilohp, thanks for the patch.
#14. migrate_drupal_multilingual has been marked hidden since 8.9.x and it is also dependent on migrate_drupal.
I think the class comment for ModulesListForm and ModuleListNonStableConfirm need to be updated to explain that obsolete modules are excluded.
And some suggestions for the comments.
This can be simpler.
"This function checks for 'lifecycle: obsolete' to determine if an extension is marked as obsolete."
Not needed.
'Remove obsolete modules' is sufficient here.
Comment #17
murilohp commentedThanks for the review @quietone!
I updated the class comment on both classes.
I also added a new test to validate if none obsolete modules are displayed on the page.
Thanks!
Comment #18
quietone commented@murilohp, yes, that is better, thanks.
This block doesn't read well to me. I'd rather it say 'all modules except obsolete', much easier to grasp the intention. What about something like this?
This should following the coding standard for @see,
Comment #19
quietone commentedI forgot one item.
Nice to add the test but there is no need to add the overhead of a new Functional test, the assertion and a comment can be added to testModuleListForm
Comment #20
murilohp commentedAddressing #18 and #19 here, thank you @quietone for the suggested message.
Comment #21
quietone commented@murilohp, almost there!
Not quite, still not following the Drupal coding standards for @see. Check the last paragraph of @see on the API documentation and comment standards page.
Comment #22
murilohp commentedComment #23
murilohp commentedMy bad @quietone, I removed the sentence after the class, now I think it's good.
Thanks!
Comment #24
murilohp commentedComment #25
quietone commentedThat looks good to me.
The issue summary needs an update to reflect what this issue is actually doing. I have already updated the title. This also should have a fail patch. Setting to NW.
Comment #26
quietone commentedComment #27
murilohp commentedComment #28
murilohp commentedHey, I updated the IS and here's a new test only patch! Moving back to NR.
Comment #30
murilohp commentedComment #31
dwwThis mostly looks great, thanks! I cleaned up the release note and a few other things in the summary. Looking at the patch in #23:
If we're re-wording this message already, seems a little weird to only mention name, description and requirements, especially given the context of a function that understands the obsolete status of a module. How about:
"... which includes the module name, description, dependencies and other information."
? We don't necessarily have to say "lifecycle" but the point is the .info.yml file defines a bunch of stuff, go see how that works...
Not worth NW over this, but does anyone wanna quick re-roll and I'll RTBC?
Comment #32
dwwStarted a draft CR for both this and #3265362: Do not display obsolete themes at admin/appearance.
Comment #33
dwwWhile obsolete modules are supposed to be uninstalled via an upgrade hook, and while I agree we should hide them from /admin/modules, it's a little too bad that they're also gone from /admin/modules/uninstall. E.g. with an obsolete contrib module enabled that doesn't provide the right upgrade path, or where I haven't run it yet, I see this on my status report with the patch applied:
The broken
%extensionsplaceholder needs a follow-up, if there's not already a bug report for that. But more to the point for this issue, there's no longer any way to do anything about this warning except use something outside of core like drush. It'd be great if the "uninstall these extensions" was a link to /admin/modules/uninstall and if all the obsolete stuff still appeared there, perhaps even at the top of the page in some high-lighted fashion.I don't want to derail this with scope creep, but it seems like if we're hiding these, we should really provide a way to recover directly with core alone. Seems like leaving them visible at the uninstall form is a good solution, but I'm open to other ideas.
Thanks/sorry!
-Derek
Comment #34
dwwAlso, if #3265362: Do not display obsolete themes at admin/appearance is major, seems like this should be, too. It's preventing a WSOD triggered via a relatively easy path through the UI...
Comment #35
quietone commentedRerolled after #3265362: Do not display obsolete themes at admin/appearance.
Comment #36
murilohp commentedThanks for the reroll @quietone, now the #32 is addressed, regarding #33, thanks @dww for the feedback.
I created a new issue for the
%extensionsbug, it would be nice to see your thoughts on #3266308: %extensions placeholder not extension names printed on the Status report warning about obsolete extensions , and I agree with you, we should allow the user to uninstall the modules using theadmin/modules/uninstallpage, in fact this is already happening.This would be nice, today the obsolete modules appears on the
admin/modules/uninstall, the patch just hide the modules at the list form, but the obsolete modules should appear high-lighted on uninstall, what do you think about having another issue to address this?Comment #37
daffie commentedAll the code changes look good.
I have tested on my local machine that the changed test will fail when the fix is removed.
For me it is RTBC.
Edit: In comment #28 there is a patch that tests the same thing.
Comment #38
murilohp commentedOoops my bad I thought #35 have addressed the suggestion of #31 on my previous comment, here's a new patch addressing it.
Just some more info here, regarding #33:
Actually the obsoletes modules still appears on
/admin/modules/uninstall, just to let things clear, I've done the following test:/admin/modulesand install the modulelifecycle: obsoleteandlifecycle_link: 'https://example.com/obsolete'/admin/modules/uninstalland module will be there, and you can uninstall it.Comment #39
dww#35 re-roll is great since core now has
Extension::isObsolete()so we don't need to re-add it here.Re: #36 Thanks for opening #3266308: %extensions placeholder not extension names printed on the Status report warning about obsolete extensions, following now. I agree that's better to fix in a separate issue for scope management.
Re: #37: Not so fast! 😉
Re: #38: Thanks for fixing #31. Thanks also for re-testing the uninstall form. I realized I had been switching branches and sites and my local wasn't in the state I thought it was when I converted something to be obsolete. I tried again just now, being more careful and intentional. I can confirm I had done it wrong when I wrote #33, and that #38 is true. Obsolete modules do still appear at /admin/modules/uninstall. 🎉 I was a little confused with myself, since it seemed like the code here wouldn't impact the uninstall form. Now it's all clear... a little PEBCAK goes a long way. 😉
One final concern: Is there now dead code in the handling of the admin/modules form to give a special warning to obsolete modules? E.g. the stuff that generates what you see inside the red box in the "before" screenshot in the summary? Shouldn't all that dead code now be removed? I need to look more closely at the surrounding code. I spun off #3266397: Highlight non-stable modules on the admin/modules/uninstall form as another separate issue to fully address #33. That's the perfect home for any code we remove from admin/modules to handle obsolete warnings...
Thanks everyone!
-Derek
Comment #40
dwwcore/modules/system/src/Form/ModulesListForm.php:
That's not dead, even though it was handling the obsolete case. Nothing else to remove. RTBC! Sorry for not checking before I posted earlier.
Thanks!
-Derek
p.s. #3266397: Highlight non-stable modules on the admin/modules/uninstall form means we want to share the above between both forms, so we can sort out how to refactor it over there.
Comment #41
benjifisherWe discussed this issue at #3266551: Drupal Usability Meeting 2022-03-04. That issue will have a link to the recording, and it already has a rough transcript.
There is not a lot to say. We agree with the solution in this issue: do not show obsolete modules on
/admin/modules.As I write that, I wonder about
/admin/appearance. Oh, #3265362: Do not display obsolete themes at admin/appearance is a sibling issue. I will add it as a related issue, too.For the record, the participants at the usability meeting were
benjifisher, rkoller, AaronMcHale, andregp, Antoniya, ckrina, guilherme-rabelo, guilherme-rabelo, kimberlly_amaral, victoria-marina, shaal, tmaiochi, worldlinemine
Comment #50
catchOne thing that's not mentioned here is the uninstall page. However, I think it's OK to still show obsolete modules on the uninstall page, since if you do get into a situation where one is enabled, you'd be able to uninstall it from the UI, otherwise you'd be stuck except for drush.
Committed/pushed to 10.0.x and cherry-picked to 9.4.x, thanks!
Comment #51
dwwThanks for committing this, @catch!
Not in the summary, but I mentioned uninstall page from #33 on, and we’ve got #3266397: Highlight non-stable modules on the admin/modules/uninstall form for improvements there...
Thanks again,
-Derek
Comment #52
dwwP.s. see also:
#3266308: %extensions placeholder not extension names printed on the Status report warning about obsolete extensions
#3266449: Add a link to the Status report warning about obsolete extensions so site owners can fix the problem