fooman / printorderpdf-implementation-m2

5 stars 8 forks source link

getting error when setup:di:compile with magento 2.4.3 #14

Closed PiroozMB closed 2 years ago

PiroozMB commented 2 years ago

I'm getting this error when I do a bin/magento setup:di:compile after installing the module manually in app/code/ on my magento 2.4.3 Interception cache generation... 6/9 [==================>---------] 66% 39 secs 422.0 MiBErrors during compilation: Fooman\PrintOrderPdf\Model\Pdf\Order Incompatible argument type: Required type: \Magento\Framework\ObjectManagerInterface. Actual type: \Magento\Payment\Helper\Data; File: /data/web/magento2/app/code/Fooman/PrintOrderPdf/Model/Pdf/Order.php

Total Errors Count: 1

In Log.php line 92:

Error during compilation

fooman commented 2 years ago

@PiroozMB

installing via app/code is not something we recommend or support. Installing via the metapackage ensures that the version we have tested against the given Magento version gets installed.

I have double checked compilation on 2.4.3

image

and did not encounter any issues.

The error message is also odd as the ObjectManager is neither in our constructor arguments nor Magento's.

Steps from here:

  1. make sure that there are no other extension's, code modifications for pdfs present
  2. install using our installation steps

Feel free to re-open if you are able to replicate this with more info.

PiroozMB commented 2 years ago

installed a new magento 2.4.3 just now and then installed your extension via option 2:

Option 2: The manual option (using packagist.org) From a command line in your Magento root folder run

composer require fooman/printorderpdf-m2:^3.0 bin/magento module:enable --clear-static-content Fooman_PrintOrderPdf bin/magento setup:upgrade If you are using Production Mode please also run

bin/magento setup:static-content:deploy bin/magento setup:di:compile

, now getting this error: Fooman\PrintOrderPdf\Model\Pdf\Order Incompatible argument type: Required type: \Magento\Framework\ObjectManagerInterface. Actual type: \Magento\Payment\Helper\Data; File: /data/web/magento2/vendor/fooman/printorderpdf-implementation-m2/src/Model/Pdf/Order.php

Total Errors Count: 1

In Log.php line 92:

Error during compilation

fooman commented 2 years ago

Thanks for checking again. Still wondering where our different results are coming from. Can you please run composer show fooman/*, as well as cat composer.json and post your results.

PiroozMB commented 2 years ago

Sure:

root@1c9c35ede539 /data/web/magento2 # composer show fooman/* fooman/printorderpdf-implementation-m2 105.0.2 Print the order as a pdf from the admin fooman/printorderpdf-m2 3.3.3 Print the order as a pdf from the admin

=============================================

root@1c9c35ede539 /data/web/magento2 # cat composer.json { "name": "magento/project-community-edition", "description": "eCommerce Platform for Growth (Community Edition)", "type": "project", "version": "2.2.3", "license": [ "OSL-3.0", "AFL-3.0" ], "require": { "composer/composer": "@alpha", "prince/module-faq": "1.0.3", "mageside/module-subscribe-at-checkout": "1.1.6", "magepal/magento2-guest-to-customer": "^1.1", "code4business/freeproduct2": "^1.0", "mageplaza/magento-2-german-language-pack": "dev-master", "mageplaza/magento-2-french-language-pack": "dev-master", "owebia/magento2-module-advanced-shipping-setting": "^2.1.1", "magekey/module-adc-popup": "^2.0", "magefan/module-blog": "^2.8", "magefan/module-blog-m22": "^2.0", "mageplaza/magento-2-social-login": "^2.6", "mailchimp/mc-magento2": "1.0.29", "magefan/module-lazyload": "^2.0", "kiwicommerce/module-login-as-customer": "^1.0", "msp/recaptcha": "^2.0", "zendesk/zendesk_api_client_php": "^2.2", "dpdconnect/php-sdk": "^1.0", "phpoffice/phpword": "^0.17.0", "magento/product-community-edition": "2.4.3", "fooman/printorderpdf-m2": "^3.0" }, "require-dev": { "phpunit/phpunit": "~6.2.0", "squizlabs/php_codesniffer": "3.2.2", "phpmd/phpmd": "@stable", "pdepend/pdepend": "2.5.2", "friendsofphp/php-cs-fixer": "~2.16.0", "lusitanian/oauth": "~0.8.10", "sebastian/phpcpd": "2.0.1" }, "autoload": { "psr-4": { "Magento\Framework\": "lib/internal/Magento/Framework/", "Magento\Setup\": "setup/src/Magento/Setup/", "Magento\": "app/code/Magento/" }, "psr-0": { "": [ "app/code/" ] }, "files": [ "app/etc/NonComposerComponentRegistration.php" ], "exclude-from-classmap": [ "/dev/", "/update/", "/Test/" ] }, "autoload-dev": { "psr-4": { "Magento\Sniffs\": "dev/tests/static/framework/Magento/Sniffs/", "Magento\Tools\": "dev/tools/Magento/Tools/", "Magento\Tools\Sanity\": "dev/build/publication/sanity/Magento/Tools/Sanity/", "Magento\TestFramework\Inspection\": "dev/tests/static/framework/Magento/TestFramework/Inspection/", "Magento\TestFramework\Utility\": "dev/tests/static/framework/Magento/TestFramework/Utility/" } }, "minimum-stability": "stable", "repositories": [ { "type": "composer", "url": "https://repo.magento.com/" } ], "extra": { "magento-force": "override" }, "config": { "allow-plugins": { "magento/magento-composer-installer": true, "magento/composer-root-update-plugin": true, "laminas/laminas-dependency-plugin": true, "magento/inventory-composer-installer": true } } }

fooman commented 2 years ago

This seems to be your composer.json from a Magento site started on 2.2.3 and then upgraded to 2.4.3. I do note that a lot of entries looks very different to how a fresh Magento 2.4.3 would look.

You mentioned you had a fresh install of 2.4.3. Can you please send the output of that.

PiroozMB commented 2 years ago

No its a migrated magento from 2.2.3 to 2.4.3. Does your extension only work on a fresh magento and not on an upgraded one?

fooman commented 2 years ago

When you migrate from 2.2.3 to 2.4.3 you need to ensure that the composer.json content is also migrated.

For more recent migrations Adobe even offers a Composer plugin to handle this. See the blog post announcing the tool https://community.magento.com/t5/Magento-DevBlog/Easier-upgrades-with-new-Composer-plugin/ba-p/136232

Your current composer.json has the potential to alter Magento behaviour quite substantially. Which may well be the explanation for the issue you ran into.

PiroozMB commented 2 years ago

but i did the upgrade just like it was said in de documentation via the composerRootUpdate plugin and every thing works fine and I get no errors in de logs,every single third-party extension except for yours. I also see the version 2.4.3 in the backend in the bottom of the page.

fooman commented 2 years ago

@PiroozMB it unfortunately looks like the root update plugin did not work in this case then. If you compare your composer.json to this https://github.com/magento/magento2/blob/2.4.3/composer.json#L89-L124 it looks substantially different.

Please understand that this is the extent I am able to provide free support for our free extension. If you have the same issue with a fresh installation of Magento 2.4.3 happy to take another look. Alternatively feel free to get in touch via email to discuss hiring us to troubleshoot the issue with your current circumstances.