{"action":"closed","issue":{"url":"https://api.github.com/repos/magento/magento2/issues/15533","repository_url":"https://api.github.com/repos/magento/magento2","labels_url":"https://api.github.com/repos/magento/magento2/issues/15533/labels{/name}","comments_url":"https://api.github.com/repos/magento/magento2/issues/15533/comments","events_url":"https://api.github.com/repos/magento/magento2/issues/15533/events","html_url":"https://github.com/magento/magento2/issues/15533","id":326733733,"node_id":"MDU6SXNzdWUzMjY3MzM3MzM=","number":15533,"title":"Issue with removing images by using class Magento\\Catalog\\Model\\Product\\Gallery\\GalleryManagement ","user":{"login":"qsolutions-pl","id":4256191,"node_id":"MDQ6VXNlcjQyNTYxOTE=","avatar_url":"https://avatars0.githubusercontent.com/u/4256191?v=4","gravatar_id":"","url":"https://api.github.com/users/qsolutions-pl","html_url":"https://github.com/qsolutions-pl","followers_url":"https://api.github.com/users/qsolutions-pl/followers","following_url":"https://api.github.com/users/qsolutions-pl/following{/other_user}","gists_url":"https://api.github.com/users/qsolutions-pl/gists{/gist_id}","starred_url":"https://api.github.com/users/qsolutions-pl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qsolutions-pl/subscriptions","organizations_url":"https://api.github.com/users/qsolutions-pl/orgs","repos_url":"https://api.github.com/users/qsolutions-pl/repos","events_url":"https://api.github.com/users/qsolutions-pl/events{/privacy}","received_events_url":"https://api.github.com/users/qsolutions-pl/received_events","type":"User","site_admin":false},"labels":[{"id":688811200,"node_id":"MDU6TGFiZWw2ODg4MTEyMDA=","url":"https://api.github.com/repos/magento/magento2/labels/G1%20Passed","name":"G1 Passed","color":"0e8a16","default":false},{"id":686420665,"node_id":"MDU6TGFiZWw2ODY0MjA2NjU=","url":"https://api.github.com/repos/magento/magento2/labels/G2%20Passed","name":"G2 Passed","color":"0e8a16","default":false},{"id":161563561,"node_id":"MDU6TGFiZWwxNjE1NjM1NjE=","url":"https://api.github.com/repos/magento/magento2/labels/needs%20update","name":"needs update","color":"b60205","default":false}],"state":"closed","locked":false,"assignee":{"login":"engcom-backlog-nickolas","id":40755810,"node_id":"MDQ6VXNlcjQwNzU1ODEw","avatar_url":"https://avatars3.githubusercontent.com/u/40755810?v=4","gravatar_id":"","url":"https://api.github.com/users/engcom-backlog-nickolas","html_url":"https://github.com/engcom-backlog-nickolas","followers_url":"https://api.github.com/users/engcom-backlog-nickolas/followers","following_url":"https://api.github.com/users/engcom-backlog-nickolas/following{/other_user}","gists_url":"https://api.github.com/users/engcom-backlog-nickolas/gists{/gist_id}","starred_url":"https://api.github.com/users/engcom-backlog-nickolas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/engcom-backlog-nickolas/subscriptions","organizations_url":"https://api.github.com/users/engcom-backlog-nickolas/orgs","repos_url":"https://api.github.com/users/engcom-backlog-nickolas/repos","events_url":"https://api.github.com/users/engcom-backlog-nickolas/events{/privacy}","received_events_url":"https://api.github.com/users/engcom-backlog-nickolas/received_events","type":"User","site_admin":false},"assignees":[{"login":"engcom-backlog-nickolas","id":40755810,"node_id":"MDQ6VXNlcjQwNzU1ODEw","avatar_url":"https://avatars3.githubusercontent.com/u/40755810?v=4","gravatar_id":"","url":"https://api.github.com/users/engcom-backlog-nickolas","html_url":"https://github.com/engcom-backlog-nickolas","followers_url":"https://api.github.com/users/engcom-backlog-nickolas/followers","following_url":"https://api.github.com/users/engcom-backlog-nickolas/following{/other_user}","gists_url":"https://api.github.com/users/engcom-backlog-nickolas/gists{/gist_id}","starred_url":"https://api.github.com/users/engcom-backlog-nickolas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/engcom-backlog-nickolas/subscriptions","organizations_url":"https://api.github.com/users/engcom-backlog-nickolas/orgs","repos_url":"https://api.github.com/users/engcom-backlog-nickolas/repos","events_url":"https://api.github.com/users/engcom-backlog-nickolas/events{/privacy}","received_events_url":"https://api.github.com/users/engcom-backlog-nickolas/received_events","type":"User","site_admin":false}],"milestone":null,"comments":4,"created_at":"2018-05-26T12:12:05Z","updated_at":"2018-08-02T08:30:12Z","closed_at":"2018-08-02T08:30:12Z","author_association":"NONE","body":"<!---\r\n    Thank you for contributing to Magento.\r\n    To help us process this issue we recommend that you add the following information:\r\n     - Summary of the issue,\r\n     - Information on your environment,\r\n     - Steps to reproduce,\r\n     - Expected and actual results,\r\n\r\n    Please also have a look at our guidelines article before adding a new issue https://github.com/magento/magento2/wiki/Issue-reporting-guidelines\r\n-->\r\n\r\n### Preconditions\r\n<!---\r\n    Please provide as detailed information about your environment as possible.\r\n    For example Magento version, tag, HEAD, PHP & MySQL version, etc..\r\n-->\r\n1. Magento 2.2.3\r\n2. PHP 7.0.x\r\n\r\n### Steps to reproduce\r\n<!---\r\n    It is important to provide a set of clear steps to reproduce this bug.\r\n    If relevant please include code samples\r\n-->\r\n1. Create a console command and inject Magento\\Catalog\\Model\\Product\\Gallery\\GalleryManagement to constructor \r\n2. load a product model by API repository\r\n3. try to remove images using GalleryManagement class (like this)\r\n\r\n```\r\n$currentGallery = $product->getMediaGalleryEntries();\r\n    foreach ($currentGallery as $key => $entry) {\r\n        $this->galleryManagement->remove($productSku, $entry->getId());\r\n     }\r\n```\r\n\r\n### Expected result\r\n<!--- Tell us what should happen -->\r\n1. Images should be removed and records in catalog_product_entity_media_gallery_value should be removed (for image related attributes)\r\n2. You should be able to add new images to products\r\n\r\n### Actual result\r\n<!--- Tell us what happens instead -->\r\n1. Images (files are removed)\r\n2. extra records are put into catalog_product_entity_varchar with value equal **no_selection** and wrong store ID is assigned. http://i.imgur.com/e2ferng.png\r\n3. After that you cannot add a new image to that product due to problem with foreign keys:\r\n`  SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`mage2db`.`catalog_product_entity_media_gallery_value`, CONSTRAINT `CAT_PRD_ENTT_MDA_GLR_VAL_VAL_ID_CAT_PRD_ENTT_MDA_GLR_VAL_ID` FOREIGN KEY (`value_id`) REFERENCES `catalog_product), query was: INSERT INTO `catalog_product_entity_media_gallery_value` (`value_id`, `store_id`, `entity_id`, `label`, `position`, `disabled`) VALUES (?, ?, ?, ?, ?, ?)`\r\n"}}
{"actor":{"display_login":"engcom-backlog-nickolas"}}