Ver código fonte

throw an error when two websites exist for one structure

Olivier Massot 4 anos atrás
pai
commit
7ea53a9f55
1 arquivos alterados com 7 adições e 2 exclusões
  1. 7 2
      ot_admin/Classes/Controller/SiteController.php

+ 7 - 2
ot_admin/Classes/Controller/SiteController.php

@@ -1633,14 +1633,19 @@ class SiteController extends ActionController
     {
         $queryBuilder = $this->connectionPool->getQueryBuilderForTable('pages');
         $queryBuilder->getRestrictions()->removeAll();
-        $rootUid = $queryBuilder
+        $rows = $queryBuilder
             ->select('uid')
             ->from('pages')
             ->where('is_siteroot=1')
             ->andWhere($queryBuilder->expr()->eq('tx_opentalent_structure_id', $organizationId))
             ->execute()
-            ->fetchColumn(0);
+            ->fetchAll();
+
+        if (count($rows) > 1) {
+            throw new \RuntimeException("More than one website match this organization id");
+        }
 
+        $rootUid = (int)$rows[0]['uid'];
         if ($rootUid > 0) {
             return $rootUid;
         }