Problem/Motivation
If module A defines
package = User interface
and module B defines
package = User Interface
then you will see two packages on the Modules page.

Proposed resolution
Force the package name to be lowercased except its first letter that is uppercased.
Remaining tasks
| Task | Novice task? | Contributor instructions | Complete? |
|---|---|---|---|
| Create a patch | Instructions | Done | |
| Update the issue summary | Instructions | Done | |
| Update the issue summary noting if allowed during the beta | Instructions | Done | |
| Manually test the patch | Novice | Instructions | Done |
| Embed before and after screenshots in the issue summary | Novice | Instructions | Done |
| Review patch to ensure that it fixes the issue, stays within scope, is properly documented, and follows coding standards | Instructions | Done |
User interface changes
Before

After

API changes
None.
Data model changes
None.
Beta phase evaluation
| Issue category | Bug because this funtionality does not mean the causal expectations of developers that are seeking to properly package/categorize their modules within having to care about case |
|---|---|
| Issue priority | Normal because these changes do not block Drupal's release |
| Unfrozen changes | Adjusts module package handling and fixes tests |
| Prioritized changes | The main goal of this issue is usability. We seek to improve the usability of the Extend page by properly grouping modules together even if their package names are different only in the way the works are cased. |
| Disruption | We are removing the ability to have lower cased (improper nouns) in package names. We are not impacting module's machine names or modules names at all. |
| Comment | File | Size | Author |
|---|---|---|---|
| #85 | Screenshot 2023-09-14 at 10.59.22 AM.png | 93.78 KB | smustgrave |
| #85 | Screenshot 2023-09-14 at 10.59.03 AM.png | 99.35 KB | smustgrave |
| #77 | 730374-76.patch | 2.1 KB | larowlan |
| #76 | interdiff-a796e8.txt | 834 bytes | larowlan |
| #75 | 730374-75.patch | 2.1 KB | alexpott |
Comments
Comment #2
sundrupal.module-package-case.0.patch queued for re-testing.
Comment #4
sunAlthough badly needed, this is D8 material according to the rules (I had to learn today). It may be backported at a later point in time (though that's unlikely).
Comment #5
callison commentedLooks good to me.
@sun, would you please explain "the rules" as you mentioned above. I thought that bugs were fixed in the current release, but new features were added into the next release. Please correct me. :)
Comment #6
tstoecklerShouldn't this be handled in the projects themselves, i.e. shouldn't the two maintainers agree that e.g. in this case "User interface" is correct?
Comment #7
sun@tstoeckler: Multiply the amount in your scenario with ~10 and you understand the problem space:
See #227687: Properly capitalize "User interface" package name for a concrete example.
Comment #8
tr commentedThe portion of the patch that changes color.info is no longer needed, and is in fact wrong. All core modules in 8.x and 7.x have consistent usage of capitalization. They are all "package = Core" or "package = Testing".
Changing status to "needs work" because of the above.
Comment #9
jhedstromThis is still an issue, but the code has been moved to
ModuleListForm.Comment #10
joshi.rohit100Comment #11
rteijeiro commentedReviewed and it seems that patch in #10 is not working. Package names should be capitalised before building the form element. I provided a couple of screenshots to prove that now it's working.
@joshi.rohit100 It's a good practice to test and provide screenshots to help reviewers to check that your patch works. Anyway thanks for your contribution ;)
Comment #14
angleet commentedHi
My name is Jonathan. I'm at DrupalconLA and I've verified that the patch applies.
Comment #15
angleet commentedMachine names are lower case - this patch is forcing the first character of the machine name to upper case and therefore failing in tests - for example:
$this->drupalPostForm('admin/modules', array('modules[Field types][image][enable]' => "1"), t('Save configuration'));fails because it is should now be 'modules[Field Types][image][enable]'
The solution is to fix all the tests that refer to packages with improper nouns
(w/ Thanks to cosmicdreams!)
Comment #16
angleet commentedcosmicdreams and I think that by using proper nouns for package names in the tests this will pass.
Comment #18
angleet commentedFound one more spot that needs ucwords in InstallUninstallTest.php
Comment #19
cosmicdreams commentedPatch is green, reviewing...
Comment #20
cosmicdreams commentedThis will ultimately need to be reviewed by a core committer to see if it's the change we want to make. It technically does not alter any APIs, just some strings that shouldn't have been relied upon explicitly.
Comment #21
cosmicdreams commentedAdded beta evaluation. Screen shots to follow
Comment #22
cosmicdreams commentedComment #23
cosmicdreams commentedBefore the module is applied we can have package names that only vary by the way they are cased. Like this:

