1

Our instance is throwing an error on this cronjob

PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name ''

The code is pulling empty table name. It seems the reason is because in the function Enterprise_Index_Model_Cron::_runCleanupAction() is this code:

$this->_getClient()->init($metadata->getTableName());

which passes the correct table names as they are in the database (with prefix "mage_"), but then in the underlying method Enterprise_Mview_Model_Client::init($name) it does this...

public function init($name)
{
    $tableName = $this->_factory->getSingleton('core/resource')->getTableName($name);
    $this->_metadata = $this->_factory->getModel('enterprise_mview/metadata')
        ->load($tableName, 'table_name');
    if (!$this->_metadata->getId()) {
        $this->_metadata->setTableName($tableName);
    }
    return $this;
}   

It gets a new table name using
$tableName = $this->_factory->getSingleton('core/resource')->getTableName($name);
which returns the same table name string only with a duplicated prefix e.g. "mage_mage_enterprise_url_rewrite_redirect". The code then cannot instantiate the model afterwards on this faulty table name.. This seems like a Magento core issue, no? Has Magento addressed this, or what would be the proper way to resolve this?

0

I ended up downloading the most recent version of Magento 1 EE (1.14.3.9) and found they coded this differently in a way that does not cause the error I'm experiencing. In the "Client.php" file, there is an added method

public function initByTableName($tableName)
{
    $this->_metadata = $this->_factory->getModel('enterprise_mview/metadata')
        ->load($tableName, 'table_name');
    if (!$this->_metadata->getId()) {
        $this->_metadata->setTableName($tableName);
    }
    return $this;
}  

Note it does not process the parameter with $this->_factory->getSingleton('core/resource')->getTableName(). and then in the "Cron.php", they use this new method in _runCleanupAction() ..

protected function _runCleanupAction(Enterprise_Mview_Model_Metadata $metadata)
{
    $this->_getClient()->initByTableName($metadata->getTableName());
    try {
        $this->_getClient()->execute('enterprise_mview/action_changelog_clear');
    } catch (Exception $e) {
        $this->_logger->logException($e);
    }
}  

I ended up modifying these 2 core/enterprise files to match and the cron is working great now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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