PMC-593
This commit is contained in:
@@ -318,6 +318,7 @@ function processWorkspace()
|
||||
executeScheduledCases();
|
||||
executeUpdateAppTitle();
|
||||
executeCaseSelfService();
|
||||
cleanSelfServiceTables();
|
||||
executePlugins();
|
||||
/*----------------------------------********---------------------------------*/
|
||||
fillReportByUser();
|
||||
@@ -1047,3 +1048,46 @@ function sendNotifications()
|
||||
saveLog("ExecuteSendNotifications", "error", "Error when sending notifications " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean unused records in tables related to the Self-Service Value Based feature
|
||||
*
|
||||
* @see processWorkspace()
|
||||
*
|
||||
* @link https://wiki.processmaker.com/3.2/Executing_cron.php#Syntax_of_cron.php_Options
|
||||
*/
|
||||
function cleanSelfServiceTables()
|
||||
{
|
||||
try {
|
||||
global $argvx;
|
||||
|
||||
// Check if the action can be executed
|
||||
if ($argvx !== "" && strpos($argvx, "clean-self-service-tables") === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Start message
|
||||
setExecutionMessage("Clean unused records for Self-Service Value Based feature");
|
||||
|
||||
// Get Propel connection
|
||||
$cnn = Propel::getConnection(AppAssignSelfServiceValueGroupPeer::DATABASE_NAME);
|
||||
|
||||
// Delete related rows and missing relations, criteria don't execute delete with joins
|
||||
$cnn->begin();
|
||||
$stmt = $cnn->createStatement();
|
||||
$stmt->executeQuery("DELETE " . AppAssignSelfServiceValueGroupPeer::TABLE_NAME . "
|
||||
FROM " . AppAssignSelfServiceValueGroupPeer::TABLE_NAME . "
|
||||
LEFT JOIN " . AppAssignSelfServiceValuePeer::TABLE_NAME . "
|
||||
ON (" . AppAssignSelfServiceValueGroupPeer::ID . " = " . AppAssignSelfServiceValuePeer::ID . ")
|
||||
WHERE " . AppAssignSelfServiceValuePeer::ID . " IS NULL");
|
||||
$cnn->commit();
|
||||
|
||||
// Success message
|
||||
setExecutionResultMessage("DONE");
|
||||
} catch (Exception $e) {
|
||||
$cnn->rollback();
|
||||
setExecutionResultMessage("WITH ERRORS", "error");
|
||||
eprintln(" '-" . $e->getMessage(), "red");
|
||||
saveLog("ExecuteCleanSelfServiceTables", "error", "Error when try to clean self-service tables " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,12 @@ class AppAssignSelfServiceValue extends BaseAppAssignSelfServiceValue
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @see \Cases->removeCase()
|
||||
* @see \Cases->setCatchUser()
|
||||
* @see \Cases->updateCase()
|
||||
*
|
||||
* @link https://wiki.processmaker.com/3.2/Tasks#Self_Service_Value_Based_Assignment
|
||||
*/
|
||||
public function remove($applicationUid, $delIndex = 0)
|
||||
{
|
||||
@@ -76,18 +82,7 @@ class AppAssignSelfServiceValue extends BaseAppAssignSelfServiceValue
|
||||
$criteria->add(AppAssignSelfServiceValuePeer::DEL_INDEX, $delIndex, Criteria::EQUAL);
|
||||
}
|
||||
|
||||
$result = AppAssignSelfServiceValuePeer::doDelete($criteria);
|
||||
|
||||
// Delete related rows and missing relations, criteria don't execute delete with joins
|
||||
$cnn = Propel::getConnection(AppAssignSelfServiceValueGroupPeer::DATABASE_NAME);
|
||||
$cnn->begin();
|
||||
$stmt = $cnn->createStatement();
|
||||
$rs = $stmt->executeQuery("DELETE " . AppAssignSelfServiceValueGroupPeer::TABLE_NAME . "
|
||||
FROM " . AppAssignSelfServiceValueGroupPeer::TABLE_NAME . "
|
||||
LEFT JOIN " . AppAssignSelfServiceValuePeer::TABLE_NAME . "
|
||||
ON (" . AppAssignSelfServiceValueGroupPeer::ID . " = " . AppAssignSelfServiceValuePeer::ID . ")
|
||||
WHERE " . AppAssignSelfServiceValuePeer::ID . " IS NULL");
|
||||
$cnn->commit();
|
||||
AppAssignSelfServiceValuePeer::doDelete($criteria);
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user