ref https://www.woltlab.com/community/thread/309331-error-message-during-import-process-wcf-ajax-error-sessionexpired/
import { DialogCallbackSetup } from "../../../Ui/Dialog/Data";
import DomUtil from "../../../Dom/Util";
import UiDialog from "../../../Ui/Dialog";
+import { prepareRequest } from "WoltLabSuite/Core/Ajax/Backend";
export class AcpUiDataImportManager implements AjaxCallbackObject {
private readonly queue: string[];
private readonly redirectUrl: string;
private currentAction = "";
private index = -1;
+ private cacheClearEndpoint = "";
- constructor(queue: string[], redirectUrl: string) {
+ constructor(queue: string[], redirectUrl: string, cacheClearEndpoint: string) {
this.queue = queue;
this.redirectUrl = redirectUrl;
+ this.cacheClearEndpoint = cacheClearEndpoint;
- this.invoke();
+ void this.invoke();
}
- private invoke(): void {
+ private async invoke(): Promise<void> {
this.index++;
if (this.index >= this.queue.length) {
- Ajax.apiOnce({
- url: "index.php?cache-clear/&t=" + Core.getXsrfToken(),
- data: {
- noRedirect: 1,
- },
- silent: true,
- success: () => this.showCompletedDialog(),
- });
+ await prepareRequest(this.cacheClearEndpoint).post().fetchAsResponse();
+ this.showCompletedDialog();
} else {
this.run(Language.get("wcf.acp.dataImport.data." + this.queue[this.index]), this.queue[this.index]);
}
parameters: data.parameters,
});
} else {
- this.invoke();
+ void this.invoke();
}
}
});
const queue = [ {implode from=$queue item=item}'{@$item}'{/implode} ];
- new AcpUiDataImportManager(queue, '{link controller='RebuildData' encode=false}{/link}');
+ new AcpUiDataImportManager(queue, '{link controller='RebuildData' encode=false}{/link}', '{$cacheClearEndpoint|encodeJS}');
});
</script>
{/if}
-define(["require", "exports", "tslib", "../../../Ajax", "../../../Core", "../../../Language", "../../../Dom/Util", "../../../Ui/Dialog"], function (require, exports, tslib_1, Ajax, Core, Language, Util_1, Dialog_1) {
+define(["require", "exports", "tslib", "../../../Ajax", "../../../Core", "../../../Language", "../../../Dom/Util", "../../../Ui/Dialog", "WoltLabSuite/Core/Ajax/Backend"], function (require, exports, tslib_1, Ajax, Core, Language, Util_1, Dialog_1, Backend_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AcpUiDataImportManager = void 0;
redirectUrl;
currentAction = "";
index = -1;
- constructor(queue, redirectUrl) {
+ cacheClearEndpoint = "";
+ constructor(queue, redirectUrl, cacheClearEndpoint) {
this.queue = queue;
this.redirectUrl = redirectUrl;
- this.invoke();
+ this.cacheClearEndpoint = cacheClearEndpoint;
+ void this.invoke();
}
- invoke() {
+ async invoke() {
this.index++;
if (this.index >= this.queue.length) {
- Ajax.apiOnce({
- url: "index.php?cache-clear/&t=" + Core.getXsrfToken(),
- data: {
- noRedirect: 1,
- },
- silent: true,
- success: () => this.showCompletedDialog(),
- });
+ await (0, Backend_1.prepareRequest)(this.cacheClearEndpoint).post().fetchAsResponse();
+ this.showCompletedDialog();
}
else {
this.run(Language.get("wcf.acp.dataImport.data." + this.queue[this.index]), this.queue[this.index]);
});
}
else {
- this.invoke();
+ void this.invoke();
}
}
_dialogSetup() {
namespace wcf\acp\form;
+use wcf\acp\action\CacheClearAction;
use wcf\data\application\Application;
use wcf\data\object\type\ObjectTypeCache;
use wcf\form\AbstractForm;
use wcf\system\exception\IllegalLinkException;
use wcf\system\exception\UserInputException;
use wcf\system\importer\UserImporter;
+use wcf\system\request\LinkHandler;
use wcf\system\WCF;
use wcf\util\ArrayUtil;
use wcf\util\StringUtil;
$collator = new \Collator(WCF::getLanguage()->getLocale());
\uksort(
$this->exporters,
- static fn (string $a, string $b) => $collator->compare(
+ static fn(string $a, string $b) => $collator->compare(
WCF::getLanguage()->get('wcf.acp.dataImport.exporter.' . $a),
WCF::getLanguage()->get('wcf.acp.dataImport.exporter.' . $b)
)
'additionalData' => $this->additionalData,
]);
- WCF::getTPL()->assign('queue', $queue);
+ WCF::getTPL()->assign([
+ 'queue' => $queue,
+ 'cacheClearEndpoint' => LinkHandler::getInstance()->getControllerLink(CacheClearAction::class),
+ ]);
}
/**