MagestyApps / module-web-images

Magento 2 module for uploading images in optimised formats (SVG, WebP, etc.)
https://www.magestyapps.com
93 stars 16 forks source link

Compilation issue : Incompatible argument type: Required type: string. Actual type: File #8

Closed emetik closed 2 years ago

emetik commented 2 years ago

Dear,

After compiling a M 2.4.3-p1 with 1.1.3, I encounter and issue regarding the argument type : string vs file

Interception cache generation... 6/9 [==================>---------] 66% 42 secs 610.0 MiBErrors during compilation: MagestyApps\WebImages\Model\File\Uploader Incompatible argument type: Required type: string. Actual type: \MagestyApps\WebImages\Model\File\fileId; File: /var/www/vhosts/------/src/vendor/magestyapps/module-web-images/Model/File/Uploader.php

It's compiling fine with 1.1.2

Regards

Flow09AT commented 2 years ago

Same issue on M 2.4.2 `Errors during compilation: MagestyApps\WebImages\Model\File\Uploader Incompatible argument type: Required type: string. Actual type: \MagestyApps\WebImages\Model\File\fileId; File: /srv/web/.../vendor/magestyapps/module-web-images/Model/File/Uploader.php

Total Errors Count: 1 `

robertdeboer commented 2 years ago

I can confirm as well - Magento 2 B2B Edition, version 2.4.3.0-patch1

Running ./bin/magento setup:upgrade executes fine Building dependencies fail via ./bin/magento setup:di:compile with

image

For now I simply downgraded to 1.1.2 because we do not use the Page Builder and di compiling works

darkdevelopers commented 2 years ago

I had the same in the file vendor/magestyapps/module-web-images/Model/File/Uploader.php in the Constructer is a Data Type missing. Pull Request is open with the fix. Now we must wait.

For the "quick & dirty" you must change this code snipped:

public function __construct(
        ImageHelper $imageHelper,
        $fileId,
        Mime $fileMime = null,
        DirectoryList $directoryList = null,
        DriverPool $driverPool = null,
        TargetDirectory $targetDirectory = null,
        Filesystem $filesystem = null
    ) {
        parent::__construct(
            $fileId,
            $fileMime,
            $directoryList,
            $driverPool,
            $targetDirectory,
            $filesystem
        );

        $this->imageHelper = $imageHelper;
    }

to this

 public function __construct(
        ImageHelper $imageHelper,
        string $fileId,
        Mime $fileMime = null,
        DirectoryList $directoryList = null,
        DriverPool $driverPool = null,
        TargetDirectory $targetDirectory = null,
        Filesystem $filesystem = null
    ) {
        parent::__construct(
            $fileId,
            $fileMime,
            $directoryList,
            $driverPool,
            $targetDirectory,
            $filesystem
        );

        $this->imageHelper = $imageHelper;
    }

Before the $fileId in the Constructor Params is the datatype missing. Than is it working with Magento 2.4.3-p1

MagestyApps commented 2 years ago

The issue has been fixed in v1.1.4

robertdeboer commented 2 years ago

Thank you very much for a prompt fix!