Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.3] magento catalog:images:resize now Database Media Storage mode aware (Again!) #23913

Merged
merged 1 commit into from
Aug 8, 2019
Merged

Conversation

gwharton
Copy link
Contributor

@gwharton gwharton commented Jul 26, 2019

Description (*)

Changes introduced in MC-17218: php bin/magento catalog:image:resize error if image is missing (6a694a9) broke the functionality that was previously fixed in PR #23598 which means that the catalog:images:resize command no longer functions as expected in database media storage mode when the file does not exist locally.

This PR corrects that.

Fixed Issues (if relevant)

  1. Database Media Storage : php bin/magento catalog:images:resize fails to process images from database if not present locally (Again!) #23911 : Database Media Storage : php bin/magento catalog:images:resize fails to process images from database if not present locally (Again!)

Manual testing scenarios (*)

Test Scenareo 1 - Normal Local Filesystem Mode

Deploy 2.3-develop
Catalog -> Products
    Add Product
        Name = Test
        Price = 111
        Images and Videos
            Upload image "a.jpg"
        Save & Close

Verify image exists in filesystem

www-data@dev:~/dev1$ find pub/media -name *.jpg
pub/media/catalog/product/a/_/a.jpg
pub/media/catalog/product/cache/44df7a05cd543e344cd804fe1b7d03f9/a/_/a.jpg
pub/media/catalog/product/cache/05700e45ea23c173c607a07e57b31f14/a/_/a.jpg
pub/media/catalog/product/cache/c8b969a5db7b942d7c1ade87824d9fb5/a/_/a.jpg
pub/media/catalog/product/cache/8e4e1244680d07f5e23aac7a094b5ced/a/_/a.jpg
pub/media/catalog/product/cache/a73dbc1e401544f4a37404df685e56cb/a/_/a.jpg
pub/media/catalog/product/cache/565aa9b4f47b76913eb467f409e405a5/a/_/a.jpg
pub/media/catalog/product/cache/cea075b4acfaff3655c89768cb020a48/a/_/a.jpg
pub/media/catalog/product/cache/43b1d9aa96ae2ac357312f5e6f063ebb/a/_/a.jpg
pub/media/catalog/product/cache/2ac5ce82894659a1de39122f4ce5d785/a/_/a.jpg
pub/media/catalog/product/cache/efabf5d6ed985597d80c0c750d8a1488/a/_/a.jpg
pub/media/catalog/product/cache/927837b6328eeac4b65eb4a0cfed0c8d/a/_/a.jpg
pub/media/catalog/product/cache/42f22ea9d6381753b704516955973a32/a/_/a.jpg
pub/media/catalog/product/cache/a51cda8ad4b127ab6c26bcd10cb133c0/a/_/a.jpg
pub/media/catalog/product/cache/7bd4e189723785d9abc492cb6290143f/a/_/a.jpg
pub/media/catalog/product/cache/f6642d3506661139d447769aff06b0d0/a/_/a.jpg
pub/media/catalog/product/cache/82b662b5f44528d0717ba6faf8db557a/a/_/a.jpg
pub/media/catalog/product/cache/2b8fe12c3ac8320dcc99b17d8210084a/a/_/a.jpg
pub/media/catalog/product/cache/962b6a57cf93a71105bd781a2d0b61fc/a/_/a.jpg
pub/media/catalog/product/cache/9527c85c0eb98f85df3f97110b56ccfc/a/_/a.jpg
pub/media/catalog/product/cache/4ee5eeb329f91d52118bd6ece2f76036/a/_/a.jpg
www-data@dev:~/dev1$

Regenerate images

www-data@dev:~/dev1$ php bin/magento catalog:images:resize
1/1 [============================] 100% < 1 sec 46.2 MiB        | /a/_/a.jpg
Product images resized successfully
www-data@dev:~/dev1$

Delete pub/media/catalog folder

www-data@dev:~/dev1$ rm -rf pub/media/catalog/
www-data@dev:~/dev1$

Regenerate images

www-data@dev:~/dev1$ php bin/magento catalog:images:resize
1/1 [============================] 100% < 1 sec 44.2 MiB        | /a/_/a.jpg
Product images resized with errors:
Cannot resize image "/var/www/dev1/pub/media/catalog/product/a/_/a.jpg" - original image not found
www-data@dev:~/dev1$

This is the expected behaviour. The image fails to be processed because it doesnt exist. The resize command fails gracefully with the correct error message, as introduced in MC-17218.

Test Scenareo 2 - Database Media Storage Mode

Deploy 2.3-develop
Stores -> Configuration
    Advanced -> System
        Storage Configuration for Media
            Media Storage = Database
            Select Media Database = default_setup
            Synchronize
            Save Config
Catalog -> Products
    Add Product
        Name = Test
        Price = 111
        Images and Videos
            Upload image "a.jpg"
        Save & Close

Verify image exists in filesystem

