From 97db4d26c61ac7ac67046412d4f6ac2427becc4b Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 20 Oct 2022 16:22:16 -0700 Subject: [PATCH] FiveFiftySix - Add pre-upgrade warning for deeply nested extension paths --- CRM/Upgrade/Incremental/php/FiveFiftySix.php | 36 ++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/CRM/Upgrade/Incremental/php/FiveFiftySix.php b/CRM/Upgrade/Incremental/php/FiveFiftySix.php index 896ccd1a39..b749886ff5 100644 --- a/CRM/Upgrade/Incremental/php/FiveFiftySix.php +++ b/CRM/Upgrade/Incremental/php/FiveFiftySix.php @@ -21,6 +21,42 @@ */ class CRM_Upgrade_Incremental_php_FiveFiftySix extends CRM_Upgrade_Incremental_Base { + public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NULL) { + if ($rev === '5.56.alpha1') { + $preUpgradeMessage .= $this->createDeepExtMessage(); + } + } + + /** + * In 5.56, the extension-system abides by a limit on the depth of search. + * This improves the performance of cache-clears. The default depth + * should catch most/all extensions on most/all sites -- but it's + * possible that some sites still need a deep search. + * + * @return string + */ + protected function createDeepExtMessage(): string { + $infinityAndBeyond = 1000; + $liveSystem = CRM_Extension_System::singleton(); + $deepSystem = new CRM_Extension_System(['maxDepth' => $infinityAndBeyond]); + $problemKeys = array_diff($deepSystem->getFullContainer()->getKeys(), $liveSystem->getFullContainer()->getKeys()); + if (empty($problemKeys)) { + return ''; + } + + $message = ts('When loading extensions, CiviCRM searches the filesystem. In v5.56+, the default search is more constrained. This improves performance, but some extensions (%1) will become invisible. To make these visible, you should either move the source-code or edit civicrm.settings.php. For example, you may add this line:', [ + 1 => implode(', ', array_map( + function($key) { + return '"' . htmlentities($key) . '"'; + }, + $problemKeys + )), + ]); + $example = htmlentities("\$civicrm_setting['domain']['ext_max_depth'] = $infinityAndBeyond;"); + + return "

" . ts('WARNING') . ": {$message}

$example
"; + } + /** * Upgrade step; adds tasks including 'runSql'. * -- 2.25.1