Open jkenneydaniel opened 4 years ago
Hi @jkenneydaniel. 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.
@jkenneydaniel do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?
@magento give me 2.3.4 instance
Hi @jkenneydaniel. Thank you for your request. I'm working on Magento 2.3.4 instance for you
Hi @jkenneydaniel, here is your Magento instance.
Admin access: https://i-28100-2-3-4.instances.magento-community.engineering/admin_e91c
Login: 6b29d693
Password: 0ed39ee02cc2
Instance will be terminated in up to 3 hours.
Confirmed the issue:
Hi @engcom-Alfa. 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:
[ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).Details
If the issue has a valid description, the label Issue: Format is valid
will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid
appears.
[ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description
label to the issue by yourself.
[ ] 3. Add Component: XXXXX
label(s) to the ticket, indicating the components it may be related to.
[ ] 4. Verify that the issue is reproducible on 2.4-develop
branchDetails
- Add the comment @magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.4-develop
branch, please, add the label Reproduced on 2.4.x
.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
[ ] 5. Add label Issue: Confirmed
once verification is complete.
[ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
@magento give me 2.4-develop instance
Hi @engcom-Alfa. Thank you for your request. I'm working on Magento 2.4-develop instance for you
Hi @engcom-Alfa, here is your Magento instance.
Admin access: https://i-28100-2-4-develop.instances.magento-community.engineering/admin_7c8f
Login: be299754
Password: 5d86697c07be
Instance will be terminated in up to 3 hours.
Hi @jkenneydaniel. Thank you for your reporting.
Unfortunately, we are not able to reproduce this issue on a fresh 2.4-develop instance.
Manual testing scenario:
Actual Result: :heavy_check_mark: Category image src uses the full URL
@jkenneydaniel Could you take a look? Thanks!
@magento give me 2.4-develop instance
Hi @jkenneydaniel. Thank you for your request. I'm working on Magento 2.4-develop instance for you
Hi @jkenneydaniel, here is your Magento instance.
Admin access: https://i-28100-2-4-develop.instances.magento-community.engineering/admin_7596
Login: ff9671ff
Password: a51269174d52
Instance will be terminated in up to 3 hours.
@engcom-Alfa So I see in 2.4 the functionality for the image.phtml
was changed to use the Image viewmodel: https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Catalog/ViewModel/Category/Image.php
Which means that section no longer uses $category->getImageUrl()
- however on 2.3 this is not the case - so I'm a little confused, will this issue not be fixed in 2.3 but rather we'll have to wait until after 2021 for 2.4 release?
@jkenneydaniel The issue is reproducible on Magento 2.3.5-p1 composer version (reproduced only on composer versions).
Actual Result: :heavy_multiplication_x: Category image src is actually just a relative path
@magento I am working on this
Hi @jkenneydaniel Unfortunately I can not pull my fix on 2.3-develop i leave you here the link with my fix so you can create a patch and fix your issue https://github.com/magento/magento2/pull/28296/commits/a39d19dcf59aed693d85e84f5685a54d8f4fb59a
@magento give me 2.4-develop instance
Hi @Digisha-97. Thank you for your request. I'm working on Magento 2.4-develop instance for you
Hi @Digisha-97, here is your Magento instance.
Admin access: https://i-28100-2-4-develop.instances.magento-community.engineering/admin_61d1
Login: 6e193aea
Password: aa48c7a1512f
Instance will be terminated in up to 3 hours.
@magento I am working on this
Hi @Digisha-97! :wave: Thank you for joining. Please accept team invitation :point_right: here :point_left: and add your comment one more time.
@magento I am working on this But I am not able to push changes , everytime it shows Authentication failed.
Yeah, this is broken on 2.3.5p2 and I spent a day debugging code thinking there was something wrong with an extension that did a getImageUrl to get the category image for inclusion in a rich snippet on the page but was putting a partial url in the html on the page.
<meta name="twitter:image" content="/pub/media/catalog/category/m2_link_garmin_2.jpg"/>
instead of this...
<meta name="twitter:image" content="https://www.example.com/pub/media/catalog/category/m2_link_garmin_2.jpg"/>
It also appears that another extension that does a getImage (without the URL) and builds up the url using just the image name is broken too, returning the media path with the image name, resulting in this... (note the double slash in the middle)
<meta property="og:image" content="https://www.example.com/pub/media/catalog/category//pub/media/catalog/category/m2_link_garmin_2.jpg" />
instead of this...
<meta property="og:image" content="https://www.example.com/pub/media/catalog/category/m2_link_garmin_2.jpg" />
Problem seems to manifest in both getImageUrl and getImage on 2.3.5 (composer install), and appears to have begun around 2.3.4 or so and seems to persist in 2.4.0 version. This issue is compounded by the fact that the improper image file name with the relative path prefix has been stored in the image attribute of the catalog_category_entity_varchar table. Fixing the bug that causes it to be stored there incorrectly is not enough, the effect of the bug remains in the database. For those categories saved with a new image while the bug was present, you also will have to repair the category image file names stored in the database to remove the improper path prefix.
/vendor/magento/module-catalog/Model/Category/Attribute/Backend/Image.php public function beforeSave($object)
In This method below code is creating issue $value[0]['url'] = '/' . $baseMediaDir . '/' . $newImgRelativePath; $value[0]['name'] = $value[0]['url'];
Update it with $value[0]['url'] = $baseMediaDir . $newImgRelativePath; $value[0]['name'] = $value[0]['name'];
This will fix issue Do Not forget to forget to override this file from your module to avoid direct core file changes
Before official patch is ready we are using following SQL only workaround:
DROP TRIGGER catalog_category_entity_varchar_before_update;
DROP TRIGGER catalog_category_entity_varchar_before_insert;
DELIMITER //
CREATE TRIGGER catalog_category_entity_varchar_before_update
BEFORE UPDATE
ON catalog_category_entity_varchar FOR EACH ROW
BEGIN
SET NEW.value = REPLACE(NEW.value, '/media/catalog/category/', '');
END; //
DELIMITER ;
DELIMITER //
CREATE TRIGGER catalog_category_entity_varchar_before_insert
BEFORE INSERT
ON catalog_category_entity_varchar FOR EACH ROW
BEGIN
SET NEW.value = REPLACE(NEW.value, '/media/catalog/category/', '');
END; //
DELIMITER ;
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions!
Confirmed issues can't be closed automatically.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions!
Bump
On 2 Jun 2021, at 02:57, stale[bot] @.***> wrote:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions!
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.
Has this been solved in 2.4.3? Doesn't look like it.
unbelievable this is not solved yet... the patch that worked for us:
magento-2.4.2-p1-issue-28100.log
rename .log to .patch
after this you either need to save each category to assure the right way of image is stored in db or run a script to remove /media/catalog/category/ from each catalog_category_entity_varchar value where there is a image
After wasting a lot of time I have landed here and seem to have this issue in 2.4.3 CE, presumably just like @EmilyPepperman (not sure you solved it?). I'm very new to Magento and a quick attempt to apply that patch @stkrelax on 2.4.3 (using ./vendor/bin/ece-patches with the patch in a m2-hotfixeds folder) quickly gave an error about -> No such file or directory: Model/Category/Attribute/Backend/Image.php so I am sort of stuck at this point.
For reference my issue in detail; when I select an Image for a Category it shows correct in the preview/select element, but upon a page refresh the image shows as a broken link in the admin. In my case the link applied to it is https://magento.domain.com/pubhttps://magento.domain.com/media/custom-asset/category-banner-1.png and the double up on the domain name is clearly what's breaking it and I have no idea why and how to fix it at this point. I presume it's related to this issue in this thread, but I might be wrong of course.
@magento give me 2.4-develop instance with extensions magepow/categories
Hi @nahall. Thank you for your request. I'm working on Magento instance for you.
Hi @nahall, here is your Magento Instance: https://354dfdfa635d2af46f593a6373bf7ccc.instances-prod.magento-community.engineering Admin access: https://354dfdfa635d2af46f593a6373bf7ccc.instances-prod.magento-community.engineering/admin_bfa7 Login: 1c3fe936 Password: 93eca160036e
@magento give me 2.4-develop instance with extensions magepow/categories
Hi @nahall. Thank you for your request. I'm working on Magento instance for you.
Hi @nahall, here is your Magento Instance: https://354dfdfa635d2af46f593a6373bf7ccc.instances-prod.magento-community.engineering Admin access: https://354dfdfa635d2af46f593a6373bf7ccc.instances-prod.magento-community.engineering/admin_0743 Login: 51b55ec9 Password: b9d69478e866
I verified that this is still a problem. To verify, upload a category image and look at the database like:
select * from catalog_category_entity_varchar where attribute_id=37 and entity_id=2135;
The value field will be set like "/media/catalog/category/test.jpg". When it is set like this, getImageUrl() returns '/media/catalog/category/test.jpg' instead of 'https://domain.com/media/catalog/category/test.jpg'.
By editing the database to change value='test.jpg' then getImageUrl() will return 'https://domain.com/media/catalog/category/test.jpg' properly.
I also tested the patch given by stkrelax https://github.com/magento/magento2/issues/28100#issuecomment-935810263 and it fixes the problem.
How can we proceed with getting this merged?
Hi @engcom-Delta. Thank you for working on this issue. Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:
Area: XXXXX
label to the ticket, indicating the functional areas it may be related to.2.4-develop
branch@magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure. 2.4-develop
branch, please, add the label Reproduced on 2.4.x
.Hi @jkenneydaniel,
Thanks for your reporting and collaboration.
We have verified the issue in Latest 2.4.7 instance and the issue is no more reproducible.
1.Go to Admin->Catalog->Categories 2.Create a new category with an image 3.Go to Storefront and open created before the category
Go to Admin->Catalog->Categories
Create a new category with an image
Category image src uses the full URL instead of a relative path
Hence we are closing this issue.
Thanks,
Hi @nahall. Thank you for your request. I'm working on Magento instance for you.
Hi @nahall, here is your Magento Instance: https://354dfdfa635d2af46f593a6373bf7ccc.instances-prod.magento-community.engineering Admin access: https://354dfdfa635d2af46f593a6373bf7ccc.instances-prod.magento-community.engineering/admin_6666 Login: 1a2d53b7 Password: 5dc38bf3a39a
Unfortunately this is still an issue. Please note that this bug refers to "getImageUrl() returning an incorrect value".
@engcom-Delta Your above test is not calling getImageUrl() in that default Luba template.
You need to modify a template file to call getImageUrl(). Doing so I just verified on 2.4.7 that the URL being returned in this case is relative, without the domain name. The above patch is needed to properly fix this.
Please reopen this as verified for 2.4.7. Thank you.
Hi @nahall ,
Thanks for your input on this issue.
We are reopening this ticket as per your above comment.
Thanks,
Hi @engcom-November. 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:
Area: XXXXX
label to the ticket, indicating the functional areas it may be related to.2.4-develop
branch@magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure. 2.4-develop
branch, please, add the label Reproduced on 2.4.x
.Issue: Confirmed
once verification is complete. Hello @nahall,
Thank you for the input.
Verified this on 2.4-develop.
I have modified the template file to call getImageUrl()
, as you can see in the below image:
It can be seen that the image is being rendered with relative path.
The getImageUrl()
method returns relative path of the image.
Hence this issue can be confirmed.
Thank you.
:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-12016 is successfully created for this GitHub issue.
Preconditions (*)
Steps to reproduce (*)
Expected result (*)
Actual result (*)
Additional Info
When uploading an image to categories, it would be expected that when loaded on the frontend the category image URL is loaded so that when the media URL is set (i.e. for CDN usage) - the full URL is used to load the image. This is not the case however because of a change introduced in commit 3c3acd75674039f38ee65d81e8daaa9cbb81fadb where it attempts to determine the path of the image value either being relative or absolute. Considering the backend model for the image attribute is using what would be considered an absolute path, it is simply returning the value without prepending the media URL to the file path.