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

Image filename not necessarily set when logging file not found error #32446

Open chris-pook opened 3 years ago

chris-pook commented 3 years ago

Preconditions (*)

  1. Magento 2.4.2

Steps to reproduce (*)

  1. In extension code use \Magento\Framework\Image\Factory::create($filePath) where $filePath is not a valid file.
  2. View var/log/exception.log. Filepath is empty in exception log file.

Description (*)

This appears to be a problem with the Magento Framework GD2 library assuming $this->_fileName has been set where it may not necessarily be the case.

https://github.com/magento/magento2/blob/2.4-develop/lib/internal/Magento/Framework/Image/Adapter/Gd2.php#L66

The file_exists check is on $fileName (which does have a valid value in the bug scenario here), so I would expect the exception message to use the same value for consistency and to log the correct value.

Expected result (*)

  1. There should be a log entry: main.ERROR: File "filePath" does not exist.

Actual result (*)

  1. There is a log entry: main.ERROR: File "" does not exist.
  2. The file path is empty and it is not clear what file was attempted to be found.
m2-assistant[bot] commented 3 years ago

Hi @chris-pook. Thank you for your report. To help us process this issue please make sure that you provided the following information:

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

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

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


: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, please join the Community Contributions Triage session to discuss the appropriate ticket.

:movie_camera: You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

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

chris-pook commented 3 years ago

This appears to be a problem with the Magento Framework GD2 library assuming $this->_fileName has been set where it may not necessarily be the case.

https://github.com/magento/magento2/blob/2.4-develop/lib/internal/Magento/Framework/Image/Adapter/Gd2.php#L66

The file_exists check is on $fileName (which does have a valid value in the bug scenario here), so I would expect the exception message to use the same value for consistency and to log the correct value.

m2-assistant[bot] commented 3 years ago

Hi @engcom-Lima. 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-Lima commented 3 years ago

Verified the issue on Magento 2.4-develop branch and the issue is reproducible:

  1. Found $this->_fileName to be written while trying to log exception. File: lib/internal/Magento/Framework/Image/Adapter/Gd2.php
  2. Filepath is empty in exception log file.
github-jira-sync-bot commented 3 years ago

Unfortunately, not enough information was provided to create a Jira ticket. Please make sure you added the following label(s): Reproduced on 2.4.x, ^Area:.*

Once all required labels are present, please add Issue: Confirmed label again.

github-jira-sync-bot commented 3 years ago

Unfortunately, not enough information was provided to create a Jira ticket. Please make sure you added the following label(s): Reproduced on 2.4.x, ^Area:.*

Once all required labels are present, please add Issue: Confirmed label again.

github-jira-sync-bot commented 3 years ago

:white_check_mark: Jira issue https://jira.corp.magento.com/browse/AC-701 is successfully created for this GitHub issue.

m2-assistant[bot] commented 3 years ago

:white_check_mark: Confirmed by @engcom-Lima. Thank you for verifying the issue.
Issue Available: @engcom-Lima, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

github-jira-sync-bot commented 3 years ago

:x: Cannot export the issue. This GitHub issue is already linked to Jira issue(s): https://jira.corp.magento.com/browse/AC-701

github-jira-sync-bot commented 3 years ago

:x: Cannot export the issue. This GitHub issue is already linked to Jira issue(s): https://jira.corp.magento.com/browse/AC-701