PM-1903 "0017014: ProcessMaker loses connection..." SOLVED

Issue:
    0017014: ProcessMaker loses connection with database -> lack of mysql_close()
Cause:
    - Error al tratar de conectarse a la BD
    - Segun el feedback proporcianado, el problema central
      se basa en que no se esta haciendo uso del mysql_close()
Solution:
    - Se a logrado implementar el close de los connects a BD abiertos
    - Este cambio repercute en toda la funcionalidad de ProcessMaker. Por lo
      que se debera hacer un test con todos los flags de depuracion
      habilitados, tambien con todos los plugins habilitados/deshabilitados
    - Tambien se debe considerar otros "test cases"
This commit is contained in:
Victor Saisa Lopez
2015-03-30 15:02:48 -04:00
parent 1d6a197592
commit e80dcd506b
2 changed files with 28 additions and 13 deletions

View File

@@ -596,16 +596,20 @@ class Propel {
* *
* @return void * @return void
*/ */
public static function close() public static function close()
{ {
$last = ''; $lastQuery = "";
foreach(self::$connectionMap as $conn) {
if ($last != $conn->lastQuery) { foreach (self::$connectionMap as $cnn) {
$conn->close(); if (!($cnn instanceof DBArrayConnection)) {
} if (gettype($cnn->getResource()) == "resource" && $cnn->isConnected() && $cnn->lastQuery != $lastQuery) {
$last = $conn->lastQuery; $cnn->close();
} }
}
$lastQuery = $cnn->lastQuery;
}
}
}
/** /**
* @param $name string The connection name * @param $name string The connection name
@@ -622,7 +626,7 @@ class Propel {
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
} }
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
if (! empty(self::$configuration['datasources'][$name]['connection'])) { if (! empty(self::$configuration['datasources'][$name]['connection'])) {
return self::getConnection($name); return self::getConnection($name);
} }
@@ -630,7 +634,7 @@ class Propel {
// the connection names always should be have a underscore like: workflow_ro, rbac_rw // the connection names always should be have a underscore like: workflow_ro, rbac_rw
// on fallback, we will try found a connection named: "workflow" if "workflow_ro" does not exist. // on fallback, we will try found a connection named: "workflow" if "workflow_ro" does not exist.
// the name without the "_ro" part. // the name without the "_ro" part.
$defaultDbName = substr($name, 0, strrpos($name, '_')); $defaultDbName = substr($name, 0, strrpos($name, '_'));
if (! empty(self::$configuration['datasources'][$defaultDbName]['connection'])) { if (! empty(self::$configuration['datasources'][$defaultDbName]['connection'])) {

View File

@@ -1,4 +1,15 @@
<?php <?php
register_shutdown_function(
create_function(
"",
"
if (class_exists(\"Propel\")) {
Propel::close();
}
"
)
);
/* /*
* ProcessMaker Web Application Bootstrap * ProcessMaker Web Application Bootstrap
*/ */
@@ -30,7 +41,7 @@ try {
} }
$loader->add($rootDir . 'workflow/engine/src/', "ProcessMaker"); $loader->add($rootDir . 'workflow/engine/src/', "ProcessMaker");
$loader->add($rootDir . 'workflow/engine/src/'); $loader->add($rootDir . 'workflow/engine/src/');
// add vendors to autoloader // add vendors to autoloader
$loader->add($rootDir . 'vendor/luracast/restler/vendor', "Luracast"); $loader->add($rootDir . 'vendor/luracast/restler/vendor', "Luracast");
$loader->add($rootDir . 'vendor/bshaffer/oauth2-server-php/src/', "OAuth2"); $loader->add($rootDir . 'vendor/bshaffer/oauth2-server-php/src/', "OAuth2");