magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.59k stars 9.32k forks source link

Declaration compatibility issue while compilation after upgrade magento version 2.4.7-p2 #39166

Closed kiwicommerceltd closed 2 months ago

kiwicommerceltd commented 2 months ago

Preconditions and environment

Steps to reproduce

Upgrade to Magento 2.4.7-p2 PHP version 8.1.29 composer install bin/magento setup:di:compile

Expected result

Compile command executed successfully

Actual result

Fatal error: Declaration of Magento\Setup\Console\Style\MagentoStyle::createProgressBar($max = 0) must be compatible with Symfony\Component\Console\Style\OutputStyle::createProgressBar(int $max = 0): Symfony\Component\Console\Helper\ProgressBar in /home/web/build/setup/src/Magento/Setup/Console/Style/MagentoStyle.php on line 322

Additional information

No response

Release note

No response

Triage and priority

m2-assistant[bot] commented 2 months ago

Hi @kiwicommerceltd. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

hostep commented 2 months ago

@kiwicommerceltd, I think your file setup/src/Magento/Setup/Console/Style/MagentoStyle.php is outdated. It should have ProgressBar declared as return type in Magento 2.4.7-p2, but that doesn't seem to be the case for you.

I suspect that the composer file marshalling failed and you are left with old files from an older Magento version in setup/src.

Can you try the following?

rm -R vendor/magento/magento2-base/
composer install

And see if that solves it? It should overwrite the files in setup with the correct files in theory.

kiwicommerceltd commented 2 months ago

@hostep That is not the case actually because the deployment is going through the pipeline, so while upgrading Magento the fresh code getting pulled

hostep commented 2 months ago

Sorry, but that's the only explanation I have, can you please double check?

This is how the file should look in 2.4.7-p2: https://github.com/magento/magento2/blob/2.4.7-p2/setup/src/Magento/Setup/Console/Style/MagentoStyle.php#L322, note that it has a return type defined : ProgressBar

According to your error message, your file is missing the return type definition. Which is how the file was in for example Magento 2.4.6-p7 and earlier versions: https://github.com/magento/magento2/blob/2.4.6-p7/setup/src/Magento/Setup/Console/Style/MagentoStyle.php#L322

So please double check, I think something is going wrong in your deploy pipeline then?

kiwicommerceltd commented 2 months ago

@hostep The issue has been resolved now, I completely removed the setup folder and replaced This works for me. Thanks for your suggestions that helped me