From be6b085e502e5ca4151ae2e3509be844f84c749e Mon Sep 17 00:00:00 2001
From: prasad <prasad@vtiger.com>
Date: Sun, 5 May 2024 14:59:33 +0530
Subject: [PATCH] Improved install compatible to E_ALL

---
 include/utils/ConfigReader.php                            | 4 ++--
 include/utils/utils.php                                   | 4 ++--
 modules/Migration/schema/600_to_610.php                   | 4 ++--
 modules/Migration/views/Index.php                         | 2 +-
 modules/Settings/Vtiger/models/ConfigModule.php           | 3 ++-
 modules/Vtiger/models/MenuStructure.php                   | 2 +-
 modules/com_vtiger_workflow/VTTaskManager.inc             | 2 +-
 .../modules/CustomerPortal/settings/models/Module.php     | 1 +
 .../modules/ModTracker/modules/ModTracker/ModTracker.php  | 5 +++--
 vtlib/Vtiger/Functions.php                                | 8 +++++++-
 vtlib/Vtiger/PackageUpdate.php                            | 1 +
 vtlib/thirdparty/dUnzip2.inc.php                          | 4 +++-
 vtlib/thirdparty/network/Request.php                      | 4 +---
 13 files changed, 27 insertions(+), 17 deletions(-)

