From e78fa18359c3134115652209c32fd3394818e1b6 Mon Sep 17 00:00:00 2001 From: odain-cbd <56586767+odain-cbd@users.noreply.github.com> Date: Tue, 31 Oct 2023 11:07:29 +0100 Subject: [PATCH 1/2] =?UTF-8?q?N=C2=B06849=20-=20Enhance=20setup=20error?= =?UTF-8?q?=20message=20in=20case=20of=20unmet=20module=20dependencies=20(?= =?UTF-8?q?#557)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * N°6849 - add cross/checkmark emoj to missing depenency message and remove unmet word * N°6849 - PR advice to avoid modifying aDeps --- setup/modulediscovery.class.inc.php | 59 +++++++++++++++++------------ 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/setup/modulediscovery.class.inc.php b/setup/modulediscovery.class.inc.php index bb642eb8d..fc86576d4 100644 --- a/setup/modulediscovery.class.inc.php +++ b/setup/modulediscovery.class.inc.php @@ -76,7 +76,7 @@ class ModuleDiscovery 'doc.manual_setup' => 'url', 'doc.more_information' => 'url', ); - + // Cache the results and the source directories protected static $m_aSearchDirs = null; @@ -148,7 +148,7 @@ class ModuleDiscovery self::$m_aModuleVersionByName[$sModuleName]['version'] = $sModuleVersion; self::$m_aModuleVersionByName[$sModuleName]['id'] = $sId; } - + self::$m_aModules[$sId] = $aArgs; // Now keep the relative paths, as provided @@ -220,8 +220,8 @@ class ModuleDiscovery public static function OrderModulesByDependencies($aModules, $bAbortOnMissingDependency = false, $aModulesToLoad = null) { // Order the modules to take into account their inter-dependencies - $aDependencies = array(); - $aSelectedModules = array(); + $aDependencies = []; + $aSelectedModules = []; foreach($aModules as $sId => $aModule) { list($sModuleName, ) = self::GetModuleName($sId); @@ -232,7 +232,7 @@ class ModuleDiscovery } } ksort($aDependencies); - $aOrderedModules = array(); + $aOrderedModules = []; $iLoopCount = 1; while(($iLoopCount < count($aModules)) && (count($aDependencies) > 0) ) { @@ -256,13 +256,24 @@ class ModuleDiscovery } if ($bAbortOnMissingDependency && count($aDependencies) > 0) { - $aModulesInfo = array(); - $aModuleDeps = array(); + $aModulesInfo = []; + $aModuleDeps = []; foreach($aDependencies as $sId => $aDeps) { $aModule = $aModules[$sId]; - $aModuleDeps[] = "{$aModule['label']} (id: $sId) depends on: ".implode(' + ', $aDeps); - $aModulesInfo[$sId] = array('module' => $aModule, 'dependencies' => $aDeps); + $aDepsWithIcons = []; + foreach($aDeps as $sIndex => $sDepId) + { + if (self::DependencyIsResolved($sDepId, $aOrderedModules, $aSelectedModules)) + { + $aDepsWithIcons[$sIndex] = '✅ ' . $sDepId; + } else + { + $aDepsWithIcons[$sIndex] = '❌ ' . $sDepId; + } + } + $aModuleDeps[] = "{$aModule['label']} (id: $sId) depends on: ".implode(' + ', $aDepsWithIcons); + $aModulesInfo[$sId] = array('module' => $aModule, 'dependencies' => $aDepsWithIcons); } $sMessage = "The following modules have unmet dependencies:\n".implode(",\n", $aModuleDeps); $oException = new MissingDependencyException($sMessage); @@ -289,7 +300,7 @@ class ModuleDiscovery // The de-duplication is now done directly by the AddModule method return $aModules; } - + protected static function DependencyIsResolved($sDepString, $aOrderedModules, $aSelectedModules) { $bResult = false; @@ -336,12 +347,12 @@ class ModuleDiscovery if (version_compare($sCurrentVersion, $sExpectedVersion, $sOperator)) { $aReplacements[$sModuleId] = '(true)'; // Add parentheses to protect against invalid condition causing - // a function call that results in a runtime fatal error + // a function call that results in a runtime fatal error } else { $aReplacements[$sModuleId] = '(false)'; // Add parentheses to protect against invalid condition causing - // a function call that results in a runtime fatal error + // a function call that results in a runtime fatal error } } else @@ -400,20 +411,20 @@ class ModuleDiscovery { self::ResetCache(); } - + if (is_null(self::$m_aSearchDirs)) { self::$m_aSearchDirs = $aSearchDirs; - + // Not in cache, let's scan the disk foreach($aSearchDirs as $sSearchDir) { - $sLookupDir = realpath($sSearchDir); + $sLookupDir = realpath($sSearchDir); if ($sLookupDir == '') { throw new Exception("Invalid directory '$sSearchDir'"); } - + clearstatcache(); self::ListModuleFiles(basename($sSearchDir), dirname($sSearchDir)); } @@ -425,7 +436,7 @@ class ModuleDiscovery return self::GetModules($bAbortOnMissingDependency, $aModulesToLoad); } } - + public static function ResetCache() { self::$m_aSearchDirs = null; @@ -437,7 +448,7 @@ class ModuleDiscovery * Helper function to interpret the name of a module * @param $sModuleId string Identifier of the module, in the form 'name/version' * @return array(name, version) - */ + */ public static function GetModuleName($sModuleId) { $aMatches = array(); @@ -466,7 +477,7 @@ class ModuleDiscovery { static $iDummyClassIndex = 0; $sDirectory = $sRootDir.'/'.$sRelDir; - + if ($hDir = opendir($sDirectory)) { // This is the correct way to loop over the directory. (according to the documentation) @@ -502,12 +513,12 @@ class ModuleDiscovery $idx++; } $bRet = eval($sModuleFileContents); - + if ($bRet === false) { SetupLog::Warning("Eval of $sRelDir/$sFile returned false"); } - + //echo "

Done.

\n"; } catch(ParseError $e) @@ -535,7 +546,7 @@ class ModuleDiscovery /** Alias for backward compatibility with old module files in which * the declaration of a module invokes SetupWebPage::AddModule() * whereas the new form is ModuleDiscovery::AddModule() - */ + */ class SetupWebPage extends ModuleDiscovery { // For backward compatibility with old modules... @@ -562,9 +573,9 @@ class SetupWebPage extends ModuleDiscovery public static function log($sText) { SetupLog::Ok($sText); - } + } } - + /** Ugly patch !!! * In order to be able to analyse / load several times * the same module file, we rename the class (to avoid duplicate class definitions) From cbb37f27d789ebf118cd92d030d1a4e9f7bea987 Mon Sep 17 00:00:00 2001 From: Molkobain Date: Mon, 30 Oct 2023 19:08:44 +0100 Subject: [PATCH 2/2] =?UTF-8?q?N=C2=B06866=20-=20Fix=20issue=20when=20crea?= =?UTF-8?q?ting=20new=20fields=20in=20Request=20Template=20in=20French?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DataTable/DataTableUIBlockFactory.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sources/application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php b/sources/application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php index 53bdfe4bd..ba210bee9 100644 --- a/sources/application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php +++ b/sources/application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php @@ -791,14 +791,14 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory $aColumnDefinition["type"] = "html"; if ($sAttCode == '_key_') { - $sAttrLabel = $aData['alias']; + $sAttLabel = $aData['alias']; $aColumnDefinition["title"] = $aData['alias']; $aColumnDefinition['metadata'] = [ 'object_class' => $sClassName, 'class_alias' => $sClassAlias, 'attribute_code' => $sAttCode, 'attribute_type' => '_key_', - 'attribute_label' => $sAttrLabel, + 'attribute_label' => $sAttLabel, ]; $aColumnDefinition["data"] = $sClassAlias."/".$sAttCode; $aColumnDefinition["render"] = [ @@ -806,8 +806,8 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory "_" => $sClassAlias."/".$sAttCode, ]; $aColumnDefinition["createdCell"] = << $sClassAlias."/".$sAttCode, ]; $aColumnDefinition["createdCell"] = <<