After the patch those casing difference are now denormalized and grouped. Like this:

Comment #24
cosmicdreams commentedComment #25
cosmicdreams commentedComment #27
cosmicdreams commentedI meant this
Comment #28
cosmicdreams commentedComment #31
izus commented#18 seems to solve the issue here
Comment #32
john cook commentedNeeded a re-roll due to text changes in button text.
I have also changed the case to
ucwords(strtolower($package))asstrtolower($package)was producing incorrect case in the package summary output.Comment #33
tr commentedI think you should be using Unicode::ucwords() rather than the PHP functions.
https://api.drupal.org/api/drupal/core!lib!Drupal!Component!Utility!Unic...
Comment #34
sdstyles commentedReplaced PHP functions with Unicode methods.
Comment #35
john cook commentedI have tested patch #34 with the following dummy modules:
Before the patch:

After the patch:

Also, the package label is sensibly capitalised:
<summary role="button" aria-controls="edit-modules-test-package" aria-expanded="false" aria-pressed="false">Test Package</summary>Comment #38
sdstyles commentedComment #39
ieguskiza commentedComment #40
ieguskiza commentedHi,
I have tested patch 34 with three test modules. See attached Extend before and after to see the results.
Modules are correctly grouped after the patch was applied and label is correctly capitalized
Hide Belgium Cities
Patch is ready to be RTBC.
Comment #41
ieguskiza commentedComment #42
alexpottWhy didn't we go for Unicode::ucfirst? There'd be way less change in HEAD then right since we would not need to change the tests?
Comment #43
john cook commentedI have changed
Unicode::ucwordtoUnicode::ucfirstas suggested in #42.I chose Unicode::ucword so to have the labels in title case, which has the first letter in each word capitalized.
Comment #47
sumitmadan commentedMoving it to needs review.
Comment #48
cosmicdreams commentedI helped out in the original development of this patch, but this approach is more complete and ucfirst is what I was going for so I agree this is a good change.
Comment #49
duaelfrUpdated IS to use the template and identify novice tasks.
Comment #50
duaelfrComment #51
alexpottI'm not convinced this is change is correct. At the moment we don't translate package names - if we do then this change is incorrect. If this occurs shouldn't we just raise an issue against the module to fix it?
Comment #52
john cook commentedI've added some related issues from the module perspective.
Comment #53
john cook commentedThe closest I can find for package name specification is Writing module .info files (Drupal 7.x). It is in the package section. Although this is for Drupal 7.x, I believe D8 follows the same guidelines.
The relevant part about case is repeated below:
It mentions "Drupal capitalization standard" but that is not described explicitly, it is "it should be capitalized as a proper name" as mentioned in the name section. From this the propper usage is
package = User InterfaceThere is also a lot of "should"s in the documentation. These would need to be changed to "must" or they can not be really classified as bugs, and it also identifies which modules are using the incorrect capitalization.
Comment #54
martins.kajins commentedTested #43 path.
Created one module with package name Issues and other module with package name ISSues.
Both modules were shown in same Package, so it means that patch #43 works.
Comment #55
clbuggs commentedComment #56
clbuggs commentedMarked the task embed before and after screenshots as done because they appear to be in comment #35. Don't see a reason why new screenshots are needed.
Comment #57
clbuggs commentedComment #63
alexpottI don't think this fix is right. If the packase is 'Commerce Tools' then it'll make it 'Commerce tools' where we do
'#title' => $this->t($package). We should only be normalising the package key.Comment #65
tr commentedThe patch in #43 is the most current patch under consideration.
That patch needs to be re-rolled to address the concerns raised by #63 and to account for changes in core made over the past 3.5 years.
There are three hunks in the patch. One hunk applies to ModulesListForm.php and the other two apply to InstallUninstallTest.php. But because the changes made in #2665152: Simplify module form structure and fix bugs when Suhosin is used removed the package name from the form element markup on the install page, we no longer need to make package-name-related changes in InstallUninstallTest.php.
What remains is a patch that changes just ONE LINE in ModulesListForm.php. This line changes form keys to use the package name standardized by
Unicode::ucfirst(strtolower("package name from .info.yml")). This also changes the package name used as the #title in the details form element that wraps the modules in that package.@alexpott's concern in #63 is that these package titles will now be listed in sentence case. He said:
But back in #42 he also said:
You can't really do both (see below). I agree with the second quote - all of core uses sentence case (ucfirst) so ucfirst is far less likely to be disruptive. The exception to sentence case is the new "Core (Experimental)" package, which was added long after this issue was last reviewed. But this patch only changes how that string is displayed on the modules list page, it doesn't break any test or necessitate changes to core .info.yml files. (And the Seven theme displays these titles in smallcaps, so it's not going to be capitalized like in your .info.yml file anyway ...)
There are reasons I disagree with the objection in #63:
ucwords(strtolower("Core (Experimental)"))because that won't work - it results in "Core (experimental)". And we have to transform it to a standardized version or else we leave ourselves vulnerable to this grouping issue all over again.So I propose the following patch, which again is just a one-line change which will fix this persistent and still-occurring problem.
Comment #66
tr commentedNew patch. Should be using mb_strtolower() instead of Unicode::strtolower().
Comment #72
larowlanComment #73
larowlanOptimistically setting this RTBC without tests as a litmus test for the discussion in #2972776: [policy, no patch] Better scoping for bug fix test coverage
Comment #74
alexpottLooking at the code - we end up doing
'#title' => $this->t($package),I think this means that we should not pass soemthing that has been put through
Unicode::ucfirst(mb_strtolower())to it.I think we should create a normalised key and then pass the package from the first module in the list. This means we won't break translations or end up oddly capitalising something that was intended to be capitals. For example if your are building a site for the World Wildlife Fund and you use that or WWF as the package name for the custom modules.
Comment #75
alexpottSomething like this...
Comment #76
larowlanJust fixing the so-called typo meh, US spelling--
Marking as RTBC, because all I'm changing is a borderline typo
Again, this is a test case for #2972776: [policy, no patch] Better scoping for bug fix test coverage so there's no tests
Comment #77
larowlanComment #82
catchComment #83
smustgrave commentedTested patch #77 by using Action and Automated Cron.
Changed Action to User interface
Changed Automated Cron to User Interface
Verified they appear as separate "packages" on the modules patch
Applied the patch and they are grouped together.
Seems like something a simple test could be added for but this is a minor issue so maybe it is overkill.
Comment #84
quietone commentedChecking RTBC issues. There are no unanswered questions here. I see that there are no tests but that is explained in #73. This is making a change for the UI but there are no before and after screenshots to demonstrate that this is working as intended. This is needed in all cases where the UI is change, even more so here when there are no tests.
Tagging for screenshots which should be in or linked to from the Issue Summary so they are easy to find. I went to add this to the remaining tasks but it is already listed.
Comment #85
smustgrave commentedComment #86
xjmHoly moly, it has a D8 beta evaluation. Old issue alert.
This should have a change record and a release note snippet, since it's both changing the behavior for these keys and also altering how core (and potentially Project Browser in a followup?) sort and list data from Drupal.org's project info.
We might also want to check with the infra team about this -- I don't know if d.o currently does anything with this data or not, but if we're changing the way core lists modules and d.o is able to extract the package and use it somehow, d.o would probably also need a parallel change.
Nit: Capitalizations.
This is a little confusing. I think it is trying to say:
A question about the actual functionality here. If there are multiple labels for the same package name, especially due to casing issues, presumably some are canonical (Sentence case labels) whereas some might be malformatted (Title Case Labels or lowercase labels). So, by defaulting to whatever is first in the array, are we perhaps overwriting a good label format with a bad one?
Should we have additional functionality to Title case the label if there are multiple versions that differ only by casing?
And what if the labels differ by more than their casing? What if they legitimately belong in different groups and it's the package key that's completely wrong?
Comment #87
nicxvan commentedComment #88
nicxvan commentedAsked in slack for the two groups in 1.
This needs an mr with the concerns 2, 3 , and 4 addressed.
Possibly, but it's better than multiple groups.
Simple title or sentence carrying was ruled out.
I feel strongly we should not, that would potentially be a lot of shuffling and guessing.
I'm not sure how that could arise or if it's a concern to worry about. If you have an examples that would help.
Comment #89
nicxvan commentedAsked in slack, @dww and @drumm confirmed d.o does not use the package key.
I don't see any evidence of project browser using this, but pinged again.
@chrisfromredfin also confirmed.