www-data@dev:~/dev1$ find pub/media -name *.jpg
pub/media/catalog/product/a/_/a.jpg
pub/media/catalog/product/cache/44df7a05cd543e344cd804fe1b7d03f9/a/_/a.jpg
pub/media/catalog/product/cache/05700e45ea23c173c607a07e57b31f14/a/_/a.jpg
pub/media/catalog/product/cache/c8b969a5db7b942d7c1ade87824d9fb5/a/_/a.jpg
pub/media/catalog/product/cache/8e4e1244680d07f5e23aac7a094b5ced/a/_/a.jpg
pub/media/catalog/product/cache/a73dbc1e401544f4a37404df685e56cb/a/_/a.jpg
pub/media/catalog/product/cache/565aa9b4f47b76913eb467f409e405a5/a/_/a.jpg
pub/media/catalog/product/cache/cea075b4acfaff3655c89768cb020a48/a/_/a.jpg
pub/media/catalog/product/cache/43b1d9aa96ae2ac357312f5e6f063ebb/a/_/a.jpg
pub/media/catalog/product/cache/2ac5ce82894659a1de39122f4ce5d785/a/_/a.jpg
pub/media/catalog/product/cache/efabf5d6ed985597d80c0c750d8a1488/a/_/a.jpg
pub/media/catalog/product/cache/927837b6328eeac4b65eb4a0cfed0c8d/a/_/a.jpg
pub/media/catalog/product/cache/42f22ea9d6381753b704516955973a32/a/_/a.jpg
pub/media/catalog/product/cache/a51cda8ad4b127ab6c26bcd10cb133c0/a/_/a.jpg
pub/media/catalog/product/cache/7bd4e189723785d9abc492cb6290143f/a/_/a.jpg
pub/media/catalog/product/cache/f6642d3506661139d447769aff06b0d0/a/_/a.jpg
pub/media/catalog/product/cache/82b662b5f44528d0717ba6faf8db557a/a/_/a.jpg
pub/media/catalog/product/cache/2b8fe12c3ac8320dcc99b17d8210084a/a/_/a.jpg
pub/media/catalog/product/cache/962b6a57cf93a71105bd781a2d0b61fc/a/_/a.jpg
pub/media/catalog/product/cache/9527c85c0eb98f85df3f97110b56ccfc/a/_/a.jpg
pub/media/catalog/product/cache/4ee5eeb329f91d52118bd6ece2f76036/a/_/a.jpg
www-data@dev:~/dev1$

Verify image exists in database

mysql> select filename,directory from media_storage_file_storage;
+----------------------------------+------------------------------------------------------------+
| filename                         | directory                                                  |
+----------------------------------+------------------------------------------------------------+
| preview_image_5d3b1f777bdc2.jpeg | theme/preview                                              |
| preview_image_5d3b1f77876c4.jpeg | theme/preview                                              |
| a.jpg                            | catalog/product/a/_                                        |
| a.jpg                            | catalog/product/cache/9527c85c0eb98f85df3f97110b56ccfc/a/_ |
| a.jpg                            | catalog/product/cache/05700e45ea23c173c607a07e57b31f14/a/_ |
| a.jpg                            | catalog/product/cache/f6642d3506661139d447769aff06b0d0/a/_ |
| a.jpg                            | catalog/product/cache/8e4e1244680d07f5e23aac7a094b5ced/a/_ |
| a.jpg                            | catalog/product/cache/a51cda8ad4b127ab6c26bcd10cb133c0/a/_ |
| a.jpg                            | catalog/product/cache/42f22ea9d6381753b704516955973a32/a/_ |
| a.jpg                            | catalog/product/cache/7bd4e189723785d9abc492cb6290143f/a/_ |
| a.jpg                            | catalog/product/cache/927837b6328eeac4b65eb4a0cfed0c8d/a/_ |
| a.jpg                            | catalog/product/cache/44df7a05cd543e344cd804fe1b7d03f9/a/_ |
| a.jpg                            | catalog/product/cache/cea075b4acfaff3655c89768cb020a48/a/_ |
| a.jpg                            | catalog/product/cache/565aa9b4f47b76913eb467f409e405a5/a/_ |
| a.jpg                            | catalog/product/cache/82b662b5f44528d0717ba6faf8db557a/a/_ |
| a.jpg                            | catalog/product/cache/43b1d9aa96ae2ac357312f5e6f063ebb/a/_ |
| a.jpg                            | catalog/product/cache/2b8fe12c3ac8320dcc99b17d8210084a/a/_ |
| a.jpg                            | catalog/product/cache/c8b969a5db7b942d7c1ade87824d9fb5/a/_ |
| a.jpg                            | catalog/product/cache/efabf5d6ed985597d80c0c750d8a1488/a/_ |
| a.jpg                            | catalog/product/cache/4ee5eeb329f91d52118bd6ece2f76036/a/_ |
| a.jpg                            | catalog/product/cache/a73dbc1e401544f4a37404df685e56cb/a/_ |
| a.jpg                            | catalog/product/cache/2ac5ce82894659a1de39122f4ce5d785/a/_ |
| a.jpg                            | catalog/product/cache/962b6a57cf93a71105bd781a2d0b61fc/a/_ |
+----------------------------------+------------------------------------------------------------+
23 rows in set (0.00 sec)

