瀏覽代碼

fix bug where non empty upload_dir did not interrupt the deletion

Olivier Massot 5 年之前
父節點
當前提交
3235546417
共有 1 個文件被更改,包括 12 次插入6 次删除
  1. 12 6
      ot_admin/Classes/Controller/SiteController.php

+ 12 - 6
ot_admin/Classes/Controller/SiteController.php

@@ -622,17 +622,21 @@ class SiteController extends ActionController
             }
 
             // If hard deletion, verify that upload dirs are empty
-            if ($hard && is_file($uploadDir)) {
+            if ($hard && is_dir($uploadDir)) {
                 foreach (scandir($uploadDir) as $subdir) {
+                    if ($subdir == '.' or $subdir == '..') {
+                        continue;
+                    }
+                    $subdir = $uploadDir . $subdir;
                     if (!is_dir($subdir)) {
                         throw new \RuntimeException(
                             'The directory ' . $uploadDir . ' contains non-directory files' .
-                            ', this humble script prefers not to take care of them automatically. Cancel.');
+                            ', this humble script prefers not to take care of them automatically. Abort.');
                     }
                     if (is_readable($subdir) && count(scandir($subdir)) > 0) {
                         throw new \RuntimeException(
                             'The directory ' . $subdir . ' is not empty, ' .
-                            'this humble script prefers not to take care of them automatically. Cancel.');
+                            'this humble script prefers not to take care of them automatically. Abort.');
                     }
                 }
             }
@@ -959,6 +963,7 @@ class SiteController extends ActionController
 
     /**
      * Insert a new row in the 'pages' table of the Typo3 DB
+     * and return its uid
      *
      * @param Organization $organization
      * @param int $pid
@@ -966,7 +971,7 @@ class SiteController extends ActionController
      * @param string $slug
      * @param string $template
      * @param array $moreValues
-     * @return string
+     * @return int
      */
     private function insertPage(Organization $organization,
                                 int $pid,
@@ -1001,7 +1006,7 @@ class SiteController extends ActionController
             ->values($values)
             ->execute();
 
-        $uid = $queryBuilder->getConnection()->lastInsertId();
+        $uid = (int)$queryBuilder->getConnection()->lastInsertId();
 
         $this->createdPagesIndex[$slug] = $uid;
         return $uid;
@@ -1009,9 +1014,10 @@ class SiteController extends ActionController
 
     /**
      * Insert the root page of a new organization's website
+     * and return its uid
      *
      * @param Organization $organization
-     * @return string
+     * @return int
      */
     private function insertRootPage(Organization $organization) {
         return $this->insertPage(