1

I'm trying to resolve this issue that only occurs when I click any link in my menu. At first after clicking, I get an error page entitled There has been an error processing your request, but refreshes the same page after that renders the page it should.

After inspecting the error number in /magentoroot/var/report I see the following stack trace which doesn't appear to be the fault of any of the third-party extensions:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1, query was: SELECT `catalog_category_entity`.* FROM `catalog_category_entity` WHERE (entity_id =)

Trace:
#0 /var/www/magento/includes/src/Varien_Db_Statement_Pdo_Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 /var/www/magento/includes/src/__default.php(64952): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /var/www/magento/includes/src/__default.php(54273): Zend_Db_Statement->execute(Array)
#3 /var/www/magento/includes/src/__default.php(55316): Zend_Db_Adapter_Abstract->query('SELECT `catalog...', Array)
#4 /var/www/magento/includes/src/__default.php(56176): Zend_Db_Adapter_Pdo_Abstract->query('SELECT `catalog...', Array)
#5 /var/www/magento/includes/src/__default.php(54549): Varien_Db_Adapter_Pdo_Mysql->query(Object(Varien_Db_Select), Array)
#6 /var/www/magento/includes/src/__default.php(42637): Zend_Db_Adapter_Abstract->fetchRow(Object(Varien_Db_Select))
#7 /var/www/magento/includes/src/__catalog.php(4819): Mage_Eav_Model_Entity_Abstract->load(Object(Mage_Catalog_Model_Category), Object(Mage_Catalog_Model_Category), NULL)
#8 /var/www/magento/includes/src/__default.php(5899): Mage_Catalog_Model_Resource_Abstract->load(Object(Mage_Catalog_Model_Category), Object(Mage_Catalog_Model_Category), NULL)
#9 /var/www/magento/includes/src/Mage_Catalog_Block_Product_List.php(80): Mage_Core_Model_Abstract->load(Object(Mage_Catalog_Model_Category))
#10 /var/www/magento/includes/src/Mage_Catalog_Block_Product_List.php(142): Mage_Catalog_Block_Product_List->_getProductCollection()
#11 /var/www/magento/includes/src/__default.php(2612): Mage_Catalog_Block_Product_List->_beforeToHtml()
#12 /var/www/magento/includes/src/__default.php(2331): Mage_Core_Block_Abstract->toHtml()
#13 /var/www/magento/includes/src/__default.php(2275): Mage_Core_Block_Abstract->_getChildHtml('product_list', true)
#14 /var/www/magento/includes/src/Mage_Catalog_Block_Category_View.php(90): Mage_Core_Block_Abstract->getChildHtml('product_list')
#15 /var/www/magento/app/design/frontend/polar/default/template/catalog/category/view.phtml(63): Mage_Catalog_Block_Category_View->getProductListHtml()
#16 /var/www/magento/includes/src/__default.php(3408): include('/var/www/magent...')
#17 /var/www/magento/includes/src/__default.php(3439): Mage_Core_Block_Template->fetchView('frontend/polar/...')
#18 /var/www/magento/includes/src/__default.php(3453): Mage_Core_Block_Template->renderView()
#19 /var/www/magento/includes/src/__default.php(2613): Mage_Core_Block_Template->_toHtml()
#20 /var/www/magento/includes/src/__default.php(13677): Mage_Core_Block_Abstract->toHtml()
#21 /var/www/magento/includes/src/__default.php(2613): Mage_Core_Block_Text_List->_toHtml()
#22 /var/www/magento/includes/src/__default.php(2331): Mage_Core_Block_Abstract->toHtml()
#23 /var/www/magento/includes/src/__default.php(2275): Mage_Core_Block_Abstract->_getChildHtml('content', true)
#24 /var/www/magento/app/design/frontend/polar/default/template/page/2columns-left.phtml(53): Mage_Core_Block_Abstract->getChildHtml('content')
#25 /var/www/magento/includes/src/__default.php(3408): include('/var/www/magent...')
#26 /var/www/magento/includes/src/__default.php(3439): Mage_Core_Block_Template->fetchView('frontend/polar/...')
#27 /var/www/magento/includes/src/__default.php(3453): Mage_Core_Block_Template->renderView()
#28 /var/www/magento/includes/src/__default.php(2613): Mage_Core_Block_Template->_toHtml()
#29 /var/www/magento/includes/src/__default.php(28278): Mage_Core_Block_Abstract->toHtml()
#30 /var/www/magento/includes/src/__default.php(14070): Mage_Core_Model_Layout->getOutput()
#31 /var/www/magento/app/code/core/Mage/Catalog/controllers/CategoryController.php(161): Mage_Core_Controller_Varien_Action->renderLayout()
#32 /var/www/magento/includes/src/__default.php(14098): Mage_Catalog_CategoryController->viewAction()
#33 /var/www/magento/includes/src/__default.php(18482): Mage_Core_Controller_Varien_Action->dispatch('view')
#34 /var/www/magento/includes/src/__default.php(18016): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#35 /var/www/magento/includes/src/__default.php(20808): Mage_Core_Controller_Varien_Front->dispatch()
#36 /var/www/magento/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#37 /var/www/magento/index.php(87): Mage::run('', 'store')
#38 {main}