mysql>

Regenerate images

www-data@dev:~/dev1$ php bin/magento catalog:images:resize
1/1 [============================] 100% < 1 sec 44.2 MiB        | /a/_/a.jpg
Product images resized successfully
www-data@dev:~/dev1$

Delete pub/media/catalog folder

www-data@dev:~/dev1$ rm -rf pub/media/catalog/
www-data@dev:~/dev1$

Regenerate images

www-data@dev:~/dev1$ php bin/magento catalog:images:resize
1/1 [============================] 100% < 1 sec 44.2 MiB        | /a/_/a.jpg
Product images resized successfully
www-data@dev:~/dev1$

Verify image exists in filesystem

www-data@dev:~/dev1$ find pub/media -name *.jpg
pub/media/catalog/product/a/_/a.jpg
pub/media/catalog/product/cache/44df7a05cd543e344cd804fe1b7d03f9/a/_/a.jpg
pub/media/catalog/product/cache/05700e45ea23c173c607a07e57b31f14/a/_/a.jpg
pub/media/catalog/product/cache/c8b969a5db7b942d7c1ade87824d9fb5/a/_/a.jpg
pub/media/catalog/product/cache/8e4e1244680d07f5e23aac7a094b5ced/a/_/a.jpg
pub/media/catalog/product/cache/a73dbc1e401544f4a37404df685e56cb/a/_/a.jpg
pub/media/catalog/product/cache/565aa9b4f47b76913eb467f409e405a5/a/_/a.jpg
pub/media/catalog/product/cache/cea075b4acfaff3655c89768cb020a48/a/_/a.jpg
pub/media/catalog/product/cache/43b1d9aa96ae2ac357312f5e6f063ebb/a/_/a.jpg
pub/media/catalog/product/cache/2ac5ce82894659a1de39122f4ce5d785/a/_/a.jpg
pub/media/catalog/product/cache/efabf5d6ed985597d80c0c750d8a1488/a/_/a.jpg
pub/media/catalog/product/cache/927837b6328eeac4b65eb4a0cfed0c8d/a/_/a.jpg
pub/media/catalog/product/cache/42f22ea9d6381753b704516955973a32/a/_/a.jpg
pub/media/catalog/product/cache/a51cda8ad4b127ab6c26bcd10cb133c0/a/_/a.jpg
pub/media/catalog/product/cache/7bd4e189723785d9abc492cb6290143f/a/_/a.jpg
pub/media/catalog/product/cache/f6642d3506661139d447769aff06b0d0/a/_/a.jpg
pub/media/catalog/product/cache/82b662b5f44528d0717ba6faf8db557a/a/_/a.jpg
pub/media/catalog/product/cache/2b8fe12c3ac8320dcc99b17d8210084a/a/_/a.jpg
pub/media/catalog/product/cache/962b6a57cf93a71105bd781a2d0b61fc/a/_/a.jpg
pub/media/catalog/product/cache/9527c85c0eb98f85df3f97110b56ccfc/a/_/a.jpg
pub/media/catalog/product/cache/4ee5eeb329f91d52118bd6ece2f76036/a/_/a.jpg
www-data@dev:~/dev1$

This is the expected behaviour. The resize command completed correctly after downloading the image from the database to the local storage for processing.

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

@m2-assistant
Copy link

m2-assistant bot commented Jul 26, 2019

Hi @gwharton. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.3-develop instance - deploy vanilla Magento instance

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

…ase if it does not exist locally. New integration test.
@magento-engcom-team
Copy link
Contributor

Hi @ihor-sviziev, thank you for the review.
ENGCOM-5498 has been created to process this Pull Request
✳️ @ihor-sviziev, could you please add one of the following labels to the Pull Request?

Label Description
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests
Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests

@ihor-sviziev ihor-sviziev added the Auto-Tests: Covered All changes in Pull Request is covered by auto-tests label Jul 27, 2019
@engcom-Alfa engcom-Alfa self-assigned this Jul 29, 2019
@engcom-Alfa
Copy link
Contributor

✔️ QA Passed

@engcom-Foxtrot engcom-Foxtrot self-assigned this Jul 29, 2019
taskula pushed a commit to Hypernova-Oy/magento2 that referenced this pull request Aug 8, 2019
@magento-engcom-team magento-engcom-team merged commit 7b2f66c into magento:2.3-develop Aug 8, 2019
@m2-assistant
Copy link

m2-assistant bot commented Aug 8, 2019

Hi @gwharton, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants