浏览代码

remove the ambivalent 'hard' option of the update CLI command

Olivier Massot 4 年之前
父节点
当前提交
878a3191ab
共有 2 个文件被更改,包括 11 次插入32 次删除
  1. 3 11
      ot_admin/Classes/Command/UpdateSiteCommand.php
  2. 8 21
      ot_admin/Classes/Controller/SiteController.php

+ 3 - 11
ot_admin/Classes/Command/UpdateSiteCommand.php

@@ -46,12 +46,6 @@ class UpdateSiteCommand extends Command
                 'organization-id',
                 'organization-id',
                 InputArgument::OPTIONAL,
                 InputArgument::OPTIONAL,
                 "The organization's id in the opentalent DB"
                 "The organization's id in the opentalent DB"
-            )
-            ->addOption(
-                'hard',
-                null,
-                InputOption::VALUE_NONE,
-                "Performs an hard update (recreate the site config file, reset the be_users permissions)"
             );
             );
     }
     }
 
 
@@ -79,8 +73,6 @@ class UpdateSiteCommand extends Command
 
 
         $siteController = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
         $siteController = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
 
 
-        $msg_hard = $hard ? 'hardly ' : '';
-
         if ($all) {
         if ($all) {
             $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
             $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
             $queryBuilder = $connectionPool->getQueryBuilderForTable('ot_websites');
             $queryBuilder = $connectionPool->getQueryBuilderForTable('ot_websites');
@@ -97,7 +89,7 @@ class UpdateSiteCommand extends Command
             foreach ($sites as $site) {
             foreach ($sites as $site) {
                 $org_id = $site['organization_id'];
                 $org_id = $site['organization_id'];
                 try {
                 try {
-                    $siteController->updateSiteAction($org_id, $hard);
+                    $siteController->updateSiteAction($org_id);
                 } catch (\Throwable $e) {
                 } catch (\Throwable $e) {
                     $io->error('Organization Id: ' . $org_id . ' - ' . $e->getMessage());
                     $io->error('Organization Id: ' . $org_id . ' - ' . $e->getMessage());
                 }
                 }
@@ -105,10 +97,10 @@ class UpdateSiteCommand extends Command
             }
             }
             $io->progressFinish();
             $io->progressFinish();
 
 
-            $io->success(sprintf("The websites have all been " . $msg_hard . "updated"));
+            $io->success(sprintf("The websites have all been updated"));
         } else {
         } else {
             $rootUid = $siteController->updateSiteAction($org_id, $hard);
             $rootUid = $siteController->updateSiteAction($org_id, $hard);
-            $io->success(sprintf("The website with root uid " . $rootUid . " has been " . $msg_hard . "updated"));
+            $io->success(sprintf("The website with root uid " . $rootUid . " has been updated"));
         }
         }
     }
     }
 }
 }

+ 8 - 21
ot_admin/Classes/Controller/SiteController.php

@@ -640,7 +640,7 @@ class SiteController extends ActionController
      * @throws \Doctrine\DBAL\DBALException
      * @throws \Doctrine\DBAL\DBALException
      * @throws \Throwable
      * @throws \Throwable
      */
      */
-    public function updateSiteAction(int $organizationId, bool $hard=false): int
+    public function updateSiteAction(int $organizationId): int
     {
     {
         $website = $this->otWebsiteRepository->getWebsiteByOrganizationId($organizationId);
         $website = $this->otWebsiteRepository->getWebsiteByOrganizationId($organizationId);
         $rootUid = $this->otWebsiteRepository->getWebsiteRootUid($website['uid']);
         $rootUid = $this->otWebsiteRepository->getWebsiteRootUid($website['uid']);
@@ -652,9 +652,6 @@ class SiteController extends ActionController
         // the prod-back DB directly.
         // the prod-back DB directly.
         $organizationExtraData = $this->fetchOrganizationExtraData($organizationId);
         $organizationExtraData = $this->fetchOrganizationExtraData($organizationId);
 
 
-        // Get the website config identifier if exists
-        $identifier = $this->otWebsiteRepository->findConfigIdentifierFor($rootUid);
-
         // start transactions
         // start transactions
         $this->connectionPool->getConnectionByName('Default')->beginTransaction();
         $this->connectionPool->getConnectionByName('Default')->beginTransaction();
 
 
@@ -663,14 +660,11 @@ class SiteController extends ActionController
 
 
             // ## Update the ot_website table
             // ## Update the ot_website table
             $queryBuilder = $this->connectionPool->getQueryBuilderForTable('ot_websites');
             $queryBuilder = $this->connectionPool->getQueryBuilderForTable('ot_websites');
-            $q = $queryBuilder->update('ot_websites')
+            $queryBuilder->update('ot_websites')
                 ->set('subdomain', $organization->getSubDomain())
                 ->set('subdomain', $organization->getSubDomain())
-                ->set('organization_name', $organization->getName());
-            if ($identifier) {
-                $q->set('config_identifier', $identifier);
-            }
-            $q->where($queryBuilder->expr()->eq('uid', $website['uid']))
-              ->execute();
+                ->set('organization_name', $organization->getName())
+                ->where($queryBuilder->expr()->eq('uid', $website['uid']))
+                ->execute();
             
             
             // ## Update the subpages of the rootpage
             // ## Update the subpages of the rootpage
             $sitePages = $this->otPageRepository->getAllSubpagesForPage($rootUid);
             $sitePages = $this->otPageRepository->getAllSubpagesForPage($rootUid);
@@ -682,11 +676,9 @@ class SiteController extends ActionController
                     ->execute();
                     ->execute();
             }
             }
 
 
-            // ## Update the config.yaml file
-            if ($hard) {
-                $organizationDomain = $this->otWebsiteRepository->resolveWebsiteDomain($website);
-                $this->writeConfigFile($organizationId, $rootUid, $organizationDomain, true);
-            }
+            // ## Update the config.yaml file and the ot_websites.config_identifier field
+            $organizationDomain = $this->otWebsiteRepository->resolveWebsiteDomain($website);
+            $this->writeConfigFile($organizationId, $rootUid, $organizationDomain, true);
 
 
             // ## Update the `sys_template`.`constants` and the `pages`.`TSConfig` fields
             // ## Update the `sys_template`.`constants` and the `pages`.`TSConfig` fields
             $constants = $this->getTemplateConstants($organizationId, $organizationExtraData);
             $constants = $this->getTemplateConstants($organizationId, $organizationExtraData);
@@ -705,11 +697,6 @@ class SiteController extends ActionController
                 ->where($queryBuilder->expr()->eq('uid', $rootUid))
                 ->where($queryBuilder->expr()->eq('uid', $rootUid))
                 ->execute();
                 ->execute();
 
 
-            // ## Reset the users permissions
-            if ($hard) {
-                $this->resetBeUserPermsAction($organizationId, true);
-            }
-
             // Try to commit the result
             // Try to commit the result
             $commitSuccess = $this->connectionPool->getConnectionByName('Default')->commit();
             $commitSuccess = $this->connectionPool->getConnectionByName('Default')->commit();
             if (!$commitSuccess) {
             if (!$commitSuccess) {