Needs work
Project:
Drupal core
Version:
main
Component:
configuration system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
7 Feb 2022 at 06:58 UTC
Updated:
23 Aug 2026 at 23:16 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
andypostComment #3
andypostFiled CR and looks it need replacement
Comment #4
volegerLooks good. The new method replaced all function usages with the appropriate code. A deprecation message was added and is correct. The deprecation test is implemented.
Comment #5
andypostThere's +3583 failures and new method needs extensive testing
Also I'm not sure sure that helper is useful, maybe some config event could be used to apply sorting for modules automatically...
This way the function will become @internal
@voleger any ideas?
Comment #6
volegermethod has to be static
Let's update the method definition and see what else is left.
Comment #7
andypostThank you! good catch)
Comment #8
andypostI still looking for a way to get rid of it without replacement, this method is implementation details and should be "protected in module installer" IMO
This is only place where the function used for some sophisticated logic at install time.
All other places is config->set(module, SORTABLE) and tests... are hacking config as well
Comment #9
volegerTest results looks good now
Comment #10
catchI think it's worth seeing if we can do #8 before going ahead here, removing the API altogether would be better.
Comment #11
catchComment #14
mile23Rerolled for 10.1.x. I'm also not sure where it gets removed, so I said 10.2, which is probably wrong.
There's no unit test for
module_config_sort(), and now there's no unit test forsortByWeightAndKeys(), so I'm adding a needs test tag.If we can make it go away as per #10 and #8, then no test needed.
Comment #15
andypostDeprecation removals are supposed to happen only in major releases so only few nits
The tests should be
- deprecation test to be sure functions rutuning the same results
- extra unit test like
core/tests/Drupal/Tests/Component/Utility/SortArrayTest.phpit should be removed from 11.0
line longer 80 chars
19 means only for 64-bits but I think it's ok for nowadays
Comment #16
mile23Takes care of #15 1 and 2, but I'm not really sure what to do about 3.
Still needs a test to determine that both functions operate identically.
Comment #17
nivethasubramaniyan commentedFixing CCF in #16
Comment #18
smustgrave commentedFor tests and #15.3
Comment #19
andypostboth should be
drupal:11.0.0Comment #20
spokjeTried to address #18 and #19.
Comment #21
andypostI'm sure #15.3 should not have even comment as 32-bit big-int is known issue and mostly no distros left
Comment #23
spokjeKnown (at least to me...) random JS test failure, back to RTBC and ordered retest.
Comment #24
catchThis is interchanging 'keys' and 'names', given the method name I think it should just be 'keys' everywhere?
Also should we be talking about 'the list of enabled modules' in Component/Utility and especially whether it's sorted on read or write? Could that be moved to an inline comment in the calling code somewhere?
Comment #25
andypostMoved comment
Comment #26
andypostprobably it could be added to @param description
I think it makes sense to point about cast to in for array values
Comment #27
Ratan Priya commented@anypost,
Made changes as per comment #26.
Needs review.
Comment #28
smustgrave commentedBelieve #27 addresses #26
Comment #29
alexpottIf we're moving this functionality to the utility class we should be adding explicit and extensive test coverage of this to \Drupal\Tests\Component\Utility\SortArrayTest.
Also the name of this method is interesting I think it should be something else. The other usage of the word weight in this class refers to a weight property. Here we're sorting an array of integers by the value and then by the key. I think the method name should reflect that. To me this is really
sortByIntValueAndKey(). I think the typehint should be@param int[] $array.Comment #30
andypostChanged method name but still needs test.
Meanwhile I think we can remove this method at all in case of related #3347842: Deprecate the trusted data concept in configuration
The new config class can care about sorting module list before saving the config if I got it right
Comment #31
kim.pepperAdded a test including one that I think should pass, but fails.
Comment #32
kim.pepperFor some reason the diff was whacky. Changing the order of methods seems to make it behave.
Comment #34
kim.pepperThis should sort asc right?
Comment #36
kim.pepperI think this can be greatly simplified to just an array multisort like:
array_multisort(array_values($array), SORT_ASC, array_keys($array), SORT_ASC, $array);This modifies the original array that gets passed in by reference so calling code will need to change too. I think this is more in line with how usort etc. work though.
Comment #37
smustgrave commentedSeems to have some failures.
Have not re-reviewed yet.
Comment #38
kim.pepperFixes test fails due to dodgy extension config setting logic.
Comment #39
kim.pepperFix more extension config setting issues.
Comment #42
kim.pepperFixes test fails.
Comment #43
kim.pepperI wonder if this should just be
sortByWeightAndKey()since that's what we use it for?Comment #44
kim.pepperJust re-read the comments and @alexpott suggested
sortByIntValueAndKey()back in #29.Comment #45
andypostLooking at https://git.drupalcode.org/project/drupal/-/blob/10.1.x/core/modules/mig...
I think it should add SORT_NUMERIC to value and SORT_STRING to keys
Comment #46
andypostMissing "A Keyed array..."
Comment #47
kim.pepperFixes for #45 and #46.
I also bumped the deprecation message to 10.2.x in anticipation of it opening soon.
Comment #48
kim.pepperMore docblock feedback from @andypost in slack.
Comment #49
andypostI find it ready, let's wait for 10.2 opening
Comment #51
kim.pepperLooks like a random fail. Happening in HEAD too apparently.
Comment #52
andypostYes, back to RTBC
Ref
Drupal\FunctionalTests\Installer\InstallerExistingConfigMultilingualTestComment #53
larowlanCan we add a test case that uses a string value that is numeric e.g. '3'
Or alternatively can we add a check that each value is an integer?
Comment #54
larowlanComment #55
kim.pepperChanging this to a bug as the current implementation doesn't correctly order negative weights.
Comment #56
kim.pepper#53.1
Added a test for passing string values (of numbers) that can still be sorted numerically.
Comment #57
jibranReviewed this patch with @kim.pepper at DrupalSouth. I think going with #53.1 makes sense. The patch looks good now so setting it back to RTBC.
Comment #59
andypostrandom failure
Comment #61
kim.pepperrandom failure
Comment #63
smustgrave commentedSeems like the random failure popping up today.
Comment #65
andypostfailed
Drupal\Tests\views\Functional\Plugin\DisplayFeedTranslationTest::testFeedFieldOutput(), re-queuedComment #66
sorlov commentedTests are ok now
Comment #68
andypostFailures after #3384960: Strengthen TransactionManager
Comment #69
quietone commentedI'm triaging RTBC issues. I read the IS and the comments. I didn't find any unanswered questions or other work to do.
I noted that #53 suggesting either testing for an integer or testing for numeric. I read the patch and it adds a test for numeric values proving that the method works for integer and numeric values. However, the method name is still,
sortByIntValueAndKey, which seems misleading. Shouldn't it besortByNumericValueAndKey? Although, I guess one could also argue that is should 'Natural' should be in the title as well."int" is not a word. But this also accepts numeric values.
The tests include testing numeric values, so is this correct?
This is rather generic, merely describing what any data provider does. I suppose the test should have a case for alphanumeric keys.
Instead of setting back to NW I opted to make a patch changing the method name and updating the comments. Is this better?
Comment #70
andypostGood point about numeric, the only question is a test for floats (as they allowed)
doc-block is fine to keep with
intThere's no ability to point (int|float)[]
Comment #71
smustgrave commentedThere an example of floats being used?
Comment #72
andyposttechnically that's allowed but not sure in a wild
Comment #73
smustgrave commentedIs it something that should be allowed? Would it be worth a follow up to look into disallowing or throwing an error if floats are passed?
Comment #74
smustgrave commentedGoing to mark but do wonder if we should prevent floats.
Comment #75
longwaveI think it's fine to document that the values should be integers; if it coincidentally works with floats that is not something we officially support as we have not documented it, but also something that I don't think we should spend time checking for or throwing errors for.
The updated method name has not been correctly replaced in all places, such as comments and the deprecation notice, back to NW for that.
Assigned and saved issue credits.
Comment #76
longwaveMethod name needs updating.
Method name needs updating.
Method names need updating.
Comment #78
andypostConverted to MR and fixed #76
Comment #79
andypostI bet it will be easier to improve docs via MR for #75
Comment #80
smustgrave commentedCould it be as simple as
?
Comment #81
andypostChanged https://git.drupalcode.org/project/drupal/-/merge_requests/5106/diffs?di...
Comment #82
smustgrave commentedComment looks good. Gitlab is all green.
Comment #83
xjmPlease remember to hide patch files from the IS when an issue is converted to MR. Thanks!
Comment #84
xjmPosted a number of points on the MR. I have several concerns about the data typing and integrity as well as possible behavior changes from this deprecation.
This will need config subsystem maintainer signoff before it is committed. It is also a significant change that may impact the data integrity of the config sort if done incorrectly, so it should have careful framework or release manager review in its final state.
Comment #85
andypostComment #87
catchI've just committed #3595652: Deprecate module.inc contents which moves the method to a specific class. I think we need to decide if we want to add a generic sort method still, so retitling. Although if we deprecate module weights as a whole, we wouldn't have any usages in core.
Comment #88
nicxvan commentedI'd vote for applying the credit here and closing this.
Are there other cases we need this?