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

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.

[code]ini_set(‘display_errors’, 1);[/code]

Lets see what the logs say:[code]PHP Fatal error: Undefined class constant ‘TYPE_CONDITION’ in /home/dev/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php on line 296[/code]

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

[code] if (!empty($conditionSql)) { $this->getSelect()->where($conditionSql, null, Varien_Db_Select::TYPE_CONDITION); } else { Mage::throwException(‘Invalid attribute identifier for filter (‘.get_class($attribute).’)’); }

return $this; }[/code]

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:

[code]class Varien_Db_Select extends Zend_Db_Select{ const TYPE_CONDITION = ‘TYPE_CONDITION’;

const STRAIGHT_JOIN_ON = ‘straight_join’; const STRAIGHT_JOIN = ‘straightjoin’; const SQL_STRAIGHT_JOIN = ‘STRAIGHT_JOIN’;[/code]

There it is.

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