diff --git a/include/utils/ConfigReader.php b/include/utils/ConfigReader.php
index f97dcbdc9..efb99edc0 100644
--- a/include/utils/ConfigReader.php
+++ b/include/utils/ConfigReader.php
@@ -24,7 +24,7 @@ class ConfigReader {
 
 	function load($path, $name, $force = false) {
 		$this->name = $path;
-		if(!$force && isset(self::$propertiesCache) && self::$propertiesCache[$path]) {
+		if(!$force && isset(self::$propertiesCache) && isset(self::$propertiesCache[$path]) && self::$propertiesCache[$path]) {
 			$this->properties = self::$propertiesCache[$path];
 			return;
 		}
@@ -46,4 +46,4 @@ class ConfigReader {
 	}
 }
 
-?>
\ No newline at end of file
+?>
diff --git a/include/utils/utils.php b/include/utils/utils.php
index e3272830b..bd5b5dadd 100755
--- a/include/utils/utils.php
+++ b/include/utils/utils.php
@@ -2022,9 +2022,9 @@ function getCurrencyDecimalPlaces($user = null) {
     global $current_user;
 
 	$currency_decimal_places = 2;
-    if (!empty($user)) {
+    if (!empty($user) && isset($user->no_of_currency_decimals)) {
         $currency_decimal_places = $user->no_of_currency_decimals;
-    } else if ($current_user) {
+    } else if ($current_user && isset($current_user->no_of_currency_decimals)) {
         $currency_decimal_places = $current_user->no_of_currency_decimals;
     }
     return (int)$currency_decimal_places;
diff --git a/modules/Migration/schema/600_to_610.php b/modules/Migration/schema/600_to_610.php
index 72cc56cf0..1456d03f3 100644
--- a/modules/Migration/schema/600_to_610.php
+++ b/modules/Migration/schema/600_to_610.php
@@ -116,7 +116,7 @@ $unWanted=array(
  "modules/FieldFormulas/functional.js"
 );
 
-for($i=0, $len=php7_count($unWanted);$i<=$len;$i++){
+for($i=0, $len=php7_count($unWanted);$i<$len;$i++){
     if(file_exists($unWanted[$i])){
         unlink($unWanted[$i]);
     }
@@ -1551,4 +1551,4 @@ Migration_Index_View::ExecuteQuery("CREATE TABLE IF NOT EXISTS vtiger_reporttype
 
 //Configuration Editor fix
 $sql = "UPDATE vtiger_settings_field SET name = ? WHERE name = ?";
-Migration_Index_View::ExecuteQuery($sql,array('LBL_CONFIG_EDITOR', 'Configuration Editor'));
\ No newline at end of file
+Migration_Index_View::ExecuteQuery($sql,array('LBL_CONFIG_EDITOR', 'Configuration Editor'));
diff --git a/modules/Migration/views/Index.php b/modules/Migration/views/Index.php
index dade9e2ac..1170148e1 100644
--- a/modules/Migration/views/Index.php
+++ b/modules/Migration/views/Index.php
@@ -233,7 +233,7 @@ class Migration_Index_View extends Vtiger_View_Controller {
 					$fieldName = '('. $fieldName .')';
 				}
 
-				$groupId = $condition['groupid'];
+				$groupId = isset($condition['groupid']) ? $condition['groupid'] : null;
 				if (!$groupId) {
 					$groupId = 0;
 				}
diff --git a/modules/Settings/Vtiger/models/ConfigModule.php b/modules/Settings/Vtiger/models/ConfigModule.php
index 47ea1dace..26d3f2d22 100644
--- a/modules/Settings/Vtiger/models/ConfigModule.php
+++ b/modules/Settings/Vtiger/models/ConfigModule.php
@@ -75,6 +75,7 @@ class Settings_Vtiger_ConfigModule_Model extends Settings_Vtiger_Module_Model {
 						$fieldValue = explode(' = ', $configContent);
 						$fieldValue = $fieldValue[1];
 						if ($fieldName === 'upload_maxsize') {
+							$fieldValue = trim($fieldValue, ' ;');
 							$fieldValue = round(number_format($fieldValue / 1048576, 2));
 						}
 
@@ -168,4 +169,4 @@ class Settings_Vtiger_ConfigModule_Model extends Settings_Vtiger_Module_Model {
 		$moduleModel->getViewableData();
 		return $moduleModel;
 	}
-}
\ No newline at end of file
+}
diff --git a/modules/Vtiger/models/MenuStructure.php b/modules/Vtiger/models/MenuStructure.php
index fb05add1a..c0d111dcd 100644
--- a/modules/Vtiger/models/MenuStructure.php
+++ b/modules/Vtiger/models/MenuStructure.php
@@ -202,7 +202,7 @@ class Vtiger_MenuStructure_Model extends Vtiger_Base_Model {
 						$regroupMenuByParent[$app][$moduleName] = $moduleModel;
 					}
 				} else {
-					if(!in_array($moduleName, $ignoredModules)) {
+					if(!in_array($moduleName, $ignoredModules) && isset($oldToNewAppMap[$appName])) {
 						$app = $oldToNewAppMap[$appName];
 						$regroupMenuByParent[$app][$moduleName] = $moduleModel;
 					}                
diff --git a/modules/com_vtiger_workflow/VTTaskManager.inc b/modules/com_vtiger_workflow/VTTaskManager.inc
index 11630a23c..8f7058f73 100644
--- a/modules/com_vtiger_workflow/VTTaskManager.inc
+++ b/modules/com_vtiger_workflow/VTTaskManager.inc
@@ -28,7 +28,7 @@
 		 */
 		public function saveTask($task){
 			$adb = $this->adb;
-			if(is_numeric($task->id)){//How do I check whether a member exists in php?
+			if(isset($task->id) && is_numeric($task->id)){
 				$taskId = $task->id;
 				$adb->pquery("update com_vtiger_workflowtasks set summary=?, task=? where task_id=?",
 							array($task->summary, serialize($task), $taskId));
diff --git a/pkg/vtiger/modules/CustomerPortal/settings/models/Module.php b/pkg/vtiger/modules/CustomerPortal/settings/models/Module.php
index 45c422047..cf3d4f21c 100644
--- a/pkg/vtiger/modules/CustomerPortal/settings/models/Module.php
+++ b/pkg/vtiger/modules/CustomerPortal/settings/models/Module.php
@@ -12,6 +12,7 @@ class Settings_CustomerPortal_Module_Model extends Settings_Vtiger_Module_Model
 
 	var $name = 'CustomerPortal';
 	var $max_sequence = '';
+	var $portalModules = null;
 
 	/**
 	 * Function to get Current portal user
diff --git a/pkg/vtiger/modules/ModTracker/modules/ModTracker/ModTracker.php b/pkg/vtiger/modules/ModTracker/modules/ModTracker/ModTracker.php
index 49e4b647c..764835a3c 100644
--- a/pkg/vtiger/modules/ModTracker/modules/ModTracker/ModTracker.php
+++ b/pkg/vtiger/modules/ModTracker/modules/ModTracker/ModTracker.php
@@ -82,7 +82,8 @@ class ModTracker {
      * function gives an array of module names for which modtracking is enabled
     */
     function getModTrackerEnabledModules() {
-        global $adb;
+	    global $adb;
+		$modules = array();
         $moduleResult = $adb->pquery('SELECT * FROM vtiger_modtracker_tabs', array());
         for($i=0; $i<$adb->num_rows($moduleResult); $i++) {
             $tabId = $adb->query_result($moduleResult, $i, 'tabid');
@@ -395,4 +396,4 @@ class ModTracker {
         self::trackRelation($sourceModule, $sourceId, $targetModule, $targetId, self::$UNLINK);
     }
 }
-?>
\ No newline at end of file
+?>
diff --git a/vtlib/Vtiger/Functions.php b/vtlib/Vtiger/Functions.php
index e8690dce7..b4ffe79ff 100644
--- a/vtlib/Vtiger/Functions.php
+++ b/vtlib/Vtiger/Functions.php
@@ -164,7 +164,13 @@ class Vtiger_Functions {
 				self::$moduleNameIdCache[$row['name']]  = $row;
 			}
 		}
-		return $id ? self::$moduleIdNameCache[$id] : self::$moduleNameIdCache[$name];
+		if ($id && isset(self::$moduleIdNameCache[$id])) {
+			return self::$moduleIdNameCache[$id];
+		}
+		if ($name && isset(self::$moduleNameIdCache[$name])) {
+			return self::$moduleNameIdCache[$name];
+		}
+		return null;
 	}
 
 	static function getModuleData($mixed) {
diff --git a/vtlib/Vtiger/PackageUpdate.php b/vtlib/Vtiger/PackageUpdate.php
index a858705d1..f03cda8ea 100644
--- a/vtlib/Vtiger/PackageUpdate.php
+++ b/vtlib/Vtiger/PackageUpdate.php
@@ -16,6 +16,7 @@ include_once('vtlib/Vtiger/PackageImport.php');
 class Vtiger_PackageUpdate extends Vtiger_PackageImport {
 
 	var $_migrationinfo = false;
+	var $_migrations = false;
 
 	/**
 	 * Constructor
diff --git a/vtlib/thirdparty/dUnzip2.inc.php b/vtlib/thirdparty/dUnzip2.inc.php
index 893947dae..24b3ab1f6 100644
--- a/vtlib/thirdparty/dUnzip2.inc.php
+++ b/vtlib/thirdparty/dUnzip2.inc.php
@@ -224,8 +224,10 @@ class dUnzip2{
 				$fdetails['uncompressed_size'],
 				$targetFileName
 			);
-		if($applyChmod && $targetFileName)
+		if($applyChmod && $targetFileName) {
+			// TODO: check if this warning supression if its not working.
 			@chmod($targetFileName, $applyChmod == 0755? 0644 : $applyChmod);
+		}
 		
 		return $ret;
 	}
diff --git a/vtlib/thirdparty/network/Request.php b/vtlib/thirdparty/network/Request.php
index 8d1ee22a4..193b6e345 100644
--- a/vtlib/thirdparty/network/Request.php
+++ b/vtlib/thirdparty/network/Request.php
@@ -965,9 +965,7 @@ class HTTP_Request
 
             // "normal" POST request
             if (!isset($boundary)) {
-                $callback = function_exists('create_function')?
-                create_function('$a', 'return $a[0] . \'=\' . $a[1];') :
-                function ($a) { return $a[0] .'='. $a[1]; };
+                $callback = function ($a) { return $a[0] .'='. $a[1]; };
 
                 $postdata = implode('&', array_map($callback, $this->_flattenArray('', $this->_postData)));
 
-- 
GitLab