]> BookStack Code Mirror - bookstack/blobdiff - app/Services/ImageService.php
Spanish translation
[bookstack] / app / Services / ImageService.php
index d1193ab4fd3d74787a0f2de13f541bed0bb8e859..7b73c457c08ec76e5d490e1971b7bb1e230b8189 100644 (file)
@@ -306,35 +306,35 @@ class ImageService extends UploadService
      *
      * Returns the path of the images that would be/have been deleted.
      * @param bool $checkRevisions
-     * @param array $types
      * @param bool $dryRun
+     * @param array $types
      * @return array
      */
-    public function deleteUnusedImages($checkRevisions = true, $types = ['gallery', 'drawio'], $dryRun = true)
+    public function deleteUnusedImages($checkRevisions = true, $dryRun = true, $types = ['gallery', 'drawio'])
     {
         $types = array_intersect($types, ['gallery', 'drawio']);
         $deletedPaths = [];
 
         $this->image->newQuery()->whereIn('type', $types)
-            ->chunk(1000, function($images) use ($types, $checkRevisions, &$deletedPaths, $dryRun) {
-             foreach ($images as $image) {
-                 $searchQuery = '%' . basename($image->path) . '%';
-                 $inPage = DB::table('pages')
+            ->chunk(1000, function ($images) use ($types, $checkRevisions, &$deletedPaths, $dryRun) {
+                foreach ($images as $image) {
+                    $searchQuery = '%' . basename($image->path) . '%';
+                    $inPage = DB::table('pages')
                          ->where('html', 'like', $searchQuery)->count() > 0;
-                 $inRevision = false;
-                 if ($checkRevisions) {
-                     $inRevision =  DB::table('page_revisions')
+                    $inRevision = false;
+                    if ($checkRevisions) {
+                        $inRevision =  DB::table('page_revisions')
                              ->where('html', 'like', $searchQuery)->count() > 0;
-                 }
-
-                 if (!$inPage && !$inRevision) {
-                     $deletedPaths[] = $image->path;
-                     if (!$dryRun) {
-                         $this->destroy($image);
-                     }
-                 }
-             }
-        });
+                    }
+
+                    if (!$inPage && !$inRevision) {
+                        $deletedPaths[] = $image->path;
+                        if (!$dryRun) {
+                            $this->destroy($image);
+                        }
+                    }
+                }
+            });
         return $deletedPaths;
     }