Skip to content
New issue

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

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

Already on GitHub? # to your account

Fixed undefined array index label_use_default in Mage_Catalog_Model_Product_Attribute_Backend_Media #4024

Merged
merged 3 commits into from
Jun 5, 2024

Conversation

fballiano
Copy link
Contributor

Fixes #4023

There could be other ways to fix this problem but I would initialize those 2 array elements

@kiatng
Copy link
Contributor

kiatng commented Jun 4, 2024

Why not use empty() to check:

// from
$data['label']    = ($image['label'] === null || $image["label_use_default"]) ? null : $image['label'];
// to
$data['label']    = ($image['label'] === null || empty($image["label_use_default"])) ? null : $image['label'];

@fballiano
Copy link
Contributor Author

@kiatng if i'm not mistaken that wouldn't cover the "store id = 0" situation and, when the conditions are in || but not all positive they automatically become hard to read to me :-)

@kiatng
Copy link
Contributor

kiatng commented Jun 5, 2024

@fballiano You are right. I got confused with if ($storeId === 0) $image["label_use_default"] = false;. We want store 0 to have the default label, but in order to make sure of that, $image["label_use_default"] needs to be set to false, regardless of its prior value. It's counter intuitive.

when the conditions are in || but not all positive

It's hard as hell for me too.

@fballiano fballiano merged commit 2a9dcb2 into OpenMage:main Jun 5, 2024
17 checks passed
@fballiano fballiano deleted the imagelabel branch June 5, 2024 10:16
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Component: Catalog Relates to Mage_Catalog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error when saving product with image without description
3 participants