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

EAV Config Cache followup: select non-existent attribute exception #3038

Merged
merged 1 commit into from
Mar 3, 2023
Merged

EAV Config Cache followup: select non-existent attribute exception #3038

merged 1 commit into from
Mar 3, 2023

Conversation

davidhiendl
Copy link
Contributor

This PR fixes an exception that is trigger when a collection selects a non-existent attribute because getAttribute() no longer returns an empty model for non-existent attributes.

Related Pull Requests

#2993

Manual testing scenarios (*)

$productCollections = Mage::getResourceModel("catalog/product_collection");
$productCollections->addAttributeToSelect("test_does_not_exist");

@github-actions github-actions bot added the Component: Eav Relates to Mage_Eav label Feb 22, 2023
@davidhiendl
Copy link
Contributor Author

@luigifab Followup fix for your issue in #2993

@@ -438,6 +438,10 @@ public function addAttributeToSelect($attribute, $joinType = false)
} else {
$attrInstance = Mage::getSingleton('eav/config')
->getAttribute($this->getEntity()->getType(), $attribute);
// failure to resolve an attribute from the eav config implies it does not exist
if (empty($attrInstance)) {
return $this;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldnt we log situations like this? Typo in the attribute name is a bug, a deweloper would like to know about

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not necessarily a bug, it could just be a deleted attribute that was referenced somewhere. But perhaps throw an exception in developer mode and log it in production mode. Let me know what you prefer and I defer to you and make the change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me, nothing, or only a log when dev mode is enabled.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also don't care, if an attribute disappears there will be an errors in some template or some other code without the need to do anything here, although maybe it would be a bit cleaner

@fballiano fballiano merged commit 6352b46 into OpenMage:20.0 Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Eav Relates to Mage_Eav
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants