diff --git a/doc/release-notes.md b/doc/release-notes.md
index 82491cf..930e443 100644
--- a/doc/release-notes.md
+++ b/doc/release-notes.md
@@ -2,6 +2,11 @@ IntegerNet_Solr Free for Magento 1
===============
Release Notes
+Upcoming
+---------------
+
+- Make the MySQL connection disconnect/reconnect feature configurable (default: off)
+
Version 1.7.4 (Jul 17, 2017)
---------------
diff --git a/src/app/code/community/IntegerNet/Solr/Model/Resource/Db.php b/src/app/code/community/IntegerNet/Solr/Model/Resource/Db.php
index 77f7607..a7b5811 100755
--- a/src/app/code/community/IntegerNet/Solr/Model/Resource/Db.php
+++ b/src/app/code/community/IntegerNet/Solr/Model/Resource/Db.php
@@ -16,8 +16,18 @@ class IntegerNet_Solr_Model_Resource_Db
*/
public function disconnectMysql()
{
+ if (!Mage::getStoreConfigFlag('integernet_solr/indexing/disconnect_mysql_connections')) {
+ return;
+ }
+
+ /** @var $coreResource Mage_Core_Model_Resource */
+ $coreResource = Mage::getSingleton('core/resource');
+ if (!method_exists($coreResource, 'getConnections')) {
+ return; // method only exists from Magento CE 1.9.1 / EE 1.14.1
+ }
+
/** @var Zend_Db_Adapter_Abstract $connection */
- foreach (Mage::getSingleton('core/resource')->getConnections() as $name => $connection) {
+ foreach ($coreResource->getConnections() as $name => $connection) {
if ($connection instanceof Zend_Db_Adapter_Abstract) {
if ($this->isTransactionOpen($connection)) {
continue;
@@ -25,6 +35,7 @@ public function disconnectMysql()
$connection->closeConnection();
}
}
+
// connections (adapter objects) must be fully reinitialized, otherwise initStatements are not executed
Mage::unregister('_singleton/core/resource');
}
diff --git a/src/app/code/community/IntegerNet/Solr/Test/Model/Resource/Db.php b/src/app/code/community/IntegerNet/Solr/Test/Model/Resource/Db.php
index d4c8cc9..d210731 100644
--- a/src/app/code/community/IntegerNet/Solr/Test/Model/Resource/Db.php
+++ b/src/app/code/community/IntegerNet/Solr/Test/Model/Resource/Db.php
@@ -10,6 +10,7 @@
/**
* @loadFixture registry
+ * @loadFixture config
* @doNotIndexAll
*/
class IntegerNet_Solr_Test_Model_Resource_Db extends EcomDev_PHPUnit_Test_Case
diff --git a/src/app/code/community/IntegerNet/Solr/Test/fixtures/config.yaml b/src/app/code/community/IntegerNet/Solr/Test/fixtures/config.yaml
index 7bafd13..4073b17 100644
--- a/src/app/code/community/IntegerNet/Solr/Test/fixtures/config.yaml
+++ b/src/app/code/community/IntegerNet/Solr/Test/fixtures/config.yaml
@@ -17,6 +17,7 @@ config:
default/integernet_solr/server/http_method: curl
default/integernet_solr/server/use_https: 0
default/integernet_solr/server/use_http_basic_auth: 0
+ default/integernet_solr/indexing/disconnect_mysql_connections: 1
default/integernet_solr/connection_check/is_active: 1
default/integernet_solr/fuzzy/is_active: 0
default/integernet_solr/category/is_active: 1
diff --git a/src/app/code/community/IntegerNet/Solr/etc/config.xml b/src/app/code/community/IntegerNet/Solr/etc/config.xml
index 3570cb3..4a657bf 100644
--- a/src/app/code/community/IntegerNet/Solr/etc/config.xml
+++ b/src/app/code/community/IntegerNet/Solr/etc/config.xml
@@ -245,6 +245,7 @@
10001
+ 01
diff --git a/src/app/code/community/IntegerNet/Solr/etc/system.xml b/src/app/code/community/IntegerNet/Solr/etc/system.xml
index df5344f..d2b7004 100644
--- a/src/app/code/community/IntegerNet/Solr/etc/system.xml
+++ b/src/app/code/community/IntegerNet/Solr/etc/system.xml
@@ -193,7 +193,7 @@
11
-
+ text40
@@ -204,6 +204,16 @@
1
+
+
+ Use this to avoid SQL timeout errors during indexing. Only available since Magento CE 1.9.1 / EE 1.14.1.
+ select
+ adminhtml/system_config_source_yesno
+ 50
+ 1
+ 0
+ 0
+
diff --git a/src/app/locale/de_DE/IntegerNet_Solr.csv b/src/app/locale/de_DE/IntegerNet_Solr.csv
index f7a3193..77ac9f4 100644
--- a/src/app/locale/de_DE/IntegerNet_Solr.csv
+++ b/src/app/locale/de_DE/IntegerNet_Solr.csv
@@ -109,4 +109,6 @@
"Show category filter","Kategorie-Filter anzeigen"
"Show products which are out of stock","Produkte anzeigen, die nicht auf Lager sind"
"Solr Priority Multiplier for Products being out of Stock","Solr-Prioritäts-Multiplikator für ausverkaufte Produkte"
-"0 = don't show at all, 1 = don't modify, anything between = lower priority","0 = gar nicht anzeigen, 1 = wie Produkte auf Lager, alles dazwischen = niedrigere Priorität"
\ No newline at end of file
+"0 = don't show at all, 1 = don't modify, anything between = lower priority","0 = gar nicht anzeigen, 1 = wie Produkte auf Lager, alles dazwischen = niedrigere Priorität"
+"Disconnect and reconnect MySQL Connections during indexing","MySQL-Verbindungen während der Indizierung trennen und neu aufbauen"
+"Use this to avoid SQL timeout errors during indexing. Only available since Magento CE 1.9.1 / EE 1.14.1.","Aktivieren Sie diese Option, wenn Sie Timeout-Fehler während der Indizierung erhalten. Verfügbar erst ab Magento CE 1.9.1 / EE 1.14.1."
\ No newline at end of file