diff --git a/config/services/system/upgrades.yaml b/config/services/system/upgrades.yaml index b0fd7b03a..61b6d8b92 100644 --- a/config/services/system/upgrades.yaml +++ b/config/services/system/upgrades.yaml @@ -19,6 +19,126 @@ parameters: - '.env.local' - '.env.local.php' - 'tmp' + toKeepIgnore: + - 'public/legacy/modules/Accounts' + - 'public/legacy/modules/ACL' + - 'public/legacy/modules/ACLActions' + - 'public/legacy/modules/ACLRoles' + - 'public/legacy/modules/Activities' + - 'public/legacy/modules/Administration' + - 'public/legacy/modules/Alerts' + - 'public/legacy/modules/AM_ProjectTemplates' + - 'public/legacy/modules/AM_TaskTemplates' + - 'public/legacy/modules/AOBH_BusinessHours' + - 'public/legacy/modules/AOD_Index' + - 'public/legacy/modules/AOD_IndexEvent' + - 'public/legacy/modules/AOK_KnowledgeBase' + - 'public/legacy/modules/AOK_Knowledge_Base_Categories' + - 'public/legacy/modules/AOP_Case_Events' + - 'public/legacy/modules/AOP_Case_Updates' + - 'public/legacy/modules/AOR_Charts' + - 'public/legacy/modules/AOR_Conditions' + - 'public/legacy/modules/AOR_Fields' + - 'public/legacy/modules/AOR_Reports' + - 'public/legacy/modules/AOR_Scheduled_Reports' + - 'public/legacy/modules/AOS_Contracts' + - 'public/legacy/modules/AOS_Invoices' + - 'public/legacy/modules/AOS_Line_Item_Groups' + - 'public/legacy/modules/AOS_PDF_Templates' + - 'public/legacy/modules/AOS_Product_Categories' + - 'public/legacy/modules/AOS_Products' + - 'public/legacy/modules/AOS_Products_Quotes' + - 'public/legacy/modules/AOS_Quotes' + - 'public/legacy/modules/AOW_Actions' + - 'public/legacy/modules/AOW_Conditions' + - 'public/legacy/modules/AOW_Processed' + - 'public/legacy/modules/AOW_WorkFlow' + - 'public/legacy/modules/Audit' + - 'public/legacy/modules/BeanDictionary.php' + - 'public/legacy/modules/Bugs' + - 'public/legacy/modules/Calendar' + - 'public/legacy/modules/Calls' + - 'public/legacy/modules/Calls_Reschedule' + - 'public/legacy/modules/CampaignLog' + - 'public/legacy/modules/Campaigns' + - 'public/legacy/modules/CampaignTrackers' + - 'public/legacy/modules/Cases' + - 'public/legacy/modules/Charts' + - 'public/legacy/modules/Configurator' + - 'public/legacy/modules/Connectors' + - 'public/legacy/modules/Contacts' + - 'public/legacy/modules/Currencies' + - 'public/legacy/modules/Delegates' + - 'public/legacy/modules/DocumentRevisions' + - 'public/legacy/modules/Documents' + - 'public/legacy/modules/DynamicFields' + - 'public/legacy/modules/EAPM' + - 'public/legacy/modules/EmailAddresses' + - 'public/legacy/modules/EmailMan' + - 'public/legacy/modules/EmailMarketing' + - 'public/legacy/modules/Emails' + - 'public/legacy/modules/EmailTemplates' + - 'public/legacy/modules/EmailText' + - 'public/legacy/modules/Employees' + - 'public/legacy/modules/Favorites' + - 'public/legacy/modules/FP_Event_Locations' + - 'public/legacy/modules/FP_events' + - 'public/legacy/modules/Groups' + - 'public/legacy/modules/Help' + - 'public/legacy/modules/History' + - 'public/legacy/modules/Home' + - 'public/legacy/modules/iCals' + - 'public/legacy/modules/Import' + - 'public/legacy/modules/InboundEmail' + - 'public/legacy/modules/jjwg_Address_Cache' + - 'public/legacy/modules/jjwg_Areas' + - 'public/legacy/modules/jjwg_Maps' + - 'public/legacy/modules/jjwg_Markers' + - 'public/legacy/modules/LabelEditor' + - 'public/legacy/modules/Leads' + - 'public/legacy/modules/MailMerge' + - 'public/legacy/modules/Meetings' + - 'public/legacy/modules/MergeRecords' + - 'public/legacy/modules/ModuleBuilder' + - 'public/legacy/modules/MySettings' + - 'public/legacy/modules/Notes' + - 'public/legacy/modules/OAuth2Clients' + - 'public/legacy/modules/OAuth2Tokens' + - 'public/legacy/modules/OAuthKeys' + - 'public/legacy/modules/OAuthTokens' + - 'public/legacy/modules/Opportunities' + - 'public/legacy/modules/OptimisticLock' + - 'public/legacy/modules/OutboundEmailAccounts' + - 'public/legacy/modules/Project' + - 'public/legacy/modules/ProjectTask' + - 'public/legacy/modules/ProspectLists' + - 'public/legacy/modules/Prospects' + - 'public/legacy/modules/Relationships' + - 'public/legacy/modules/Releases' + - 'public/legacy/modules/Reminders' + - 'public/legacy/modules/Reminders_Invitees' + - 'public/legacy/modules/ResourceCalendar' + - 'public/legacy/modules/Roles' + - 'public/legacy/modules/SavedSearch' + - 'public/legacy/modules/Schedulers' + - 'public/legacy/modules/SchedulersJobs' + - 'public/legacy/modules/SecurityGroups' + - 'public/legacy/modules/Spots' + - 'public/legacy/modules/Studio' + - 'public/legacy/modules/SugarFeed' + - 'public/legacy/modules/SurveyQuestionOptions' + - 'public/legacy/modules/SurveyQuestionResponses' + - 'public/legacy/modules/SurveyQuestions' + - 'public/legacy/modules/SurveyResponses' + - 'public/legacy/modules/Surveys' + - 'public/legacy/modules/TableDictionary.php' + - 'public/legacy/modules/Tasks' + - 'public/legacy/modules/TemplateSectionLine' + - 'public/legacy/modules/Trackers' + - 'public/legacy/modules/UpgradeWizard' + - 'public/legacy/modules/UserPreferences' + - 'public/legacy/modules/Users' + - 'public/legacy/modules/vCals' toExpand: - 'public' - 'public/legacy' diff --git a/core/backend/Engine/Service/FolderSync/FolderComparator.php b/core/backend/Engine/Service/FolderSync/FolderComparator.php index 3741ac0cc..809a9c364 100644 --- a/core/backend/Engine/Service/FolderSync/FolderComparator.php +++ b/core/backend/Engine/Service/FolderSync/FolderComparator.php @@ -46,6 +46,16 @@ class FolderComparator implements FolderComparatorInterface */ protected $toKeepKeys = []; + /** + * @var string[] + */ + protected $toKeepIgnore = []; + + /** + * @var bool[] + */ + protected $toKeepIgnoreKeys = []; + /** * @var string[] */ @@ -107,16 +117,19 @@ class FolderComparator implements FolderComparatorInterface string $basePath = '' ): void { $origin = $this->newFinder($originPath)->files(); + $destination = $this->newDestinationFinder($destinationPath); + $destination->files(); if (!$origin->hasResults()) { + if ($destination->hasResults()) { + $this->addEntriesToRemove($destination, $manifest, $basePath); + } + return; } $this->addEntriesToCopy($origin, $manifest, $basePath); - $destination = $this->newDestinationFinder($destinationPath); - $destination->files(); - if (!$destination->hasResults()) { return; } @@ -216,10 +229,11 @@ class FolderComparator implements FolderComparatorInterface continue; } - if (empty($manifest[$pathFromBase]) && - !$this->isToKeep($pathFromBase) && - !$this->isToKeep($basePath) - ) { + if ($this->isToKeepPath($basePath, $pathFromBase)) { + continue; + } + + if (empty($manifest[$pathFromBase])) { $manifest[$pathFromBase] = $this->newManifestEntry($pathFromBase, 'delete', $entry->getType()); } } @@ -237,7 +251,6 @@ class FolderComparator implements FolderComparatorInterface /** * Set files to keep * @param array $toKeep - * @return array */ public function setToKeep(array $toKeep): void { @@ -258,6 +271,39 @@ class FolderComparator implements FolderComparatorInterface return $this->toKeepKeys; } + + /** + * Get Files to always look at origin, even if to keep + * @return array + */ + public function getToKeepIgnore(): array + { + return $this->toKeepIgnore; + } + + /** + * Set to keepIgnore + * @param array $toKeepIgnore + */ + public function setToKeepIgnore(array $toKeepIgnore): void + { + $this->toKeepIgnore = $toKeepIgnore; + $this->toKeepIgnoreKeys = []; + + foreach ($this->toKeepIgnore as $item) { + $this->toKeepIgnoreKeys[$item] = true; + } + } + + /** + * Get Files to always look at origin, even if to keep + * @return array + */ + protected function getToKeepIgnoreKeys(): array + { + return $this->toKeepIgnoreKeys; + } + /** * Add folder directories * @param string $originPath @@ -273,16 +319,19 @@ class FolderComparator implements FolderComparatorInterface ): void { $origin = $this->newFinder($originPath); $origin->directories(); + $destination = $this->newDestinationFinder($destinationPath); + $destination->directories(); if (!$origin->hasResults()) { + if ($destination->hasResults()) { + $this->addEntriesToRemove($destination, $manifest, $basePath); + } + return; } $this->addEntriesToCopy($origin, $manifest, $basePath); - $destination = $this->newDestinationFinder($destinationPath); - $destination->directories(); - if (!$destination->hasResults()) { return; } @@ -383,6 +432,16 @@ class FolderComparator implements FolderComparatorInterface return !empty($this->getToKeepKeys()[$path]); } + /** + * Check if path is to ignore toKeep + * @param string $path + * @return bool + */ + protected function isToKeepIgnore(string $path): bool + { + return !empty($this->getToKeepIgnoreKeys()[$path]); + } + /** * Check if path is to expand * @param string $path @@ -392,4 +451,18 @@ class FolderComparator implements FolderComparatorInterface { return !empty($this->getPathsToExpandKeys()[$path]); } + + /** + * @param $basePath + * @param string $pathFromBase + * @return bool + */ + protected function isToKeepPath($basePath, string $pathFromBase): bool + { + if ($this->isToKeepIgnore($pathFromBase)) { + return false; + } + + return $this->isToKeep($pathFromBase) || $this->isToKeep($basePath); + } } diff --git a/core/backend/Install/Service/Upgrade/UpgradePackageHandler.php b/core/backend/Install/Service/Upgrade/UpgradePackageHandler.php index 5e4f7d44b..fda2770a7 100644 --- a/core/backend/Install/Service/Upgrade/UpgradePackageHandler.php +++ b/core/backend/Install/Service/Upgrade/UpgradePackageHandler.php @@ -84,6 +84,7 @@ class UpgradePackageHandler extends PackageHandler $this->compare = $compare; $this->compare->setToKeep($upgradeConfig['toKeep']); + $this->compare->setToKeepIgnore($upgradeConfig['toKeepIgnore']); $this->compare->setPathsToExpand($upgradeConfig['toExpand']); $this->upgradeLogger = $upgradeLogger; }