{"action":"closed","issue":{"url":"https://api.github.com/repos/webbhuset/bugfix/issues/21","repository_url":"https://api.github.com/repos/webbhuset/bugfix","labels_url":"https://api.github.com/repos/webbhuset/bugfix/issues/21/labels{/name}","comments_url":"https://api.github.com/repos/webbhuset/bugfix/issues/21/comments","events_url":"https://api.github.com/repos/webbhuset/bugfix/issues/21/events","html_url":"https://github.com/webbhuset/bugfix/issues/21","id":181171664,"number":21,"title":"Subselect condition on Shopping Cart Price Rules causes \"Fatal error: Stack overflow\".","user":{"login":"Fabiansamuelsson","id":17568858,"avatar_url":"https://avatars.githubusercontent.com/u/17568858?v=3","gravatar_id":"","url":"https://api.github.com/users/Fabiansamuelsson","html_url":"https://github.com/Fabiansamuelsson","followers_url":"https://api.github.com/users/Fabiansamuelsson/followers","following_url":"https://api.github.com/users/Fabiansamuelsson/following{/other_user}","gists_url":"https://api.github.com/users/Fabiansamuelsson/gists{/gist_id}","starred_url":"https://api.github.com/users/Fabiansamuelsson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fabiansamuelsson/subscriptions","organizations_url":"https://api.github.com/users/Fabiansamuelsson/orgs","repos_url":"https://api.github.com/users/Fabiansamuelsson/repos","events_url":"https://api.github.com/users/Fabiansamuelsson/events{/privacy}","received_events_url":"https://api.github.com/users/Fabiansamuelsson/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-10-05T14:30:53Z","updated_at":"2016-10-06T14:45:21Z","closed_at":"2016-10-06T14:45:21Z","body":"Using the subselect condition on Shopping Cart Price Rules causes \"Fatal error: Stack overflow\".\r\n\r\nLooking at  the `validate` method at row 116 in the class `Mage_SalesRule_Model_Rule_Condition_Product_Subselect`:\r\n```php\r\n    ...more code...\r\n    foreach ($object->getQuote()->getAllVisibleItems() as $item) {\r\n        if (parent::validate($item)) {\r\n            $total += $item->getData($attr);\r\n        }\r\n    }\r\n   ...more code....\r\n```\r\nHere the `parent::validate` method is called for all items in the qoute, parent in this case is `Mage_SalesRule_Model_Rule_Condition_Product_Combine`, so take a look at it's validate method on row 208:\r\n```php\r\n    public function validate(Varien_Object $object)\r\n    {\r\n        /** @var Mage_Catalog_Model_Product $product */\r\n        $product = $object->getProduct();\r\n        if (!($product instanceof Mage_Catalog_Model_Product)) {\r\n            $product = Mage::getModel('catalog/product')->load($object->getProductId());\r\n        }\r\n\r\n        $valid = parent::validate($object);\r\n        if (!$valid && $product->getTypeId() == Mage_Catalog_Model_Product_Type_Configurable::TYPE_CODE) {\r\n            $children = $object->getChildren();\r\n            $valid = $children && $this->validate($children[0]);\r\n        }\r\n\r\n        return $valid;\r\n    }\r\n```\r\nIf the condition is not met and the item is a configurable product `$this->validate($children[0])` is called, and in the subselect casse `$this` is the ``Mage_SalesRule_Model_Rule_Condition_Product_Subselect` class which will call `parent::validate()` for all items in the quote, and since the qoute hasn't changed since the first time it was called we have a endless loop causing stack overflow."}}
{"actor":{"display_login":"albtje"}}