PMCORE-2412

This commit is contained in:
Julio Cesar Laura Avendaño
2020-11-10 15:14:49 +00:00
parent a37491d4ca
commit b47f838e62
4 changed files with 51 additions and 13 deletions

View File

@@ -17,7 +17,8 @@ try {
'ldapcron' => ['title' => 'LDAP Advanced CRON'],
'messageeventcron' => ['title' => 'Message-Event CRON'],
'timereventcron' => ['title' => 'Timer-Event CRON'],
'sendnotificationscron' => ['title' => 'Send-Notifications CRON']
'sendnotificationscron' => ['title' => 'Send-Notifications CRON'],
'webentriescron' => ['title' => 'Wen Entries CRON']
];
//Define constants

View File

@@ -8,6 +8,7 @@
* @see workflow/engine/bin/timereventcron.php
* @see workflow/engine/bin/ldapcron.php
* @see workflow/engine/bin/sendnotificationscron.php
* @see workflow/engine/bin/webentriescron.php
* @see workflow/engine/methods/setup/cron.php
*
* @link https://wiki.processmaker.com/3.2/Executing_cron.php
@@ -22,6 +23,7 @@ require_once __DIR__ . '/../../../gulliver/system/class.g.php';
require_once __DIR__ . '/../../../bootstrap/autoload.php';
require_once __DIR__ . '/../../../bootstrap/app.php';
use ProcessMaker\BusinessModel\WebEntry;
use ProcessMaker\Core\JobsManager;
use ProcessMaker\Core\System;
use ProcessMaker\Plugins\PluginRegistry;
@@ -302,6 +304,11 @@ try {
case 'sendnotificationscron':
sendNotifications();
break;
case 'webentriescron':
setExecutionMessage('Deleting web entry cases created one week ago or more');
WebEntry::deleteOldWebEntries();
setExecutionResultMessage('FINISHED');
break;
/*----------------------------------********---------------------------------*/
case 'actionsByEmailEmailResponse':
(new ResponseReader)->actionsByEmailEmailResponse();

View File

@@ -0,0 +1,3 @@
<?php
require_once 'cron.php';

View File

@@ -1175,7 +1175,7 @@ class WebEntry
public static function convertFromV1ToV2()
{
// Build query
$sql = "UPDATE
$query = "UPDATE
`WEB_ENTRY`
LEFT JOIN
`BPMN_PROCESS`
@@ -1188,6 +1188,33 @@ class WebEntry
`WE_CALLBACK` = 'PROCESSMAKER' AND `BPMN_PROCESS`.`PRJ_UID` IS NOT NULL";
// Execute query
DB::connection('workflow')->statement($sql);
DB::connection('workflow')->statement($query);
}
/**
* Delete web entries created one week ago or more
*/
public static function deleteOldWebEntries()
{
// Define some values for PM tables classes
if (!defined('PATH_WORKSPACE')) {
define('PATH_WORKSPACE', PATH_DB . config('system.workspace') . PATH_SEP);
}
set_include_path(get_include_path() . PATH_SEPARATOR . PATH_WORKSPACE);
// Calculate date, one week ago from today
$date = now()->subWeek()->format('Y-m-d H:i:s');
// Build query
$query = "SELECT `APP_UID` FROM `APPLICATION` WHERE `APP_NUMBER` < 0 AND `APP_CREATE_DATE` < '{$date}'";
// Execute query
$cases = DB::connection('workflow')->select($query);
// Delete cases, one by one with all related records
$casesInstance = new Cases();
foreach ($cases as $case) {
$casesInstance->removeCase($case->APP_UID);
}
}
}