Magento: PHP Fatal error Undefined class constant ‘TYPE_CONDITION’ Abstract.php on line 296

Posted — Dec 27, 2014

This is what happens when you don’t pay attention. I was working on a project that started out when Magento 1.4.1.1 was the latest stable version. There is a bit of development left, but I decided to upgrade the install to 1.4.2 via subversion. I go get some coffee, come back, and assume the upgrade is done.

Then I try to load the homepage, and I get a blank screen. Eh, ok. Time to display errors by commenting the following line in index.php.

1
ini\_set(‘display\_errors’, 1);

Lets see what the logs say:

1
PHP Fatal error: Undefined class constant ‘TYPE\_CONDITION’ in /home/dev/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php on line 296

Well, what exactly is the code throwing this error? In Abstract.php:

1
2
3
 if (!empty($conditionSql)) { 
     $this->
     getSelect()-&gt;where($conditionSql, null, Varien\_Db\_Select::TYPE\_CONDITION); } else { Mage::throwException(‘Invalid attribute identifier for filter (.get\_class($attribute).)); }<br /><br /> return $this; }

How can Varien_Db_Select::TYPE_CONDITION not exist? I looked at my Varien/DB/Select.php and there was no TYPE_CONDITION. Then I looked at Varien_Db_Select in the Magento docs, and it was there. Weird.

Then I looked back at the terminal which was doing Subversion update, and noticed that there was an error. Apparently my Internet connection had died and the update didn’t complete. Ugh.

After restarting the Subversion update, I look at Varien_Db_Select:

1
class Varien\_Db\_Select extends Zend\_Db\_Select{ const TYPE\_CONDITION = ‘TYPE\_CONDITION’;<br /><br /> const STRAIGHT\_JOIN\_ON = ‘straight\_join’; const STRAIGHT\_JOIN = ‘straightjoin’; const SQL\_STRAIGHT\_JOIN = ‘STRAIGHT\_JOIN’;

There it is.

Moral of the story. Make sure your updates actually complete before making such an assumption.