Problem/Motivation
system_sort_modules_by_info_name() is also used to sort themes, and is thus misnamed.
Proposed resolution
Rename the function to system_sort_by_info_name()
.
Remaining tasks
Discuss whether we should add backwards-compatible, deprecated "wrappers" to help transition to the new function names. See #778346-5: system_sort_modules_by_info_name() is misnamed (which includes a D7 patch using this method) and #1221904: RFC: forwards compatibility in D7 / 'backports' defgroup (for a broader discussion).
If not, the D8 patch can go in by itself.
User interface changes
None.
API changes
system_sort_modules_by_info_name()
will be renamed to:
system_sort_by_info_name()
optionally with backwards-compatible wrappers that make backportable.
Original report by @cwgordon7
system_sort_modules_by_info_name() is also used to sort themes, so perhaps it should be renamed to system_sort_by_info_name()?
Comment | File | Size | Author |
---|---|---|---|
#31 | 778346-31.patch | 5.07 KB | dhirendra.mishra |
#31 | interdiff_26-31.txt | 1.95 KB | dhirendra.mishra |
#26 | interdiff_24-26.txt | 1.01 KB | vsujeetkumar |
#26 | 778346-26.patch | 5.11 KB | vsujeetkumar |
Comments
Comment #1
pillarsdotnet CreditAttribution: pillarsdotnet commentedPatch.
Comment #2
cwgordon7 CreditAttribution: cwgordon7 commentedAwesome, looks good. This has always bugged me.
Comment #3
Dries CreditAttribution: Dries commentedThis looks good but can't be backported to D7. Thus, I'm going to wait a bit with committing it to D8.
Comment #4
catchWe could consider adding wrapper functions to D7 when there is a straight switch like this, so that people can make modules 'forwards compatible' to the extent possible. So I'm tagging for backport but that likely needs wider discussion.
Comment #5
xjmAttached variant would add a backwards-compatible wrapper to promote forwards compatibility. (To the DeLorean!)
This is patterned on the solution in #1174444: Make the _element_validate_* functions in field.module available for all contrib modules to use.
Dropping to 7.x temporarily for testbot.
Comment #6
xjmPatch passed; back to 8.x
Added issue summary.
Comment #7
xjm#1: rename-system_sort_modules_by_info_name-778346-1.patch queued for re-testing.
Comment #7.0
xjmUpdated issue summary.
Comment #7.1
xjmAdding link to meta issue.
Comment #8
xjm#5: system_sort_by_info_name-wrapper-D7-778346-5.patch queued for re-testing.
Comment #9
xjmReroll of the D8 patch for core/.
Comment #10
kscheirer#9: system_sort_by_info_name-778346-9.patch queued for re-testing.
Comment #11.0
(not verified) CreditAttribution: commentedClarification.
Comment #20
catchStill valid, but this is a task. Should also consider whether this should move to the extension system.
Comment #21
sudiptadas19 CreditAttribution: sudiptadas19 at QED42 for Drupal India Association commentedProposed changes have been addressed. Please review it.
Comment #22
tim.plunkettThe original function needs to be left as a wrapper around the new one, with deprecation warnings.
Comment #23
vsujeetkumar CreditAttribution: vsujeetkumar at Srijan | A Material+ Company for Drupal India Association commentedAdded deprecation warnings with the wrapper function for 9.3.x. As mentioned in #22, Please have a look.
Comment #24
vsujeetkumar CreditAttribution: vsujeetkumar at Srijan | A Material+ Company for Drupal India Association commentedFixed the above(#23) issue. Please have a look.
Comment #25
quietone CreditAttribution: quietone as a volunteer commentedThis needs a test of the deprecation, see item #3 in How we deprecate.
Comment #26
vsujeetkumar CreditAttribution: vsujeetkumar at Srijan | A Material+ Company for Drupal India Association commentedAdded test as mentioned in #25.
Comment #27
vikashsoni CreditAttribution: vikashsoni as a volunteer and at Zyxware Technologies commented@vsujeetkumar thanks for the patch
patch apply successfully
Comment #28
bnjmnmRe #27 @vikashsoni adding a screenshot that shows a patch applies provides zero benefit. In the previous comment, the Drupal test runner automatically confirms a patch applies:
I notice this has been pointed out to you before:
I encourage you to use Slack to work with some of the contributors involved in these issues. We'd be happy to help you find ways to contribute to issues that benefits them and would actually get you credited (providing screenshots of a patch applying does not qualify for issue credit)
Comment #29
daffie CreditAttribution: daffie commentedThe patch looks good. Just a little bit more work:
I think that this change is wrong. If I am wrong, then where does this method inherit its docblock from?
Could we initialize the array before we start using it by adding:
$module_info = [];
The deprecation message must link to the change record (https://www.drupal.org/node/3225624) not the original issue.
Comment #30
dhirendra.mishra CreditAttribution: dhirendra.mishra at Valuebound for Valuebound commentedlet me work on above feedback
Comment #31
dhirendra.mishra CreditAttribution: dhirendra.mishra at Valuebound for Valuebound commentedKindly review the patch.
Comment #32
joachim CreditAttribution: joachim as a volunteer commentedLGTM.
Comment #33
catchThere are some possible follow-ups to this:
1. Move it to a utility class or trait out of system.module
2. Inline the logic in the closure in the three places it's used and remove the public function altogether.
At three usages it's a bit borderline which of these is the better option, so going ahead and committing this one.
Comment #35
alexpottThis is always being used to sort lists of Extension objects. We should add a public static function sort to \Drupal\Core\Extension\Extension and use that instead.
Comment #36
alexpottThis method should get the installed module list as extensions form \Drupal\Core\Extension\ModuleHandlerInterface::getModuleList() instead of
Which is really odd code.
Comment #37
alexpottlol funny xpost - I'll open a follow-up when I have a moment.
If we don't move this to an object then documentation should be improved... the whole point of this change is that this is not only about modules.
Comment #38
alexpottCreated a follow-up to deal with #35 / #36 / #37...
See #3225779: Provide sort callback on ExtensionList class