N°4938 - Fix background calls broken by lazy JS dictionaries loads

This commit is contained in:
Molkobain
2022-03-11 09:25:14 +01:00
parent 5908ec5197
commit 0d4796ae2b
3 changed files with 18 additions and 10 deletions

View File

@@ -65,6 +65,9 @@ try
switch ($sOperation)
{
case 'add':
$oPage = new JsonPage();
$oPage->SetOutputDataOnly(true);
$aResult = array(
'error' => '',
'att_id' => 0,
@@ -111,7 +114,7 @@ try
$aResult['error'] = $e->GetMessage();
}
}
$oPage->add(json_encode($aResult));
$oPage->SetData($aResult);
break;
case 'remove':

View File

@@ -2060,10 +2060,14 @@ EOF
break;
case 'export_build':
$oPage = new JsonPage();
$oPage->SetOutputDataOnly(true);
$oAjaxRenderController->ExportBuild($oPage, false);
break;
case 'export_build_portal':
$oPage = new JsonPage();
$oPage->SetOutputDataOnly(true);
$oAjaxRenderController->ExportBuild($oPage, true);
break;
@@ -2652,7 +2656,8 @@ EOF
// Navigation menu
//--------------------------------
case 'get_menus_count':
$oPage = new JsonPage();
$oPage->SetOutputDataOnly(true);
$oAjaxRenderController->GetMenusCount($oPage);
break;

View File

@@ -123,12 +123,12 @@ class AjaxRenderController
}
/**
* @param \AjaxPage $oPage
* @param \JsonPage $oPage
* @param bool $bTokenOnly
*
* @throws \Exception
*/
public static function ExportBuild(AjaxPage $oPage, $bTokenOnly)
public static function ExportBuild(JsonPage $oPage, $bTokenOnly)
{
register_shutdown_function(function () {
$aErr = error_get_last();
@@ -208,13 +208,13 @@ class AjaxRenderController
$aResult['message'] = Dict::Format('Core:BulkExport:ClickHereToDownload_FileName', $oExporter->GetDownloadFileName());
}
}
$oPage->add(json_encode($aResult));
$oPage->SetData($aResult);
} catch (BulkExportException $e) {
$aResult = array('code' => 'error', 'percentage' => 100, 'message' => utils::HtmlEntities($e->GetLocalizedMessage()));
$oPage->add(json_encode($aResult));
$oPage->SetData($aResult);
} catch (Exception $e) {
$aResult = array('code' => 'error', 'percentage' => 100, 'message' => utils::HtmlEntities($e->getMessage()));
$oPage->add(json_encode($aResult));
$oPage->SetData($aResult);
}
}
@@ -224,13 +224,13 @@ class AjaxRenderController
* The resulting JSON is added to the page with the format:
* {"code": "done or error", "counts": {"menu_id_1": count1, "menu_id_2": count2...}}
*
* @param \AjaxPage $oPage
* @param \JsonPage $oPage
*/
public function GetMenusCount(AjaxPage $oPage)
public function GetMenusCount(JsonPage $oPage)
{
$aCounts = ApplicationMenu::GetMenusCount();
$aResult = ['code' => 'done', 'counts' => $aCounts];
$oPage->add(json_encode($aResult));
$oPage->SetData($aResult);
}
/**