}
});
</script>
+{if $bulkProcessingID|isset}
+ <script data-relocate="true">
+ {jsphrase name='wcf.acp.worker.abort.confirmMessage'}
+ require(['WoltLabSuite/Core/Acp/Ui/Worker'], (AcpUiWorker) => {
+ new AcpUiWorker({
+ dialogId: 'bulkProcessing',
+ dialogTitle: '{jslang}{$pageTitle}{/jslang}',
+ className: 'wcf\\system\\worker\\BulkProcessingWorker',
+ parameters: {
+ bulkProcessingID: {@$bulkProcessingID},
+ },
+ });
+ });
+ </script>
+{/if}
<header class="contentHeader">
<h1 class="contentTitle">{lang}{$objectType->getProcessor()->getLanguageItemPrefix()}{/lang}</h1>
use wcf\form\AbstractForm;
use wcf\system\exception\IllegalLinkException;
use wcf\system\exception\UserInputException;
+use wcf\system\request\LinkHandler;
use wcf\system\WCF;
/**
}
parent::readData();
+
+ if (empty($_POST)) {
+ if (isset($_REQUEST['success']) && isset($_REQUEST['count'])) {
+ $this->affectedObjectCount = \intval($_REQUEST['count']);
+ WCF::getTPL()->assign('success', true);
+ }
+ }
}
/**
}
}
- // Set a limit to avoid the 'Prepared statement contains too many placeholders' error
- $this->objectList->sqlLimit = 65000;
+ $this->objectList->readObjectIDs();
- $this->objectList->readObjects();
-
- // execute action
- if (\count($this->objectList)) {
- $this->actions[$this->action]->getProcessor()->executeAction($this->objectList);
+ $this->affectedObjectCount = \count($this->objectList->getObjectIDs());
+ // save config in session
+ $bulkProcessingData = WCF::getSession()->getVar('bulkProcessingData');
+ if ($bulkProcessingData === null) {
+ $bulkProcessingData = [];
}
-
- $this->affectedObjectCount = \count($this->objectList);
+ $bulkProcessingData[$this->affectedObjectCount] = [
+ 'action' => $this->actions[$this->action]->getProcessor(),
+ 'objectIDs' => $this->objectList->getObjectIDs(),
+ 'form' => LinkHandler::getInstance()->getControllerLink(get_called_class(), [
+ 'isACP' => true,
+ 'success' => true,
+ 'count' => $this->affectedObjectCount,
+ ]),
+ ];
+ WCF::getSession()->register('bulkProcessingData', $bulkProcessingData);
$this->saved();
- // reset fields
- $this->actions[$this->action]->getProcessor()->reset();
-
- foreach ($this->conditions as $groupedObjectTypes) {
- foreach ($groupedObjectTypes as $objectType) {
- $objectType->getProcessor()->reset();
- }
- }
- $this->action = '';
-
- WCF::getTPL()->assign('success', true);
+ WCF::getTPL()->assign('bulkProcessingID', $this->affectedObjectCount);
}
/**
--- /dev/null
+<?php
+
+namespace wcf\system\worker;
+
+use wcf\system\bulk\processing\IBulkProcessingAction;
+use wcf\system\exception\SystemException;
+use wcf\system\WCF;
+
+/**
+ * @author Olaf Braun
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ */
+final class BulkProcessingWorker extends AbstractWorker
+{
+ /**
+ * @inheritDoc
+ */
+ protected $limit = 100;
+ protected array $bulkProcessingData;
+ protected IBulkProcessingAction $action;
+
+ #[\Override]
+ public function validate()
+ {
+ if (!isset($this->parameters['bulkProcessingID'])) {
+ throw new SystemException("bulkProcessingID missing");
+ }
+
+ $bulkProcessingData = WCF::getSession()->getVar('bulkProcessingData');
+ if (!isset($bulkProcessingData[$this->parameters['bulkProcessingID']])) {
+ throw new SystemException("bulkProcessingID '" . $this->parameters['bulkProcessingID'] . "' is invalid");
+ }
+
+ $this->bulkProcessingData = $bulkProcessingData[$this->parameters['bulkProcessingID']];
+ $this->action = $this->bulkProcessingData['action'];
+ }
+
+ #[\Override]
+ public function countObjects()
+ {
+ return \count($this->bulkProcessingData['objectIDs']);
+ }
+
+ #[\Override]
+ public function getProgress()
+ {
+ $progress = parent::getProgress();
+
+ if ($progress == 100) {
+ // clear session
+ $bulkProcessingData = WCF::getSession()->getVar('bulkProcessingData');
+ unset($bulkProcessingData[$this->parameters['bulkProcessingID']]);
+ WCF::getSession()->register('bulkProcessingData', $bulkProcessingData);
+ }
+
+ return $progress;
+ }
+
+ #[\Override]
+ public function execute()
+ {
+ $objectList = $this->action->getObjectList();
+ $objectList->setObjectIDs(
+ \array_slice($this->bulkProcessingData['objectIDs'], $this->limit * $this->loopCount, $this->limit)
+ );
+ $objectList->readObjects();
+
+ $this->action->executeAction($objectList);
+ }
+
+ #[\Override]
+ public function getProceedURL()
+ {
+ return $this->bulkProcessingData['form'];
+ }
+}