-
Notifications
You must be signed in to change notification settings - Fork 642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[4.x]: The update command modifies the package order in the require section #13806
Comments
Do you have |
@brandonkelly D'oh, I'm stupid. You're right, totally forgot that we had that in there. Removed it and now the order is retained. This behaviour just surprised me, since this didn't use to happen in previous Craft versions – did that change with the recent refactoring of the Composer integration? |
We’ve been passing the Line 232 in 0bcd212
However it’s possible that we are enforcing it more strictly than Composer‘s internal JSON manipulation logic does, now that we’re no longer using That said, it feels like expected behavior that if you have |
@brandonkelly Yes, this is absolutely the expected behaviour! I was just caught off guard. I've noticed that the Craft commands behave slightly differently than native Composer commands (e.g. it removes the newline at the end if there is one, while Composer keeps this as-is). But yeah, having |
Actually, looks like that’s exactly what |
@brandonkelly Awesome, thanks Brandon! That looks great, didn't realize Composer behaved like this already. Very nice that Craft matches this behaviour now. |
Craft 4.5.7 is out now with that fix 🎉 |
What happened?
Description
I'm seeing an error where running
php craft update all
changes the order of requirements in thecomposer.json
. Before:After:
I don't like this behaviour. We prefer to have platform requirements (in particular, the
php
requirement) at the top to see which PHP version a project is using at a glance. This seems to be a behaviour of Craft's update in particular. Runningcomposer update -W
(after changing the fixed version numbers to version ranges) doesn't exhibit this behaviour.As a side note, it also looks like it's stripping the trailing newline at the end of the file. Composer retains the newline if it exists, and many editors are configured to add it back if it's missing, so this results in some unnecessary noise in git diffs.
Steps to reproduce
php
requirement at the top of therequire
section in yourcomposer.json
.php craft update all
in a project with pending Craft/plugin updates.Expected behavior
The command should never modify the order of packages in the requirement. If this is necessary for implementation reasons, it should at least put system requirements (like the
php
requirement) at the top so they aren't mixed in with other packages.Actual behavior
The order of packages is changed, looks like it's sorting them alphabetically. This might make sense for normal package, but nor for system requirements.
Craft CMS version
4.5.5
PHP version
8.2
Operating system and version
macOS
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
No response
The text was updated successfully, but these errors were encountered: