PMCORE-949 Use of buffered query on cron's calculate parameter/task exhausts php's memory limit

This commit is contained in:
Roly Gutierrez
2022-08-05 11:45:35 -04:00
committed by Julio Cesar Laura Avendaño
parent c48f006c6a
commit 809a1feeef
4 changed files with 240 additions and 90 deletions

View File

@@ -7,6 +7,7 @@ use ProcessMaker\Core\JobsManager;
use ProcessMaker\Core\System;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\Fields;
use ProcessMaker\Util\BatchProcessWithIndexes;
require_once 'classes/model/om/BaseAdditionalTables.php';
@@ -782,19 +783,17 @@ class AdditionalTables extends BaseAdditionalTables
$reportTableBatchRegeneration = $config['report_table_batch_regeneration'];
// Initializing more variables
$size = $n;
$start = 0;
$limit = $reportTableBatchRegeneration;
$batch = new BatchProcessWithIndexes($n);
$batch->setLimit($reportTableBatchRegeneration);
// Creating jobs
for ($i = 1; $start < $size; $i++) {
$closure = function() use($workspace, $tableName, $type, $processUid, $gridKey, $addTabUid, $start, $limit) {
$batch->process(function ($start, $limit) use ($workspace, $tableName, $type, $processUid, $gridKey, $addTabUid) {
$closure = function () use ($workspace, $tableName, $type, $processUid, $gridKey, $addTabUid, $start, $limit) {
$workspaceTools = new WorkspaceTools($workspace);
$workspaceTools->generateDataReport($tableName, $type, $processUid, $gridKey, $addTabUid, $start, $limit);
};
JobsManager::getSingleton()->dispatch(GenerateReportTable::class, $closure);
$start = $i * $limit;
}
});
}
/**