Skip to content

Commit

Permalink
Merge pull request #3275 from mhsdesign/task/resourceCleanFollowup1678
Browse files Browse the repository at this point in the history
TASK: `resource:clean` followup #1678
  • Loading branch information
mhsdesign authored Mar 6, 2024
2 parents 201e73d + 7ac1303 commit 9f353e4
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions Neos.Flow/Classes/Command/ResourceCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ public function cleanCommand()
$resourcesCount = $this->resourceRepository->countAll();
$this->output->progressStart($resourcesCount);

/** @var list<PersistentResource> $brokenResources */
$brokenResources = [];
$relatedAssets = new \SplObjectStorage();
$relatedThumbnails = new \SplObjectStorage();
Expand All @@ -230,10 +231,9 @@ public function cleanCommand()
$this->clearState($iteration);
$iteration++;
$this->output->progressAdvance(1);
/* @var PersistentResource $resource */
$stream = $resource->getStream();
if (!is_resource($stream)) {
$brokenResources[] = $this->persistenceManager->getIdentifierByObject($resource);
$brokenResources[] = $resource;
}
}

Expand All @@ -246,9 +246,7 @@ public function cleanCommand()
$mediaPackagePresent = $this->packageManager->isPackageAvailable('Neos.Media');

if (count($brokenResources) > 0) {
foreach ($brokenResources as $key => $resourceIdentifier) {
$resource = $this->resourceRepository->findByIdentifier($resourceIdentifier);
$brokenResources[$key] = $resource;
foreach ($brokenResources as $resource) {
if ($mediaPackagePresent) {
$assets = $assetRepository->findByResource($resource);
if ($assets !== null) {
Expand All @@ -275,8 +273,8 @@ public function cleanCommand()
}
}
$response = null;
while (!in_array($response, ['y', 'n', 'c'])) {
$response = $this->output->ask('<comment>Do you want to remove all broken resource objects and related assets from the database? (y/n/c) </comment>');
while (!in_array($response, ['y', 'n'])) {
$response = $this->output->ask('<comment>Do you want to remove all broken resource objects and related assets from the database? (y/n) </comment>');
}

switch ($response) {
Expand Down Expand Up @@ -320,9 +318,6 @@ public function cleanCommand()
break;
case 'n':
$this->outputLine('Did not delete any resource objects.');
break;
case 'c':
$this->outputLine('Stopping. Did not delete any resource objects.');
$this->quit(0);
break;
}
Expand Down

0 comments on commit 9f353e4

Please sign in to comment.