From 68f290e966c92ec9bdfab27232f0a59f9fd54cea Mon Sep 17 00:00:00 2001
From: Prasad <prasad@vtiger.com>
Date: Tue, 8 Nov 2022 07:06:22 +0530
Subject: [PATCH] Fix for undefined variables usage - MR #877

---
 include/database/PearDatabase.php | 4 ++--
 include/utils/ListViewUtils.php   | 2 ++
 libraries/antlr/AntlrLexer.php    | 2 +-
 modules/Vtiger/models/Field.php   | 2 ++
 4 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/include/database/PearDatabase.php b/include/database/PearDatabase.php
index 29f1d970a..16831a4a3 100644
--- a/include/database/PearDatabase.php
+++ b/include/database/PearDatabase.php
@@ -399,7 +399,7 @@ class PearDatabase{
     {
 	//if(dbType=="oci8") return 'empty_blob()';
 	//else return 'null';
-	if (is_string) return 'null';
+	if ($is_string) return 'null';
 	return null;
     }
 
@@ -557,7 +557,7 @@ class PearDatabase{
 
     function sql_quote($data) {
 		if (is_array($data)) {
-			switch($data['type']) {
+			switch($cur = $data['type']) {
 			case 'text':
 			case 'numeric':
 			case 'integer':
diff --git a/include/utils/ListViewUtils.php b/include/utils/ListViewUtils.php
index 48cc3351f..027c71a0d 100755
--- a/include/utils/ListViewUtils.php
+++ b/include/utils/ListViewUtils.php
@@ -518,6 +518,8 @@ function getListQuery($module, $where = '') {
  */
 
 function setSessionVar($lv_array, $noofrows, $max_ent, $module = '', $related = '') {
+	global $currentModule;
+	
 	$start = '';
 	if ($noofrows >= 1) {
 		$lv_array['start'] = 1;
diff --git a/libraries/antlr/AntlrLexer.php b/libraries/antlr/AntlrLexer.php
index 05a7ae016..3f0954e6d 100644
--- a/libraries/antlr/AntlrLexer.php
+++ b/libraries/antlr/AntlrLexer.php
@@ -136,7 +136,7 @@ abstract class AntlrLexer extends BaseRecognizer{
 			}
 			$i++;
 			$this->input->consume();
-			$state->failed = false;
+			$this->state->failed = false;
 		}
 	}
 	
diff --git a/modules/Vtiger/models/Field.php b/modules/Vtiger/models/Field.php
index 0744e48d9..2177a25e1 100644
--- a/modules/Vtiger/models/Field.php
+++ b/modules/Vtiger/models/Field.php
@@ -1184,6 +1184,7 @@ class Vtiger_Field_Model extends Vtiger_Field {
 	 * @return <Array>
 	 */
 	public function getCurrencyList() {
+		$currencies = array();
 		$db = PearDatabase::getInstance();
 				// Not a good approach to get all the fields if not required(May leads to Performance issue)
 		$result = $db->pquery('SELECT id, currency_name FROM vtiger_currency_info WHERE currency_status = ? AND deleted=0', array('Active'));
@@ -1398,6 +1399,7 @@ class Vtiger_Field_Model extends Vtiger_Field {
 		foreach ($referenceList as $referenceModuleName) {
 			$autoFillData = $moduleModel->getAutoFillModuleAndField($referenceModuleName);
 			if($autoFillData) {
+				$newautoFillData = array();
 				foreach($autoFillData as $data) {
 					// To get the parent autofill reference field name of reference field
 					$referenceModuleModel = Vtiger_Module_Model::getInstance($referenceModuleName);
-- 
GitLab