Any ideas on where I should start, and has anybody experienced this particular type of error?

UPDATE

After disabling compilation as per Tyler's suggestion below, I am still getting an error, but attached is the stack trace:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1, query was: SELECT `catalog_category_entity`.* FROM `catalog_category_entity` WHERE (entity_id =)

Trace:
#0 /var/www/magento/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 /var/www/magento/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /var/www/magento/lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#3 /var/www/magento/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT `catalog...', Array)
#4 /var/www/magento/lib/Varien/Db/Adapter/Pdo/Mysql.php(428): Zend_Db_Adapter_Pdo_Abstract->query('SELECT `catalog...', Array)
#5 /var/www/magento/lib/Zend/Db/Adapter/Abstract.php(756): Varien_Db_Adapter_Pdo_Mysql->query(Object(Varien_Db_Select), Array)
#6 /var/www/magento/app/code/core/Mage/Eav/Model/Entity/Abstract.php(943): Zend_Db_Adapter_Abstract->fetchRow(Object(Varien_Db_Select))
#7 /var/www/magento/app/code/core/Mage/Catalog/Model/Resource/Abstract.php(698): Mage_Eav_Model_Entity_Abstract->load(Object(Mage_Catalog_Model_Category), Object(Mage_Catalog_Model_Category), NULL)
#8 /var/www/magento/app/code/core/Mage/Core/Model/Abstract.php(225): Mage_Catalog_Model_Resource_Abstract->load(Object(Mage_Catalog_Model_Category), Object(Mage_Catalog_Model_Category), NULL)
#9 /var/www/magento/app/code/core/Mage/Catalog/Block/Product/List.php(80): Mage_Core_Model_Abstract->load(Object(Mage_Catalog_Model_Category))
#10 /var/www/magento/app/code/core/Mage/Catalog/Block/Product/List.php(142): Mage_Catalog_Block_Product_List->_getProductCollection()
#11 /var/www/magento/app/code/core/Mage/Core/Block/Abstract.php(918): Mage_Catalog_Block_Product_List->_beforeToHtml()
#12 /var/www/magento/app/code/core/Mage/Core/Block/Abstract.php(637): Mage_Core_Block_Abstract->toHtml()
#13 /var/www/magento/app/code/core/Mage/Core/Block/Abstract.php(581): Mage_Core_Block_Abstract->_getChildHtml('product_list', true)
#14 /var/www/magento/app/code/core/Mage/Catalog/Block/Category/View.php(90): Mage_Core_Block_Abstract->getChildHtml('product_list')
#15 /var/www/magento/app/design/frontend/polar/default/template/catalog/category/view.phtml(63): Mage_Catalog_Block_Category_View->getProductListHtml()
#16 /var/www/magento/app/code/core/Mage/Core/Block/Template.php(241): include('/var/www/magent...')
#17 /var/www/magento/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('frontend/polar/...')
#18 /var/www/magento/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()
#19 /var/www/magento/app/code/core/Mage/Core/Block/Abstract.php(919): Mage_Core_Block_Template->_toHtml()
#20 /var/www/magento/app/code/core/Mage/Core/Block/Text/List.php(43): Mage_Core_Block_Abstract->toHtml()
#21 /var/www/magento/app/code/core/Mage/Core/Block/Abstract.php(919): Mage_Core_Block_Text_List->_toHtml()
#22 /var/www/magento/app/code/core/Mage/Core/Block/Abstract.php(637): Mage_Core_Block_Abstract->toHtml()
#23 /var/www/magento/app/code/core/Mage/Core/Block/Abstract.php(581): Mage_Core_Block_Abstract->_getChildHtml('content', true)
#24 /var/www/magento/app/design/frontend/polar/default/template/page/2columns-left.phtml(53): Mage_Core_Block_Abstract->getChildHtml('content')
#25 /var/www/magento/app/code/core/Mage/Core/Block/Template.php(241): include('/var/www/magent...')
#26 /var/www/magento/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('frontend/polar/...')
#27 /var/www/magento/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()
#28 /var/www/magento/app/code/core/Mage/Core/Block/Abstract.php(919): Mage_Core_Block_Template->_toHtml()
#29 /var/www/magento/app/code/core/Mage/Core/Model/Layout.php(555): Mage_Core_Block_Abstract->toHtml()
#30 /var/www/magento/app/code/core/Mage/Core/Controller/Varien/Action.php(390): Mage_Core_Model_Layout->getOutput()
#31 /var/www/magento/app/code/core/Mage/Catalog/controllers/CategoryController.php(161): Mage_Core_Controller_Varien_Action->renderLayout()
#32 /var/www/magento/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Catalog_CategoryController->viewAction()
#33 /var/www/magento/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('view')
#34 /var/www/magento/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#35 /var/www/magento/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#36 /var/www/magento/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#37 /var/www/magento/index.php(87): Mage::run('', 'store')
#38 {main}

