Browse Source

N°1092.1 Setup / MTP improvements regarding the environments folders:
- /env-production-build rights check before running setup
- /env-xxx-build is no longer deleted after MTT / MTP from the ITSM Designer. This prevents permissions issue when webserver user doesn't have suffisant rights on the root folder.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@5023 a333f486-631f-4898-b8df-5754b55c2be0

glajarige 7 years ago
parent
commit
4d18b176c4
2 changed files with 23 additions and 16 deletions
  1. 7 4
      setup/runtimeenv.class.inc.php
  2. 16 12
      setup/setuputils.class.inc.php

+ 7 - 4
setup/runtimeenv.class.inc.php

@@ -947,7 +947,9 @@ class RunTimeEnvironment
 			);
 			$this->CommitDir(
 				APPROOT.'env-'.$this->sTargetEnv,
-				APPROOT.'env-'.$this->sFinalEnv
+				APPROOT.'env-'.$this->sFinalEnv,
+                true,
+                false
 			);
 
 			// Move the config file
@@ -1013,14 +1015,15 @@ class RunTimeEnvironment
 	 *
 	 * @param $sSource
 	 * @param $sDest
-	 * @param bool $bSourceMustExist
+	 * @param boolean $bSourceMustExist
+     * @param boolean $bRemoveSource If true $sSource will be removed, otherwise $sSource will just be emptied
 	 * @throws Exception
 	 */
-	protected function CommitDir($sSource, $sDest, $bSourceMustExist = true)
+	protected function CommitDir($sSource, $sDest, $bSourceMustExist = true, $bRemoveSource = true)
 	{
 		if (file_exists($sSource))
 		{
-			SetupUtils::movedir($sSource, $sDest);
+			SetupUtils::movedir($sSource, $sDest, $bRemoveSource);
 		}
 		else
 		{

+ 16 - 12
setup/setuputils.class.inc.php

@@ -82,7 +82,7 @@ class SetupUtils
 		}
 		
 		// Check the common directories
-		$aWritableDirsErrors = self::CheckWritableDirs(array('log', 'env-production', 'conf', 'data'));
+		$aWritableDirsErrors = self::CheckWritableDirs(array('log', 'env-production', 'env-production-build', 'conf', 'data'));
 		$aResult = array_merge($aResult, $aWritableDirsErrors);
 		
 		$aMandatoryExtensions = array('mysqli', 'iconv', 'simplexml', 'soap', 'hash', 'json', 'session', 'pcre', 'dom', 'phar', 'zlib', 'zip');
@@ -691,16 +691,17 @@ class SetupUtils
 		}
 	}
 
-    /**
-     * Helper to move a directory when the parent directory of the target dir cannot be written
-     * To be used as alternative to rename()
-     * Files/Subdirs of the source directory are moved one by one
-     * Returns void
-     * @param $sSource
-     * @param $sDest
-     * @throws Exception
-     */
-	public static function movedir($sSource, $sDest)
+	/**
+	 * Helper to move a directory when the parent directory of the target dir cannot be written
+	 * To be used as alternative to rename()	 	 
+	 * Files/Subdirs of the source directory are moved one by one
+	 * Returns void
+     *
+     * @param string $sSource
+     * @param string $sDest
+     * @param boolean $bRemoveSource If true $sSource will be removed, otherwise $sSource will just be emptied
+	 */
+	public static function movedir($sSource, $sDest, $bRemoveSource = true)
 	{
 		if (!is_dir($sSource))
 		{
@@ -717,7 +718,10 @@ class SetupUtils
 
 		self::copydir($sSource, $sDest);
 		self::tidydir($sSource);
-		rmdir($sSource);
+		if($bRemoveSource === true)
+        {
+            rmdir($sSource);
+        }
 
 		/**
 		 * We have tried the following implementation (based on a rename/mv)