From: Joshua Rüsweg Date: Sun, 25 Nov 2018 14:46:33 +0000 (+0100) Subject: Fix sorting object types in content remove worker X-Git-Tag: 5.2.0_Alpha_1~489 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=50f6659830c28a2ba07f52aa0bc233d0a3a600dd;p=GitHub%2FWoltLab%2FWCF.git Fix sorting object types in content remove worker See #2716 --- diff --git a/wcfsetup/install/files/lib/system/worker/UserContentRemoveWorker.class.php b/wcfsetup/install/files/lib/system/worker/UserContentRemoveWorker.class.php index 2e40e718f3..f94119ff54 100644 --- a/wcfsetup/install/files/lib/system/worker/UserContentRemoveWorker.class.php +++ b/wcfsetup/install/files/lib/system/worker/UserContentRemoveWorker.class.php @@ -105,21 +105,6 @@ class UserContentRemoveWorker extends AbstractWorker implements IWorker { $contentProviders = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.content.userContentProvider'); - // sort object types - uasort($contentProviders, function ($a, $b) { - $niceValueA = ($a->nicevalue ?: 0); - $niceValueB = ($b->nicevalue ?: 0); - - if ($niceValueA < $niceValueB) { - return -1; - } - else if ($niceValueA > $niceValueB) { - return 1; - } - - return 0; - }); - // add the required object types for the select content provider if (is_array($this->contentProvider)) { foreach ($this->contentProvider as $contentProvider) { @@ -135,7 +120,7 @@ class UserContentRemoveWorker extends AbstractWorker implements IWorker { throw new \RuntimeException('Unknown required object type "' . $objectTypeName . '" for object type "' . $contentProvider . '" given.'); } - $this->contentProvider[] = $objectType; + $this->contentProvider[] = $objectTypeName; } } } @@ -151,13 +136,29 @@ class UserContentRemoveWorker extends AbstractWorker implements IWorker { if ($count) { $this->data['provider'][$contentProvider->objectType] = [ 'count' => $count, - 'objectTypeID' => $contentProvider->objectTypeID + 'objectTypeID' => $contentProvider->objectTypeID, + 'nicevalue' => $contentProvider->nicevalue ?: 0 ]; $this->data['count'] += ceil($count / $this->limit) * $this->limit; } } } + + // sort object types + uasort($this->data['provider'], function ($a, $b) { + $niceValueA = ($a['nicevalue'] ?: 0); + $niceValueB = ($b['nicevalue'] ?: 0); + + if ($niceValueA < $niceValueB) { + return -1; + } + else if ($niceValueA > $niceValueB) { + return 1; + } + + return 0; + }); } /** @@ -173,10 +174,10 @@ class UserContentRemoveWorker extends AbstractWorker implements IWorker { public function execute() { if (empty($this->data['provider'])) { return; - } + } $values = array_keys($this->data['provider']); - $providerObjectType = array_pop($values); + $providerObjectType = array_shift($values); /** @var IUserContentProvider $processor */ $processor = ObjectTypeCache::getInstance()->getObjectType($this->data['provider'][$providerObjectType]['objectTypeID'])->getProcessor();