From: Joshua Rüsweg Date: Thu, 22 Nov 2018 09:31:45 +0000 (+0100) Subject: Support nicevalue for user content provider X-Git-Tag: 5.2.0_Alpha_1~493 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=cd972953ee2736e8ac25d1f36fb659528fa2dfdf;p=GitHub%2FWoltLab%2FWCF.git Support nicevalue for user content provider 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 1992a8c88b..5b6a772f71 100644 --- a/wcfsetup/install/files/lib/system/worker/UserContentRemoveWorker.class.php +++ b/wcfsetup/install/files/lib/system/worker/UserContentRemoveWorker.class.php @@ -105,6 +105,21 @@ 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; + }); + foreach ($contentProviders as $contentProvider) { if ($this->contentProvider === null || (is_array($this->contentProvider) && in_array($contentProvider->objectType, $this->contentProvider))) { /** @var IUserContentProvider $processor */ @@ -113,8 +128,9 @@ class UserContentRemoveWorker extends AbstractWorker implements IWorker { $count = $contentList->countObjects(); if ($count) { - $this->data['provider'][$contentProvider->objectTypeID] = [ - 'count' => $count + $this->data['provider'][$contentProvider->objectType] = [ + 'count' => $count, + 'objectTypeID' => $contentProvider->objectTypeID ]; $this->data['count'] += ceil($count / $this->limit) * $this->limit; @@ -139,20 +155,20 @@ class UserContentRemoveWorker extends AbstractWorker implements IWorker { } $values = array_keys($this->data['provider']); - $providerID = array_pop($values); + $providerObjectType = array_pop($values); /** @var IUserContentProvider $processor */ - $processor = ObjectTypeCache::getInstance()->getObjectType($providerID)->getProcessor(); + $processor = ObjectTypeCache::getInstance()->getObjectType($this->data['provider'][$providerObjectType]['objectTypeID'])->getProcessor(); $objectList = $processor->getContentListForUser($this->user); $objectList->sqlLimit = $this->limit; $objectList->readObjectIDs(); $processor->deleteContent($objectList->objectIDs); - $this->data['provider'][$providerID]['count'] -= $this->limit; + $this->data['provider'][$providerObjectType]['count'] -= $this->limit; - if ($this->data['provider'][$providerID]['count'] <= 0) { - unset($this->data['provider'][$providerID]); + if ($this->data['provider'][$providerObjectType]['count'] <= 0) { + unset($this->data['provider'][$providerObjectType]); } }