From 80813dba2275d12db0807cb3b30537013e48d688 Mon Sep 17 00:00:00 2001 From: Eric Espie Date: Thu, 30 Apr 2026 14:35:29 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B09503=20-=20Setup=20wizard=20:=20fix=20sy?= =?UTF-8?q?mlinks=20for=20data/production-modules?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup/runtimeenv.class.inc.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/setup/runtimeenv.class.inc.php b/setup/runtimeenv.class.inc.php index e2bcfcf66f..74d9667d9d 100644 --- a/setup/runtimeenv.class.inc.php +++ b/setup/runtimeenv.class.inc.php @@ -1020,6 +1020,8 @@ class RunTimeEnvironment false ); + $this->RerouteSymlinks(APPROOT.'env-'.$this->sFinalEnv, utils::GetDataPath().$this->sBuildEnv.'-modules/', utils::GetDataPath().$this->sFinalEnv.'-modules/'); + // Move the config file // $sBuildConfig = APPCONF.$this->sBuildEnv.'/config-itop.php'; @@ -1636,4 +1638,34 @@ class RunTimeEnvironment return $aModulesToLoad; } + + /** + * Replace target for links in sToScan from sSource to sDest + * + * @param string $sToScan where to search for symlinks + * @param string $sSource part to replace in the link target + * @param string $sDest replacement in the link target + * + * @return void + */ + private function RerouteSymlinks(string $sToScan, string $sSource, string $sDest) + { + if (is_dir($sToScan)) { + $aFiles = scandir($sToScan); + if (sizeof($aFiles) > 0) { + foreach ($aFiles as $sFile) { + if ($sFile == '.' || $sFile == '..' || $sFile == '.svn' || $sFile == '.git') { + // Skip + continue; + } + $this->RerouteSymlinks($sToScan.'/'.$sFile, $sSource, $sDest); + } + } + } elseif (is_link($sToScan)) { + $sLinkPath = readlink($sToScan); + $sLinkPath = str_replace($sSource, $sDest, $sLinkPath); + unlink($sToScan); + symlink($sLinkPath, $sToScan); + } + } }