Skip to content
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

Compile Error: Declaration of Symfony\Component\HttpFoundation\InputBag::get(string $key, $default = null) must be compatible with Symfony\Component\HttpFoundation\ParameterBag::get($key, $default = null) #679

Closed
sebbm opened this issue Mar 25, 2022 · 16 comments

Comments

@sebbm
Copy link

sebbm commented Mar 25, 2022

Hi everybody, i've used contao-manager to update to version 1.5.2 of contao-manager. Since this update during system check of the contao-manager in the step the "Compeser Environment" ther comes following error message:

Error 500:
Compile Error: Declaration of Symfony\Component\HttpFoundation\InputBag::get(string $key, $default = null) must be compatible with Symfony\Component\HttpFoundation\ParameterBag::get($key, $default = null)

The Apache log says: GET /contao-manager.phar.php/api/server/composer HTTP/1.0

Contao manager log-file:
[25-Mar-2022 18:46:52 UTC] [2022-03-25 18:46:52] app.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\FatalThrowableError: "Compile Error: Declaration of Symfony\Component\HttpFoundation\InputBag::get(string $key, $default = null) must be compatible with Symfony\Component\HttpFoundation\ParameterBag::get($key, $default = null)" at /var/www/vhosts/ABC.de/httpdocs/ABC/vendor/symfony/http-foundation/InputBag.php line 30 {"exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Compile Error: Declaration of Symfony\Component\HttpFoundation\InputBag::get(string $key, $default = null) must be compatible with Symfony\Component\HttpFoundation\ParameterBag::get($key, $default = null) at /var/www/vhosts/ABC.de/httpdocs/ABC/vendor/symfony/http-foundation/InputBag.php:30)"} []

Is this an known issue ? The site itself and also the backend are OK but everytime i want to start contao-manager i get the same issue

@aschempp
Copy link
Member

aschempp commented Apr 1, 2022

sorry for the late response, did you fix this in the meantime? Please try to manually update the manager (upload the latest version) to make sure no file corruption is the problem.

@sebbm
Copy link
Author

sebbm commented Apr 1, 2022

Hi Andreas, thank you for your response.
No i was not able to solve the issue by now. i've tried to replace the manager file on the server but still the same issue.

@fritzmg
Copy link
Contributor

fritzmg commented Apr 1, 2022

The issue seems to be somehow related to erdmannfreunde/optimist-theme-bundle - at least according to the other reports in the community. @sebbm do you have that package as well?

@sebbm
Copy link
Author

sebbm commented Apr 1, 2022

@fritzmg: Yes, you're right i'm using this optimist-theme

@fritzmg
Copy link
Contributor

fritzmg commented Apr 1, 2022

The workaround would be to remove the package, update, then add the package again. However, @denniserdmann may be you can investigate this issue?

@denniserdmann
Copy link

We'll have a look at it.

@richardhj
Copy link
Member

I did investigate but am unable to explain how this issue can be related to https://github.com/erdmannfreunde/optimist-theme-bundle in any way? There is no reference to those methods at all. Does someone have a guess?

@denniserdmann
Copy link

denniserdmann commented Apr 7, 2022

As discussed on slack, i think the problem is, that updating optimist means uploading the package AND press update contao, as update all packages is canceled. But updating only selected packages results in a command like this: composer require contao/manager-bundle=4.13.* … --no-update

So symfony and all the other packages are not updated because of --no-update. Result: you have a contao 4.13 installation that expects newer versions of packages that were not installed.

Update: I made some more tests and think Contao Manager itself is the problem.

  1. In a fresh Contao 4.12 installation, i can not install them optimist theme, canceling process with the same error
  2. in a contao 4.13 installation i can install them optimist theme, but when i downgrade to 4.12, i cannot remove it --> same error
  3. when i use cli with php web/contao-manager.phar.php composer remove erdmannfreunde/optimist-theme-bundle --> same error
  4. when i use composer with php composer.php remove erdmannfreunde/optimist-theme-bundle it's working.

