Question

magento upgrade 1.5.1.0 >> {1.6.2.0,1.7.0.2,1.8.0.0} i was trying to remove all modules, upgrading directly copying files and with magento downloader, no luck, every time i get this error. but where and why it fails exactly, how to debug it properly?

Error in file: "Z:\home\www\store\app\code\core\Mage\Core\sql\core_setup\mysql4-upgrade-1.5.9.9-1.6.0.0.php" 
- SQLSTATE[HY093]: Invalid parameter number: no parameters were bound

Trace:
#0 Z:\home\www\store\app\code\core\Mage\Core\Model\Resource\Setup.php(645): Mage::exception('Mage_Core', 'Error in file: ...')
#1 Z:\home\www\store\app\code\core\Mage\Core\Model\Resource\Setup.php(437): Mage_Core_Model_Resource_Setup->_modifyResourceDb('upgrade', '0.8.28', '1.6.0.3')
#2 Z:\home\www\store\app\code\core\Mage\Core\Model\Resource\Setup.php(320): Mage_Core_Model_Resource_Setup->_upgradeResourceDb('0.8.28', '1.6.0.3')
#3 Z:\home\www\store\app\code\core\Mage\Core\Model\Resource\Setup.php(235): Mage_Core_Model_Resource_Setup->applyUpdates()
#4 Z:\home\www\store\app\code\core\Mage\Core\Model\App.php(417): Mage_Core_Model_Resource_Setup::applyAllUpdates()
#5 Z:\home\www\store\app\code\core\Mage\Core\Model\App.php(343): Mage_Core_Model_App->_initModules()
#6 Z:\home\www\store\app\Mage.php(683): Mage_Core_Model_App->run(Array)
#7 Z:\home\www\store\index.php(87): Mage::run('', 'store')
#8 {main}
Was it helpful?

Solution

To enable PDO MySQL Debug need to edit this file: /lib/Varien/Db/Adapter/Pdo/Mysql.php

protected $_debug               = true;

then we open this file: /lib/Zend/Db/Statement/Pdo.php, and replace this line about 234:

throw new Zend_Db_Statement_Exception($e->getMessage(), (int) $e->getCode(), $e);

with this code:

$msg = "SQL ERROR: ". $e->getMessage() . "\n";
            $msg .= "SQL QUERY:" . $this->_stmt->queryString."\n";
            if(!empty($params)) {
                $msg .= "SQL PARAMS: ('". implode("','", $params) ."')\n";
            }
            $dbsEx = new Zend_Db_Statement_Exception($msg, (int) $e->getCode(), $e);
            throw $dbsEx;

so now we will get a folder /var/debug/, and file pdo_mysql.log in this file we have now full mysql error with full mysql query. you can easily execute those failing queries in phpmyadmin or edit database table, params, etc.

im happy with it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top