Skip to content

Commit 1e76a68

Browse files
committed
Do not close MySQL connections with open transactions
Transactions are used if products are saved. To update the index of a single product, disconnecting from the database does not make sense anyway. Resolves #6
1 parent 215d3ee commit 1e76a68

File tree

1 file changed

+14
-0
lines changed
  • src/app/code/community/IntegerNet/Solr/Model/Resource

1 file changed

+14
-0
lines changed

src/app/code/community/IntegerNet/Solr/Model/Resource/Db.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,24 @@ public function disconnectMysql()
1919
/** @var Zend_Db_Adapter_Abstract $connection */
2020
foreach (Mage::getSingleton('core/resource')->getConnections() as $name => $connection) {
2121
if ($connection instanceof Zend_Db_Adapter_Abstract) {
22+
if ($this->isTransactionOpen($connection)) {
23+
continue;
24+
}
2225
$connection->closeConnection();
2326
}
2427
}
2528
// connections (adapter objects) must be fully reinitialized, otherwise initStatements are not executed
2629
Mage::unregister('_singleton/core/resource');
2730
}
31+
32+
/**
33+
* Returns true if the given connection has open transactions
34+
*
35+
* @param Zend_Db_Adapter_Abstract $connection
36+
* @return bool
37+
*/
38+
private function isTransactionOpen(Zend_Db_Adapter_Abstract $connection)
39+
{
40+
return $connection instanceof Magento_Db_Adapter_Pdo_Mysql && $connection->isTransaction();
41+
}
2842
}

0 commit comments

Comments
 (0)