Reading this trace, I cannot figure out where the problem is originating, but I do know that the problem lies in a call to catalog_category_entity. I'm certain that it can't be any core files, and the 5 or 6 custom extensions installed were all working a week or two back.

Code from app/design/frontend/polar/default/template/catalog/category/view.phtml:

<?php
    $_helper    = $this->helper('catalog/output');
    $_category  = $this->getCurrentCategory();
    $_imgHtml   = '';
    if ($_imgUrl = $_category->getImageUrl()) {
        $_imgHtml = '<p class="category-image"><img src="'.$_imgUrl.'" alt="'.$this->escapeHtml($_category->getName()).'" title="'.$this->escapeHtml($_category->getName()).'" /></p>';
        $_imgHtml = $_helper->categoryAttribute($_category, $_imgHtml, 'image');
    }
?>
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>

<?php if($_imgUrl): ?>
    <?php echo $_imgHtml ?>
<?php endif; ?>

<?php if($_description=$this->getCurrentCategory()->getDescription()): ?>
    <div class="category-description std">
        <?php echo $_helper->categoryAttribute($_category, $_description, 'description') ?>
    </div>
    <?php endif; ?>

<?php if($this->isContentMode()): ?>
    <?php echo $this->getCmsBlockHtml() ?>

<?php elseif($this->isMixedMode()): ?>
    <?php echo $this->getCmsBlockHtml() ?>
    <?php echo $this->getProductListHtml() ?>

<?php else: ?>
    <?php echo $this->getProductListHtml() ?>    // LINE 63
<?php endif; ?>
12
  • 1
    Looking at your stack trace, i see that line 9, it seems to passing an object instead of an integer, which may result in a null value for entity_id
    – Shaughn
    Commented May 10, 2015 at 15:43
  • Hi Shaughn, and thanks for the feedback! What do you suggest? Line 9 shows a call from a core module
    – maGz
    Commented May 10, 2015 at 16:00
  • ye, i know its from the core. Im actually running a few scenarios to see if i can replicate. Can you confirm the following so long: category flat table is enabled and developer mode is disabled.
    – Shaughn
    Commented May 10, 2015 at 16:07
  • Hi Shaughn. I can confirm that Use Flat Catalog Category is off and developer mode is not enabled anywhere in .htaccess
    – maGz
    Commented May 10, 2015 at 16:12
  • Could you turn flat category on, reindex and refresh cache please and see if the error still exists
    – Shaughn
    Commented May 10, 2015 at 16:15

2 Answers 2

2

Stack trace shows that line 9 is passing an object instead of an integer. To debug, copy lib/Zend/Db/Adapter/Pdo/Abstract.php to app/code/local/Zend/Db/Adapter/Pdo/Abstract.php and add the Mage::log($value); before line 296. Enable Magento logging and clear cache. Then refresh the problematic page.

The output should show multiple lines with string values. If a line contains a Mage_Catalog_Model_Category object, then the value being passed is incorrect. Make note of the entity_id within that object as that is the category which is causing the issue.

Solution:

Disable / Delete category and re-add it again.

Cause:

Unknown, but could be caused from a malformed import or 3rd party import of categories and its sub parts.

2
  • Oh and when done debugging, dont forget to remove the copied app/code/local/Zend/Db/Adapter/Pdo/Abstract.php ;)
    – Shaughn
    Commented May 10, 2015 at 18:24
  • Ah yes! Of course. Thank u once again for all of your assistance and patience especially Shaughn :)
    – maGz
    Commented May 10, 2015 at 18:26
1

According to the error, that page is trying to run the query:

SELECT `catalog_category_entity`.* FROM `catalog_category_entity` WHERE (entity_id =)

Which isn't a valid MySQL query because no entity_id is specified.

The path of the file causing the error (/var/www/magento/includes/src/__default.php) denotes that Compilation is turned on, and that this error is baked into the compiled source. I'm not sure what the original source of the error is, but my suggestion is to go to System > Tools > Compilation and turn it off. Then clear your caches in System > Cache Management and refresh any indexes which require it in System > Index Management before going back into the Compilation page and recompiling and re-enabling compilation.

My guess is that code was updated, (like a module upgrade) while Compilation was turned on.

6
  • Thanks Tyler! Yes, I forgot about compilation. Let me try your instructions and I'll post right back here.
    – maGz
    Commented May 9, 2015 at 7:04
  • Hi Tyler, kindly see my edit above after compilation was disabled. Thank you!
    – maGz
    Commented May 10, 2015 at 14:06
  • @maGz Can you switch back to the base/default theme to see if the error happens there? I have a feeling it has to do with a bug in the Polar theme. Also, can you post the code around line 63 in the category template in the Polar theme?
    – Tyler V.
    Commented May 10, 2015 at 15:12
  • I looked through the polar code for view.phtml but couldn't see anything. Anyway, I've included the code in my answer above
    – maGz
    Commented May 10, 2015 at 15:18
  • really appreciate your help Tyler :)
    – maGz
    Commented May 10, 2015 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.