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.55k stars 9.32k forks source link

AwsS3 PHP8 compatibility issue #35729

Closed Nuranto closed 2 years ago

Nuranto commented 2 years ago

Preconditions and environment

Steps to reproduce

I don't know how to reproduce, I find that error in production logs, but without trace.

However, it should be fixed anyway by adding a cast on $path variable, or better : manage the case where $path variable is empty or/and null

Expected result

no error

Actual result

.CRITICAL: TypeError: preg_replace(): Argument #3 ($subject) must be of type array|string, null given in /var/www/html/vendor/magento/module-aws-s3/Driver/AwsS3.php:302

Additional information

Concerned code : Magento\AwsS3\Driver\AwsS3

 public function getRealPathSafety($path)
    {
        //Removing redundant directory separators
        $path = preg_replace(
            '~(?<!:)\/\/+~',
            '/',
            $path
        );

        if (strpos($path, '/.') === false) {
            return $path;
        }

Release note

No response

Triage and priority

m2-assistant[bot] commented 2 years ago

Hi @Nuranto. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:

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:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

simonmaass commented 2 years ago

I can confirm this error on our magento 2.4.4 and php 8.1 instance. This error occurs when trying to upload an image in the product description:

image

In the system logs i can see the following error:

[2022-07-06T16:04:32.635581+00:00] .CRITICAL: TypeError: preg_replace(): Argument #3 ($subject) must be of type array|string, null given in /vendor/magento/module-aws-s3/Driver/AwsS3.php:302
Stack trace:
m2-assistant[bot] commented 2 years ago

Hi @engcom-Hotel. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-Hotel commented 2 years ago

Hello @Nuranto @simonmaass,

Thanks for the report and collaboration!

We have tried to reproduce the issue in Magento 2.4-develop instance but the issue is not reproducible for us. We are able to upload the image while adding a product description. Please refer to the below screenshot:

image

For AWS S3 is enabled. Please let us know in case we have missed anything.

Thanks

engcom-Hotel commented 2 years ago

Dear @Nuranto @simonmaass,

We have noticed that this issue has not been updated for a period of 14 Days. Hence we assume that this issue is fixed now, so we are closing it. Please raise a fresh ticket or reopen this ticket if you need more assistance on this.

Regards