Browse Source

remove instances where a pointer is used in a foreach loop for value (#7108)

frytimo 1 year ago
parent
commit
5c2a977011

+ 1 - 1
core/databases/app_defaults.php

@@ -31,7 +31,7 @@ if (!empty($domains_processed) && $domains_processed == 1) {
 		$sql = "select * from v_databases ";
 		$sql .= "where database_driver is null ";
 		$result = $database->select($sql, null, 'all');
-		foreach ($result as &$row) {
+		foreach ($result as $row) {
 			$database_uuid = $row["database_uuid"];
 			$database_type = $row["database_type"];
 			$database_type_array = explode(":",  $database_type);

+ 1 - 1
core/default_settings/default_settings.php

@@ -470,7 +470,7 @@
 				$sql .= "where menu_uuid = :menu_uuid ";
 				$parameters['menu_uuid'] = $row['default_setting_value'];
 				$sub_result = $database->select($sql, $parameters ?? null, 'all');
-				foreach ($sub_result as &$sub_row) {
+				foreach ($sub_result as $sub_row) {
 					echo $sub_row["menu_language"]." - ".$sub_row["menu_name"]."\n";
 				}
 				unset($sql, $sub_result, $sub_row);

+ 1 - 1
core/domain_settings/domain_setting_edit.php

@@ -242,7 +242,7 @@
 
 						$time_zone_found = false;
 						if (!empty($result)) {
-							foreach ($result as &$row) {
+							foreach ($result as $row) {
 								//get the dialplan_uuid
 									$dialplan_uuid = $row["dialplan_uuid"];
 

+ 1 - 1
core/domain_settings/domain_settings.php

@@ -294,7 +294,7 @@
 				$database = new database;
 				$sub_result = $database->select($sql, $parameters, 'all');
 				if (!empty($sub_result)) {
-					foreach ($sub_result as &$sub_row) {
+					foreach ($sub_result as $sub_row) {
 						echo escape($sub_row["menu_language"])." - ".escape($sub_row["menu_name"])."\n";
 					}
 				}

+ 2 - 2
core/events/resources/classes/events.php

@@ -118,7 +118,7 @@ class events {
 	 * @return boolean $value
 	 */
 	public function check_required($category) {
-		foreach ($this->required['headers'] as &$header) {
+		foreach ($this->required['headers'] as $header) {
 			if ($category == $header) {
 				return true;
 			}
@@ -131,7 +131,7 @@ class events {
 	 */
 	public function send() {
 		//check for required headers are present return false if any are missing
-			foreach ($this->headers as &$header) {
+			foreach ($this->headers as $header) {
 				if (!$this->check_required($header)) {
 					return false;
 				}

+ 2 - 2
core/groups/group_members.php

@@ -119,7 +119,7 @@
 
 //add group_member to the users array
 	if (!empty($users)) {
-		foreach ($users as &$field) {
+		foreach ($users as $field) {
 			$field['group_member'] = 'false';
 			if (!empty($user_groups)) {
 				foreach($user_groups as $row) {
@@ -196,7 +196,7 @@
 
 	if (is_array($user_groups) && @sizeof($user_groups) != 0) {
 		$x = 0;
-		foreach ($user_groups as &$row) {
+		foreach ($user_groups as $row) {
 			echo "<tr class='list-row' href='".$list_row_url."'>";
 			if (permission_exists('group_member_delete')) {
 				echo "	<td class='checkbox'>\n";

+ 1 - 1
core/groups/permissions_copy.php

@@ -96,7 +96,7 @@
 			unset($sql, $parameters);
 
 			if (is_array($result) && sizeof($result) != 0) {
-				foreach ($result as $x => &$row) {
+				foreach ($result as $x => $row) {
 					//define group permissions values
 						$domain_uuid = $row["domain_uuid"];
 						$permission_name = $row["permission_name"];

+ 2 - 2
core/groups/resources/classes/permission.php

@@ -33,7 +33,7 @@
 				//get the $apps array from the installed apps from the core and mod directories
 					$config_list = glob($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/*/*/app_config.php");
 					$x = 0;
-					foreach ($config_list as &$config_path) {
+					foreach ($config_list as $config_path) {
 						include($config_path);
 						$x++;
 					}
@@ -130,7 +130,7 @@
 				//get the $apps array from the installed apps from the core and mod directories
 					$config_list = glob($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/*/*/app_config.php");
 					$x = 0;
-					foreach ($config_list as &$config_path) {
+					foreach ($config_list as $config_path) {
 						include($config_path);
 						$x++;
 					}

+ 2 - 2
core/menu/menu_item_list.php

@@ -124,7 +124,7 @@
 
 				$group_list = '';
 				if (!empty($sub_result) && sizeof($sub_result) != 0) {
-					foreach ($sub_result as &$sub_row) {
+					foreach ($sub_result as $sub_row) {
 						$group_array[] = $sub_row["group_name"].((!empty($sub_row['group_domain_uuid'])) ? "@".$_SESSION['domains'][$sub_row['group_domain_uuid']]['domain_name'] : null);
 					}
 					$group_list = !empty($group_array) ? implode(', ', $group_array) : '';
@@ -306,7 +306,7 @@
 				unset($sql, $group_list);
 
 				if (!empty($sub_result) && sizeof($sub_result) != 0) {
-					foreach ($sub_result as &$sub_row) {
+					foreach ($sub_result as $sub_row) {
 						$group_list[] = $sub_row["group_name"].((!empty($sub_row['group_domain_uuid'])) ? "@".$_SESSION['domains'][$sub_row['group_domain_uuid']]['domain_name'] : null);
 					}
 					$group_list = implode(', ', $group_list);

+ 1 - 1
core/permissions/app_defaults.php

@@ -9,7 +9,7 @@ if ($domains_processed == 1) {
 	//get the $apps array from the installed apps from the core and mod directories
 		$config_list = glob($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/*/*/app_config.php");
 		$x = 0;
-		foreach ($config_list as &$config_path) {
+		foreach ($config_list as $config_path) {
 			include($config_path);
 			$x++;
 		}

+ 1 - 1
core/upgrade/index.php

@@ -406,7 +406,7 @@
 		$database = new database;
 		$result = $database->select($sql, null, 'all');
 		if (is_array($result) && sizeof($result) != 0) {
-			foreach ($result as &$row) {
+			foreach ($result as $row) {
 				if ($row["menu_name"] == 'default') {
 					echo "<option selected value='".$row["menu_uuid"]."|".$row["menu_language"]."'>".$row["menu_name"]."</option>";
 				}

+ 1 - 1
core/user_settings/user_setting_edit.php

@@ -227,7 +227,7 @@ if (!empty($_POST) && empty($_POST["persistformvar"])) {
 
 					$time_zone_found = false;
 					if (is_array($result) && sizeof($result) != 0) {
-						foreach ($result as &$row) {
+						foreach ($result as $row) {
 							//get the dialplan_uuid
 								$dialplan_uuid = $row["dialplan_uuid"];
 

+ 1 - 1
core/user_settings/user_settings.php

@@ -271,7 +271,7 @@
 				$database = new database;
 				$sub_result = $database->select($sql, $parameters, 'all');
 				if (!empty($sub_result)) {
-					foreach ($sub_result as &$sub_row) {
+					foreach ($sub_result as $sub_row) {
 						echo escape($sub_row["menu_language"])." - ".escape($sub_row["menu_name"])."\n";
 					}
 				}

+ 8 - 8
resources/classes/database.php

@@ -645,14 +645,14 @@
 					$tmp = $prep_statement->fetchAll(PDO::FETCH_NAMED);
 					if ($this->type == "pgsql" || $this->type == "sqlite" || $this->type == "mssql") {
 						if (is_array($tmp)) {
-							foreach ($tmp as &$row) {
+							foreach ($tmp as $row) {
 								$result[]['name'] = $row['name'];
 							}
 						}
 					}
 					if ($this->type == "mysql") {
 						if (is_array($tmp)) {
-							foreach ($tmp as &$row) {
+							foreach ($tmp as $row) {
 								$table_array = array_values($row);
 								$result[]['name'] = $table_array[0];
 							}
@@ -2815,7 +2815,7 @@
 
 							//get the domain_uuid
 							$domain_uuid = '';
-							foreach($old_array as &$data_array) {
+							foreach ($old_array as $data_array) {
 								foreach ($data_array as $row) {
 									if (!empty($row['domain_uuid'])) {
 										$domain_uuid = $row['domain_uuid'];
@@ -2968,7 +2968,7 @@
 					$config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
 					$x = 0;
 					if (is_array($config_list)) {
-						foreach ($config_list as &$config_path) {
+						foreach ($config_list as $config_path) {
 							include($config_path);
 							$x++;
 						}
@@ -3011,7 +3011,7 @@
 				//search through all fields to see if domain_uuid exists
 					foreach (self::$apps as $x => &$app) {
 						if (is_array($app['db'])) {
-							foreach ($app['db'] as $y => &$row) {
+							foreach ($app['db'] as $y => $row) {
 								if (is_array($row['table']['name'])) {
 									$table_name = $row['table']['name']['text'];
 								}
@@ -3065,15 +3065,15 @@
 						}
 					}
 					$x = 0;
-					foreach ($config_list as &$config_path) {
+					foreach ($config_list as $config_path) {
 						include($config_path);
 						$x++;
 					}
 
 				//search through all fields to find relations
 					if (!empty($apps) && is_array($apps)) {
-						foreach ($apps as $x => &$app) {
-							foreach ($app['db'] as $y => &$row) {
+						foreach ($apps as $x => $app) {
+							foreach ($app['db'] as $y => $row) {
 								foreach ($row['fields'] as $z => $field) {
 									if (!empty($field['deprecated']) && $field['deprecated'] != "true") {
 										if (!empty($field['key']['type']) &&  $field['key']['type'] == "foreign") {

+ 4 - 4
resources/classes/domains.php

@@ -144,13 +144,13 @@ if (!class_exists('domains')) {
 										//get the $apps array from the installed apps from the core and mod directories
 											$config_list = glob($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/*/*/app_config.php");
 											$x=0;
-											if (isset($config_list)) foreach ($config_list as &$config_path) {
+											if (isset($config_list)) foreach ($config_list as $config_path) {
 												include($config_path);
 												$x++;
 											}
 
 										//delete the domain data from all tables in the database
-											if (isset($apps)) foreach ($apps as &$app) {
+											if (isset($apps)) foreach ($apps as $app) {
 												if (isset($app['db'])) foreach ($app['db'] as $row) {
 													if (is_array($row['table']['name'])) {
 														$table_name = $row['table']['name']['text'];
@@ -623,7 +623,7 @@ if (!class_exists('domains')) {
 				$config_list = array_merge((array)$config_list_1, (array)$config_list_2);
 				unset($config_list_1,$config_list_2);
 				$x=0;
-				foreach ($config_list as &$config_path) {
+				foreach ($config_list as $config_path) {
 					$app_path = dirname($config_path);
 					$app_path = preg_replace('/\A.*(\/.*\/.*)\z/', '$1', $app_path);
 					include($config_path);
@@ -650,7 +650,7 @@ if (!class_exists('domains')) {
 
 					//get the list of installed apps from the core and mod directories and run the php code in app_defaults.php
 						$default_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_defaults.php");
-						foreach ($default_list as &$default_path) {
+						foreach ($default_list as $default_path) {
 							include($default_path);
 						}
 

+ 1 - 1
resources/classes/email.php

@@ -142,7 +142,7 @@ if (!class_exists('email')) {
 
 				//get the attachments and add to the email
 				$x = 0;
-				foreach ($decoded[0]["Parts"] as &$parts_array) {
+				foreach ($decoded[0]["Parts"] as $parts_array) {
 					//image/tiff;name="testfax.tif"
 					//text/plain; charset=ISO-8859-1; format=flowed
 					$content_type = $parts_array["Parts"][0]["Headers"]["content-type:"];

+ 1 - 1
resources/classes/groups.php

@@ -459,7 +459,7 @@ if (!class_exists('groups')) {
 					//build the apps array
 					$config_list = glob($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/*/*/app_config.php");
 					$x = 0;
-					foreach ($config_list as &$config_path) {
+					foreach ($config_list as $config_path) {
 						include($config_path);
 						$x++;
 					}

+ 15 - 15
resources/classes/schema.php

@@ -47,7 +47,7 @@ if (!class_exists('schema')) {
 				//get the list of installed apps from the core and mod directories
 				$config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
 				$x=0;
-				foreach ($config_list as &$config_path) {
+				foreach ($config_list as $config_path) {
 					try {
 						include($config_path);
 					}
@@ -137,7 +137,7 @@ if (!class_exists('schema')) {
 
 		//check if a column exists in sqlite
 			private function sqlite_column_exists($table_info, $column_name) {
-				foreach ($table_info as $key => &$row) {
+				foreach ($table_info as $key => $row) {
 					if ($row['name'] == $column_name) {
 						return true;
 					}
@@ -274,21 +274,21 @@ if (!class_exists('schema')) {
 		//database type
 			private function db_data_type($db_type, $table_info, $column_name) {
 				if ($db_type == "sqlite") {
-					foreach ($table_info as $key => &$row) {
+					foreach ($table_info as $key => $row) {
 						if ($row['name'] == $column_name) {
 							return $row['type'];
 						}
 					}
 				}
 				if ($db_type == "pgsql") {
-					foreach ($table_info as $key => &$row) {
+					foreach ($table_info as $key => $row) {
 						if ($row['column_name'] == $column_name) {
 							return $row['data_type'];
 						}
 					}
 				}
 				if ($db_type == "mysql") {
-					foreach ($table_info as $key => &$row) {
+					foreach ($table_info as $key => $row) {
 						if ($row['Field'] == $column_name) {
 							return $row['Type'];
 						}
@@ -298,7 +298,7 @@ if (!class_exists('schema')) {
 
 		//sqlite column exists
 			private function db_sqlite_column_exists($table_info, $column_name) {
-				foreach ($table_info as $key => &$row) {
+				foreach ($table_info as $key => $row) {
 					if ($row['name'] == $column_name) {
 						return true;
 					}
@@ -348,7 +348,7 @@ if (!class_exists('schema')) {
 		//database create table
 			public function db_create_table ($apps, $db_type, $table) {
 				if (empty($apps)) { return false; }
-				if (is_array($apps)) foreach ($apps as $x => &$app) {
+				if (is_array($apps)) foreach ($apps as $x => $app) {
 					if (!empty($app['db']) && is_array($app['db'])) foreach ($app['db'] as $y => $row) {
 						if (!empty($row['table']['name']) && is_array($row['table']['name'])) {
 							$table_name = $row['table']['name']['text'];
@@ -393,7 +393,7 @@ if (!class_exists('schema')) {
 		//database insert
 			private function db_insert_into ($apps, $db_type, $table) {
 				global $db_name;
-				foreach ($apps as $x => &$app) {
+				foreach ($apps as $x => $app) {
 					foreach ($app['db'] as $y => $row) {
 						if ($row['table']['name'] == $table) {
 							$sql = "INSERT INTO " . $row['table']['name'] . " (";
@@ -520,8 +520,8 @@ if (!class_exists('schema')) {
 
 				//update the app db array add exists true or false
 					$sql = '';
-					foreach ($this->apps as $x => &$app) {
-						if (isset($app['db'])) foreach ($app['db'] as $y => &$row) {
+					foreach ($this->apps as $x => $app) {
+						if (isset($app['db'])) foreach ($app['db'] as $y => $row) {
 							if (isset($row['table']['name'])) {
 								if (is_array($row['table']['name'])) {
 									$table_name = $row['table']['name']['text'];
@@ -582,8 +582,8 @@ if (!class_exists('schema')) {
 					$sql_update = '';
 
 				//add missing tables and fields
-					foreach ($this->apps as $x => &$app) {
-						if (isset($app['db'])) foreach ($app['db'] as $y => &$row) {
+					foreach ($this->apps as $x => $app) {
+						if (isset($app['db'])) foreach ($app['db'] as $y => $row) {
 							if (is_array($row['table']['name'])) {
 								$table_name = $row['table']['name']['text'];
 								if ($this->db_table_exists($db_type, $db_name, $row['table']['name']['deprecated'])) {
@@ -735,8 +735,8 @@ if (!class_exists('schema')) {
 						}
 					}
 				//rebuild and populate the table
-					foreach ($this->apps as $x => &$app) {
-						if (isset($app['db'])) foreach ($app['db'] as $y => &$row) {
+					foreach ($this->apps as $x => $app) {
+						if (isset($app['db'])) foreach ($app['db'] as $y => $row) {
 							if (is_array($row['table']['name'])) {
 								$table_name = $row['table']['name']['text'];
 							}
@@ -792,7 +792,7 @@ if (!class_exists('schema')) {
 							$response .= "<tr>\n";
 						//build the html while looping through the app db array
 							$sql = '';
-							foreach ($this->apps as &$app) {
+							foreach ($this->apps as $app) {
 								if (isset($app['db'])) foreach ($app['db'] as $row) {
 									if (is_array($row['table']['name'])) {
 										$table_name = $row['table']['name']['text'];

+ 1 - 1
resources/functions.php

@@ -845,7 +845,7 @@
 		if (is_numeric(trim($phone_number ?? '', ' +'))) {
 			if (isset($_SESSION["format"]["phone"])) {
 				$phone_number = trim($phone_number, ' +');
-				foreach ($_SESSION["format"]["phone"] as &$format) {
+				foreach ($_SESSION["format"]["phone"] as $format) {
 					$format_count = substr_count($format, 'x');
 					$format_count = $format_count + substr_count($format, 'R');
 					$format_count = $format_count + substr_count($format, 'r');

+ 1 - 1
resources/login.php

@@ -299,7 +299,7 @@
 				echo "<select name='domain_name' class='txt login' style='".$placeholder_color." width: 200px; text-align: center; text-align-last: center; margin-bottom: 8px;' onclick=\"this.style.color='".$click_change_color."';\" onchange=\"this.style.color='".$click_change_color."';\">\n";
 				echo "	<option value='' disabled selected hidden>".$text['label-domain']."</option>\n";
 				sort($_SESSION['login']['domain_name']);
-				foreach ($_SESSION['login']['domain_name'] as &$row) {
+				foreach ($_SESSION['login']['domain_name'] as $row) {
 					echo "	<option value='".escape($row)."'>".escape($row)."</option>\n";
 				}
 				echo "</select><br />\n";