|
@@ -156,25 +156,53 @@ class Route_Status extends RouteBase {
|
|
|
function updateRefTablesPostTask() {
|
|
function updateRefTablesPostTask() {
|
|
|
Lib::loadClass('RefConfig');
|
|
Lib::loadClass('RefConfig');
|
|
|
DBG::log("DBG:updateRefTablesPostTask...");
|
|
DBG::log("DBG:updateRefTablesPostTask...");
|
|
|
- $toUpdateStep = 10;
|
|
|
|
|
- $baseRefOffset = V::get('baseref_offset', 0, $_POST, 'int');
|
|
|
|
|
- $backRefOffset = V::get('backref_offset', 0, $_POST, 'int');
|
|
|
|
|
- $todoBaseRefOffset = $baseRefOffset;
|
|
|
|
|
- $todoBackRefOffset = $backRefOffset;
|
|
|
|
|
- $baseRefToUpdate = RefConfig::getToUpdateItems();
|
|
|
|
|
- DBG::log($baseRefToUpdate, 'array', "DBG:updateRefTablesPostTask \$baseRefToUpdate");
|
|
|
|
|
- if ($baseRefOffset > count($baseRefToUpdate)) {
|
|
|
|
|
- $backRefToUpdate = RefConfig::getToUpdateItems('backRef');
|
|
|
|
|
- $listBackRefConf = array_slice($backRefToUpdate, $backRefOffset, $toUpdateStep);
|
|
|
|
|
- DBG::log($listBackRefConf, 'array', "DBG:updateRefTablesPostTask \$listBackRefConf ({$backRefOffset}, {$toUpdateStep})");
|
|
|
|
|
- self::_updateRefTables($listBackRefConf);
|
|
|
|
|
- $todoBackRefOffset = $backRefOffset + $toUpdateStep;
|
|
|
|
|
- } else {
|
|
|
|
|
- $listBaseRefConf = array_slice($baseRefToUpdate, $baseRefOffset, $toUpdateStep);
|
|
|
|
|
- DBG::log($listBaseRefConf, 'array', "DBG:updateRefTablesPostTask \$listBaseRefConf ({$baseRefOffset}, {$toUpdateStep})");
|
|
|
|
|
- self::_updateRefTables($listBaseRefConf);
|
|
|
|
|
- $todoBaseRefOffset = $baseRefOffset + $toUpdateStep;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (0) { // TEST
|
|
|
|
|
+ // 5345 is backRef 2411
|
|
|
|
|
+ $todoRef = DB::getPDO()->fetchAll("
|
|
|
|
|
+ select c.ID, c.ROOT_OBJECT_NS, c.CHILD_NAME, c.CHILD_NS
|
|
|
|
|
+ from `CRM_REF_CONFIG` c
|
|
|
|
|
+ where c.A_STATUS = 'NORMAL' and c.ID = :id
|
|
|
|
|
+ ", [
|
|
|
|
|
+ ':id' => 2411,
|
|
|
|
|
+ ]);
|
|
|
|
|
+ self::_updateRefTables($todoRef);
|
|
|
|
|
+
|
|
|
|
|
+ $todoRef = DB::getPDO()->fetchAll("
|
|
|
|
|
+ select c.ID, c.ROOT_OBJECT_NS, c.CHILD_NAME, c.CHILD_NS
|
|
|
|
|
+ from `CRM_REF_CONFIG` c
|
|
|
|
|
+ where c.A_STATUS = 'NORMAL' and c.ID = :id
|
|
|
|
|
+ ", [
|
|
|
|
|
+ ':id' => 5345,
|
|
|
|
|
+ ]);
|
|
|
|
|
+ self::_updateRefTables($todoRef);
|
|
|
|
|
+
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $toUpdateStep = 100;
|
|
|
|
|
+ $todoType = V::get('type_type', 'base', $_POST); // base | back
|
|
|
|
|
+ $idLast = V::get('id_last', 0, $_POST, 'int');
|
|
|
|
|
+ // $baseRefToUpdate = RefConfig::getToUpdateItems('', $toUpdateStep, $idLast);
|
|
|
|
|
+ $todoRef = [];
|
|
|
|
|
+ if ('base' === $todoType) {
|
|
|
|
|
+ $todoRef = RefConfig::getToUpdateItems('', $toUpdateStep, $idLast);
|
|
|
|
|
+ if (empty($todoRef)) {
|
|
|
|
|
+ $todoType = 'back';
|
|
|
|
|
+ $idLast = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if ('back' === $todoType) {
|
|
|
|
|
+ $todoRef = RefConfig::getToUpdateItems('backRef', $toUpdateStep, $idLast);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!empty($todoRef)) {
|
|
|
|
|
+ self::_updateRefTables($todoRef);
|
|
|
|
|
+ $lastRef = end($todoRef);
|
|
|
|
|
+ $idLast = $lastRef['ID'];
|
|
|
}
|
|
}
|
|
|
|
|
+ DBG::nicePrint($todoRef, '$todoRef');
|
|
|
|
|
+ DBG::nicePrint($idLast, '$idLast');
|
|
|
|
|
|
|
|
$totalToUpdateRef = RefConfig::getToUpdateTotal();
|
|
$totalToUpdateRef = RefConfig::getToUpdateTotal();
|
|
|
echo ($totalToUpdateRef)
|
|
echo ($totalToUpdateRef)
|
|
@@ -184,8 +212,8 @@ class Route_Status extends RouteBase {
|
|
|
'class' => "btn btn-xs btn-default",
|
|
'class' => "btn btn-xs btn-default",
|
|
|
'data' => [
|
|
'data' => [
|
|
|
'_postTask' => 'updateRefTables',
|
|
'_postTask' => 'updateRefTables',
|
|
|
- 'baseref_offset' => $todoBaseRefOffset,
|
|
|
|
|
- 'backref_offset' => $todoBackRefOffset,
|
|
|
|
|
|
|
+ 'id_last' => $idLast,
|
|
|
|
|
+ 'type_type' => $todoType,
|
|
|
]
|
|
]
|
|
|
])
|
|
])
|
|
|
])
|
|
])
|
|
@@ -202,7 +230,9 @@ class Route_Status extends RouteBase {
|
|
|
try {
|
|
try {
|
|
|
UI::alert('info', "Aktualizuje ['{$refConf['ID']}'] od '{$refConf['ROOT_OBJECT_NS']}' do '{$refConf['CHILD_NAME']}' ...");
|
|
UI::alert('info', "Aktualizuje ['{$refConf['ID']}'] od '{$refConf['ROOT_OBJECT_NS']}' do '{$refConf['CHILD_NAME']}' ...");
|
|
|
RefConfig::getRefConfig($refConf['ROOT_OBJECT_NS'], $refConf['CHILD_NAME'], $refConf['CHILD_NS']);
|
|
RefConfig::getRefConfig($refConf['ROOT_OBJECT_NS'], $refConf['CHILD_NAME'], $refConf['CHILD_NS']);
|
|
|
|
|
+ // expected fix ref config and set current version if no errors
|
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
|
|
|
+ echo UI::h('p', [ 'class' => "p5-refconfig-exception", 'style' => "display:none" ], "#ERROR: " . $e->getMessage());
|
|
|
DBG::log($e);
|
|
DBG::log($e);
|
|
|
if ('Ref allowed only for AntAcl objects' === $e->getMessage()) {
|
|
if ('Ref allowed only for AntAcl objects' === $e->getMessage()) {
|
|
|
$totalTableSkippedNotAcl++;
|
|
$totalTableSkippedNotAcl++;
|
|
@@ -211,7 +241,7 @@ class Route_Status extends RouteBase {
|
|
|
} else if ("Not Implemented acl type ''" === substr($e->getMessage(), 0, strlen("Not Implemented acl type ''"))) {
|
|
} else if ("Not Implemented acl type ''" === substr($e->getMessage(), 0, strlen("Not Implemented acl type ''"))) {
|
|
|
$totalTableSkippedMissingAclType++;
|
|
$totalTableSkippedMissingAclType++;
|
|
|
}
|
|
}
|
|
|
- UI::alert('danger', "Problem z aktualizacją tabeli z relacjami ['{$refConf['ID']}'] od '{$refConf['ROOT_OBJECT_NS']}' do '{$refConf['CHILD_NAME']}'");
|
|
|
|
|
|
|
+ UI::alert('danger', "Problem z aktualizacją tabeli z relacjami ['{$refConf['ID']}'] od '{$refConf['ROOT_OBJECT_NS']}' do '{$refConf['CHILD_NAME']}'");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if ($totalTableSkippedNotAcl) UI::alert('warning', "Nie zaktualizowano {$totalTableSkippedNotAcl} tabeli z relajami - obiekty różnego typu od 'Acl'");
|
|
if ($totalTableSkippedNotAcl) UI::alert('warning', "Nie zaktualizowano {$totalTableSkippedNotAcl} tabeli z relajami - obiekty różnego typu od 'Acl'");
|