Since changes to the sitemap are saved directly in the object type, there is the problem that when you update the WCF, these changes are potentially overwritten again. This commit fixes this problem by saving changes in the registry.
Fixes #3376
<?php
namespace wcf\acp\form;
use wcf\data\object\type\ObjectType;
-use wcf\data\object\type\ObjectTypeAction;
use wcf\data\object\type\ObjectTypeCache;
use wcf\form\AbstractForm;
use wcf\system\exception\IllegalLinkException;
use wcf\system\exception\UserInputException;
+use wcf\system\registry\RegistryHandler;
use wcf\system\WCF;
+use wcf\system\worker\SitemapRebuildWorker;
/**
* Shows the sitemap edit form.
parent::readData();
if (empty($_POST)) {
- if ($this->objectType->priority !== null) $this->priority = $this->objectType->priority;
- if ($this->objectType->changeFreq !== null) $this->changeFreq = $this->objectType->changeFreq;
- if ($this->objectType->rebuildTime !== null) $this->rebuildTime = $this->objectType->rebuildTime;
- if ($this->objectType->isDisabled !== null) $this->isDisabled = $this->objectType->isDisabled;
+ $sitemapData = RegistryHandler::getInstance()->get('com.woltlab.wcf', SitemapRebuildWorker::REGISTRY_PREFIX . $this->objectTypeName);
+ $sitemapData = @unserialize($sitemapData);
+
+ if (is_array($sitemapData)) {
+ $this->priority = $sitemapData['priority'];
+ $this->changeFreq = $sitemapData['changeFreq'];
+ $this->rebuildTime = $sitemapData['rebuildTime'];
+ $this->isDisabled = $sitemapData['isDisabled'];
+ }
+ else {
+ if ($this->objectType->priority !== null) $this->priority = $this->objectType->priority;
+ if ($this->objectType->changeFreq !== null) $this->changeFreq = $this->objectType->changeFreq;
+ if ($this->objectType->rebuildTime !== null) $this->rebuildTime = $this->objectType->rebuildTime;
+ if ($this->objectType->isDisabled !== null) $this->isDisabled = $this->objectType->isDisabled;
+ }
}
}
public function save() {
parent::save();
- $data = array_merge($this->objectType->additionalData, [
+ RegistryHandler::getInstance()->set('com.woltlab.wcf', SitemapRebuildWorker::REGISTRY_PREFIX . $this->objectTypeName, serialize([
'priority' => $this->priority,
'changeFreq' => $this->changeFreq,
'rebuildTime' => $this->rebuildTime,
- 'isDisabled' => $this->isDisabled
- ]);
-
- $this->objectAction = new ObjectTypeAction([$this->objectType], 'update', [
- 'data' => [
- 'additionalData' => serialize($data)
- ]
- ]);
- $this->objectAction->executeAction();
+ 'isDisabled' => $this->isDisabled,
+ ]));
$this->saved();
use wcf\data\object\type\ObjectTypeCache;
use wcf\page\AbstractPage;
use wcf\system\WCF;
+use wcf\system\worker\SitemapRebuildWorker;
/**
* Shows a list of sitemap object types.
parent::readData();
$this->sitemapObjectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.sitemap.object');
+
+ foreach ($this->sitemapObjectTypes as $sitemapObjectType) {
+ SitemapRebuildWorker::prepareSitemapObject($sitemapObjectType);
+ }
}
/**
namespace wcf\data\object\type;
use wcf\data\IToggleAction;
use wcf\system\exception\IllegalLinkException;
+use wcf\system\registry\RegistryHandler;
use wcf\system\WCF;
+use wcf\system\worker\SitemapRebuildWorker;
/**
* Executes sitemap object type-related actions.
*/
public function toggle() {
foreach ($this->getObjects() as $objectEditor) {
- $objectEditor->update([
- 'additionalData' => serialize(array_merge($objectEditor->additionalData, ['isDisabled' => !$objectEditor->isDisabled ? 1 : 0]))
- ]);
+ $sitemapData = RegistryHandler::getInstance()->get('com.woltlab.wcf', SitemapRebuildWorker::REGISTRY_PREFIX . $objectEditor->objectType);
+ $sitemapData = @unserialize($sitemapData);
+
+ if (is_array($sitemapData)) {
+ $sitemapData['isDisabled'] = $sitemapData['isDisabled'] ? 0 : 1;
+ }
+ else {
+ $sitemapData = [
+ 'priority' => $objectEditor->priority,
+ 'changeFreq' => $objectEditor->changeFreq,
+ 'rebuildTime' => $objectEditor->rebuildTime,
+ 'isDisabled' => $objectEditor->isDisabled ? 0 : 1,
+ ];
+ }
+
+ RegistryHandler::getInstance()->set('com.woltlab.wcf', SitemapRebuildWorker::REGISTRY_PREFIX . $objectEditor->objectType, serialize($sitemapData));
}
}
use wcf\system\exception\ParentClassException;
use wcf\system\io\AtomicWriter;
use wcf\system\io\File;
+use wcf\system\registry\RegistryHandler;
use wcf\system\request\LinkHandler;
use wcf\system\Regex;
use wcf\system\WCF;
*/
const SITEMAP_OBJECT_LIMIT = 50000;
+ const REGISTRY_PREFIX = 'sitemapData_';
+
/**
* @inheritDoc
*/
// read sitemaps
$sitemapObjects = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.sitemap.object');
foreach ($sitemapObjects as $sitemapObject) {
+ self::prepareSitemapObject($sitemapObject);
$processor = $sitemapObject->getProcessor();
if ($processor->isAvailableType() && ($sitemapObject->isDisabled === null || !$sitemapObject->isDisabled)) {
private function changeToActualUser() {
WCF::getSession()->changeUser($this->actualUser, true);
}
+
+ /**
+ * Reads the columns changed by the user for this sitemap object from the registry and modifies the object accordingly.
+ *
+ * @param ObjectType $object
+ */
+ public static function prepareSitemapObject(ObjectType &$object) {
+ $sitemapData = RegistryHandler::getInstance()->get('com.woltlab.wcf', self::REGISTRY_PREFIX . $object->objectType);
+
+ if ($sitemapData !== null) {
+ $sitemapData = @unserialize($sitemapData);
+
+ if (is_array($sitemapData)) {
+ $object->priority = $sitemapData['priority'];
+ $object->changeFreq = $sitemapData['changeFreq'];
+ $object->rebuildTime = $sitemapData['rebuildTime'];
+ $object->isDisabled = $sitemapData['isDisabled'];
+ }
+ }
+ }
}