@aschempp
Copy link
Member

aschempp commented Apr 8, 2022

I have ideas how this is happening, but not why. The Contao Manager ships with Symfony 4.4, which includes the ParameterBag class. This class is likely different from what is installed in the vendor folder (which for Contao 4.13 is Symfony 5.4). Somehow the InputBag class from vendor/symfony... is used while the composer plugin is executed. I can't see how this is related to erdmannfreunde/optimist-theme-bundle since its composer plugin does not use that class. But it sure is related to mixing two different Symfony versions. And probably not much the Contao Manager can do 😞

@richardhj
Copy link
Member

I have ideas how this is happening, but not why. The Contao Manager ships with Symfony 4.4, which includes the ParameterBag class. This class is likely different from what is installed in the vendor folder (which for Contao 4.13 is Symfony 5.4). Somehow the InputBag class from vendor/symfony... is used while the composer plugin is executed. I can't see how this is related to erdmannfreunde/optimist-theme-bundle since its composer plugin does not use that class. But it sure is related to mixing two different Symfony versions. And probably not much the Contao Manager can do 😞

Sounds like contao/contao#2183...

@fritzmg
Copy link
Contributor

fritzmg commented Apr 8, 2022

Sounds like contao/contao#2183...

There it's clear, because the Script Handler directly uses Symfony Process, which Composer has its own version of. But here it is not (yet) clear, as the plugin does not use InputBag directly. Without having tested this in depth my guess is the usage of the Symfony VarDumper within the plugin - because the VarDumper uses Symfony HttpFoundation components.

I think @denniserdmann should remove the VarDumper output as this should not be done for any production code anyway.

@richardhj
Copy link
Member

Sounds like contao/contao#2183...

There it's clear, because the Script Handler directly uses Symfony Process, which Composer has its own version of. But here it is not (yet) clear, as the plugin does not use InputBag directly. Without having tested this in depth my guess is the usage of the Symfony VarDumper within the plugin - because the VarDumper uses Symfony HttpFoundation components.

I think @denniserdmann should remove the VarDumper output as this should not be done for any production code anyway.

That's a good guess. However the dd was introduced recently by accident, thus this wont be the culprit (as it was introduced after the issue occurred). Since the issue occurs very occasional, Dennis and I will investigate an affected Contao installation to reproduce this issue.

@denniserdmann
Copy link

After several tests, we come to the following conclusion:

  1. this problem only exists in Contao 4.11 and 4.12 as these versions use symfony < 5.4. Contao 4.13 uses symfony >=5.4 and Contao 4.9 and 4.10 use symfony 4.4.
  2. upgrading Contao 4.11 and 4.12 installations can be done by disabling the optimist-theme-bundle via composer.json, adding the following lines before the last closing brace:
"config": {
    "allow-plugins": {
        "contao-components/installer": true,
        "contao/manager-plugin": true,
        "contao-community-alliance/composer-plugin": true,
        "erdmannfreunde/optimist-theme-bundle": false
    }
}
  1. after upgrading to Contao 4.13 one should remove these lines in order to use the contao manager default behaviour.

@ACCakut
Copy link

ACCakut commented Apr 24, 2022

Thanks a lot @denniserdmann . I was stuck for hours on this bug, chasing for coincident PHP executable path errors (PhpExecutableFinder.php) and Google did me led to here.

Don't forget to add a , right before the code from Dennis, otherwise you get an JSON parse error.

Like:

            "Contao\\ManagerBundle\\Composer\\ScriptHandler::initializeApplication"
        ]
    }, <----------- ### THERE ###
    "config": {
        "allow-plugins": {

Keywords:
Contao Install Manager 1.5.5 Compile Error Declaration Input Bag

@sebbm
Copy link
Author

sebbm commented Apr 28, 2022

Thank you too. I was also able to solve my issue and will close it.

@sebbm sebbm closed this as completed Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants