Description
What happened?
Description
I'm seeing an error where running php craft update all
changes the order of requirements in the composer.json
. Before:
"require": {
"php": "~8.2.0",
"clubstudioltd/craft-asset-rev": "7.0.0",
"craftcms/ckeditor": "3.6.0",
"craftcms/cms": "4.5.5",
"craftcms/contact-form": "3.0.1",
"rynpsc/craft-phone-number": "2.1.0",
"sebastianlenz/linkfield": "2.1.5",
"twig/string-extra": "^3.5",
"verbb/navigation": "2.0.21",
"verbb/smith": "2.0.0",
"verbb/super-table": "3.0.9",
"vlucas/phpdotenv": "^5.5.0"
},
After:
"require": {
"clubstudioltd/craft-asset-rev": "7.0.0",
"craftcms/ckeditor": "3.6.0",
"craftcms/cms": "4.5.6.1",
"craftcms/contact-form": "3.0.1",
"php": "~8.2.0",
"rynpsc/craft-phone-number": "2.2.0",
"sebastianlenz/linkfield": "2.1.5",
"twig/string-extra": "^3.5",
"verbb/navigation": "2.0.21",
"verbb/smith": "2.0.0",
"verbb/super-table": "3.0.12",
"vlucas/phpdotenv": "^5.5.0"
},
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. Running composer 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
- Put a
php
requirement at the top of therequire
section in yourcomposer.json
. - Run
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