-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
Generated code in autoload_real.php collision of hashes with multiple instances of composer (in 2.6.4, not present in 2.6.3) #11675
Comments
I'm also curious to learn more about the issue this is introducing. |
The problem is that the generated hash is always the same for any composer.json. So when you have 2 projects (both with a composer.json file) and you need to autoload just a few parts of the other project this is not possible anymore. And yes normally you would extract the common classes and put those in a shared repository, but this is not feasible with how the application grew over a few decades time. |
@qrizly2 please can you provide two example |
I still do not understand the issue. Basically, the only relevant change in the PR I submitted is this single line: https://github.com/composer/composer/pull/11663/files#diff-67d1dfefa9c7b1c7e0b04b07274628d812f82cd82fae635c0aeba643c02e8cd8R410 As you can see, instead of generating a random suffix, it uses the suffix from the I have troubles understanding a use case where this would create an issue. |
If you're somehow calling the autoload dumper manually to generate different autoloaders for subsets of packages, even tho that would seem strange to me as autoloading really should mean there is no penalty to having lots of classes "available" at once, then make sure you set an autoloader-suffix in the config or pass $suffix to AutoloadGenerator::dump to ensure it's unique for each instance. If it's not that, then as the others said I have no clue what you are doing and we'd need more infos :) |
In short we have the following structure: with the content of the composer.json file of application-1: {
"autoloader-suffix": "A",
"autoload": {
"classmap": [
"ProjectA/Model"
]
}
} with the content of the composer.json file of application-2: {
"autoloader-suffix": "B",
"autoload": {
"classmap": [
"ProjectB/Model"
]
}
} and the content of application-3 index.php: <?php
include_once __DIR__ .'/../application-1/vendor/autoload.php';
include_once __DIR__ .'/../application-2/vendor/autoload.php';
echo 'hi'; when you run index.php in appplication-3 this will generate the following error:
|
Could you remove the |
Don't regenerate the autoloader, just remove the |
@qrizly2 have you set a "name" in your composer/src/Composer/Package/Locker.php Lines 81 to 86 in d2bd983
|
|
But indeed if you only have a composer.json like this:
Then your composer.lock hash will be the same as the autoload config isn't part of the hash, and there are no dependencies. So if deleting the lock file you still get an empty one recreated when you run |
Thank you. That seems to work, for completeness sake: composer.json file for application-1: {
"config": {
"autoloader-suffix": "A"
},
"autoload": {
"classmap": [
"ProjectA/Model"
]
}
} composer.json file for application-2: {
"config": {
"autoloader-suffix": "B"
},
"autoload": {
"classmap": [
"ProjectB/Model"
]
}
} |
Output of
composer diagnose
:When I run this command:
I get the following output in file "vendor/composer/autoload_real.php"
And I expected this to happen, when i run it for the second time: that the hash after "ComposerAutoloaderInit" will change.
It does this in 2.6.3, but will stay the same in 2.6.4
The text was updated successfully, but these errors were encountered: