Browse Source

fix bug where deleted sites throw an error when requested

Olivier Massot 4 năm trước cách đây
mục cha
commit
b7b9471a0b
1 tập tin đã thay đổi với 5 bổ sung1 xóa
  1. 5 1
      ot_core/Classes/Website/OtWebsiteRepository.php

+ 5 - 1
ot_core/Classes/Website/OtWebsiteRepository.php

@@ -333,7 +333,7 @@ class OtWebsiteRepository
      * @return Site
      * @throws NoSuchWebsiteException
      */
-    public function matchUriToWebsite(\Psr\Http\Message\UriInterface $uri, bool $devMode=false): array
+    public function matchUriToWebsite(\Psr\Http\Message\UriInterface $uri, bool $devMode=false, bool $withRestrictions = true): array
     {
         $queryBuilder = $this->connectionPool->getQueryBuilderForTable('ot_websites');
 
@@ -356,6 +356,10 @@ class OtWebsiteRepository
             }
         }
 
+        if ($withRestrictions) {
+            $q = $q->andWhere($queryBuilder->expr()->eq('deleted', 0));
+        }
+
         $website = $q->execute()
                     ->fetch();