Frytimo pr patches for php8.1 (#6630)

* Passing null to parameter #2 ($string) of type string is deprecated

* Passing null to parameter #1 ($string) of type string is deprecated

* php 8.1 fixes

* php 8.1 fixes - replace strlen($var) > 0 with !empty($var)

* php 8.1 fixes - replace ${var} with {$var}

* php 8.1 fixes - replace ${var} with {$var}

* php 8.1 fixes - replace ${var} with {$var}

* php 8.1 fixes - replace ${var} with {$var}

* php 8.1 fixes - strlower with null

* php 8.1 fixes - strreplace with null

* php 8.1 fixes - passing null to base64_decode

* php 8.1 fixes - check for false and check for null on $this->dir

* php 8.1 fixes - remove assignment of $db variable to modules object

* php 8.1 fixes - avoid sending null to substr

* php 8.1 fixes - change ${var} to {$var}

* php 8.1 fixes - check for null before preg_replace

* php 8.1 fixes - remove setting db variable on domains object

* php 8.1 fixes - set empty string if $row['domain_setting_subcategory'] is null

* php 8.1 fixes - set empty string if $_REQUEST['show'] is not available

* php 8.1 fixes

* php 8.1 fixes - correct $_POST checking syntax

* php 8.1 fixes - correct $_POST variables

* php 8.1 fixes

* Use brackets consistently

* Update user_setting_edit.php

* Change to not empty

* Update device.php

* Update text.php

---------

Co-authored-by: Tim Fry <tim@voipstratus.com>
Co-authored-by: FusionPBX <markjcrane@gmail.com>
This commit is contained in:
frytimo
2023-05-05 13:46:37 -03:00
committed by GitHub
parent ebbb2f1a72
commit fef8165be2
230 changed files with 1948 additions and 1937 deletions

View File

@@ -434,7 +434,7 @@
if (!isset($this->path) && isset($db_path)) { $this->path = $db_path; }
if ($this->driver == "sqlite") {
if (strlen($this->db_name) == 0) {
if (empty($this->db_name)) {
$server_name = $_SERVER["SERVER_NAME"];
$server_name = str_replace ("www.", "", $server_name);
$db_name_short = $server_name;
@@ -467,12 +467,12 @@
if ($this->driver == "mysql") {
try {
//mysql pdo connection
if (strlen($this->host) == 0 && strlen($this->port) == 0) {
if (strlen($this->host) == 0 && empty($this->port)) {
//if both host and port are empty use the unix socket
$this->db = new PDO("mysql:host=$this->host;unix_socket=/var/run/mysqld/mysqld.sock;dbname=$this->db_name", $this->username, $this->password);
}
else {
if (strlen($this->port) == 0) {
if (empty($this->port)) {
//leave out port if it is empty
$this->db = new PDO("mysql:host=$this->host;dbname=$this->db_name;", $this->username, $this->password, array(
PDO::ATTR_ERRMODE,
@@ -496,8 +496,8 @@
if ($this->driver == "pgsql") {
//database connection
try {
if (strlen($this->host) > 0) {
if (strlen($this->port) == 0) { $this->port = "5432"; }
if (!empty($this->host)) {
if (empty($this->port)) { $this->port = "5432"; }
if ($this->db_secure === true) {
$this->db = new PDO("pgsql:host=$this->host port=$this->port dbname=$this->db_name user=$this->username password=$this->password sslmode=verify-ca sslrootcert=$this->db_cert_authority");
}
@@ -593,7 +593,7 @@
}
//get the table info
if (strlen($this->table) == 0) { return false; }
if (empty($this->table)) { return false; }
if ($this->type == "sqlite") {
$sql = "PRAGMA table_info(".$this->table.");";
}
@@ -927,7 +927,7 @@
foreach($this->fields as $name => $value) {
$name = self::sanitize($name);
if ($field_count == $i) {
if (strlen($value) > 0) {
if (!empty($value)) {
//$sql .= "'".$value."' ";
$sql .= ":".$name." \n";
$params[$name] = trim($value);
@@ -937,7 +937,7 @@
}
}
else {
if (strlen($value) > 0) {
if (!empty($value)) {
//$sql .= "'".$value."', ";
$sql .= ":".$name.", \n";
$params[$name] = trim($value);
@@ -995,7 +995,7 @@
foreach($this->fields as $name => $value) {
$name = self::sanitize($name);
if (count($this->fields) == $i) {
if (strlen($name) > 0 && $value == null) {
if (!empty($name) && $value == null) {
$sql .= $name." = null ";
}
else {
@@ -1005,7 +1005,7 @@
}
}
else {
if (strlen($name) > 0 && $value == null) {
if (!empty($name) && $value == null) {
$sql .= $name." = null, ";
}
else {
@@ -1188,7 +1188,7 @@
}
}
}
if (strlen($field_value) > 0) {
if (!empty($field_value)) {
$results = $this->execute($sql, $parameters, 'all');
unset($parameters);
if (is_array($results)) {
@@ -1230,7 +1230,7 @@
}
//delete the child data
if (isset($row[$relation['field']]) && strlen($row[$relation['field']]) > 0) {
if (isset($row[$relation['field']]) && !empty($row[$relation['field']])) {
$sql = "delete from ".self::TABLE_PREFIX.$child_table." ";
$sql .= "where ".$relation['field']." = :".$relation['field'];
$parameters[$relation['field']] = $row[$relation['field']];
@@ -1320,7 +1320,7 @@
if (isset($this->app_uuid) && is_uuid($this->app_uuid)) {
$sql .= "app_uuid, ";
}
if (isset($this->app_name) && strlen($this->app_name) > 0) {
if (isset($this->app_name) && !empty($this->app_name)) {
$sql .= "app_name, ";
}
$sql .= "transaction_code, ";
@@ -1343,7 +1343,7 @@
if (isset($this->app_uuid) && is_uuid($this->app_uuid)) {
$sql .= ":app_uuid, ";
}
if (isset($this->app_name) && strlen($this->app_name) > 0) {
if (isset($this->app_name) && !empty($this->app_name)) {
$sql .= ":app_name, ";
}
$sql .= "'".$message["code"]."', ";
@@ -1371,7 +1371,7 @@
if (isset($this->app_uuid) && is_uuid($this->app_uuid)) {
$statement->bindParam(':app_uuid', $this->app_uuid);
}
if (isset($this->app_name) && strlen($this->app_name) > 0) {
if (isset($this->app_name) && !empty($this->app_name)) {
$statement->bindParam(':app_name', $this->app_name);
}
$statement->bindParam(':remote_address', $_SERVER['REMOTE_ADDR']);
@@ -2126,7 +2126,7 @@
$array_key != 'insert_date' &&
$array_key != 'update_user' &&
$array_key != 'update_date') {
if (strlen($array_value) == 0) {
if (empty($array_value)) {
$sql .= "null, ";
}
elseif ($array_value === "now()") {
@@ -2228,7 +2228,7 @@
foreach ($array as $array_key => $array_value) {
if (!is_array($array_value) && $array_key != $parent_key_name) {
$array_key = self::sanitize($array_key);
if (strlen($array_value) == 0) {
if (empty($array_value)) {
$sql .= $array_key." = null, ";
}
elseif ($array_value === "now()") {
@@ -2346,7 +2346,7 @@
$uuid_exists = false;
if (is_array($row)) foreach ($row as $k => $v) {
if ($child_key_name == $k) {
if (strlen($v) > 0) {
if (!empty($v)) {
$child_key_value = trim($v);
$uuid_exists = true;
break;
@@ -2418,7 +2418,7 @@
foreach ($row as $k => $v) {
if (!is_array($v) && ($k != $parent_key_name || $k != $child_key_name)) {
$k = self::sanitize($k);
if (strlen($v) == 0) {
if (empty($v)) {
$sql .= $k." = null, ";
}
elseif ($v === "now()") {
@@ -2501,7 +2501,7 @@
else {
$retval = false;
$message["name"] = $child_name;
$message["message"] = "Forbidden, does not have '${child_name}_edit'";
$message["message"] = "Forbidden, does not have '{$child_name}_edit'";
$message["code"] = "403";
$message["line"] = __line__;
$this->message = $message;
@@ -2570,7 +2570,7 @@
$k != 'insert_date' &&
$k != 'update_user' &&
$k != 'update_date') {
if (strlen($v) == 0) {
if (empty($v)) {
$sql .= "null, ";
}
elseif ($v === "now()") {
@@ -2655,7 +2655,7 @@
else {
$retval = false;
$message["name"] = $child_name;
$message["message"] = "Forbidden, does not have '${child_name}_add'";
$message["message"] = "Forbidden, does not have '{$child_name}_add'";
$message["code"] = "403";
$message["line"] = __line__;
$this->message = $message;
@@ -2680,7 +2680,7 @@
$this->db->commit();
//set the action if not set
if (strlen($action) == 0) {
if (strlen($action ?? '') === 0) {
if (is_array($old_array)) {
$transaction_type = 'update';
}
@@ -2708,7 +2708,7 @@
if (isset($this->app_uuid) && is_uuid($this->app_uuid)) {
$sql .= "app_uuid, ";
}
if (isset($this->app_name) && strlen($this->app_name) > 0) {
if (isset($this->app_name) && !empty($this->app_name)) {
$sql .= "app_name, ";
}
$sql .= "transaction_code, ";
@@ -2734,7 +2734,7 @@
if (isset($this->app_uuid) && is_uuid($this->app_uuid)) {
$sql .= ":app_uuid, ";
}
if (isset($this->app_name) && strlen($this->app_name) > 0) {
if (isset($this->app_name) && !empty($this->app_name)) {
$sql .= ":app_name, ";
}
$sql .= "'".$message["code"]."', ";
@@ -2762,7 +2762,7 @@
if (isset($this->app_uuid) && is_uuid($this->app_uuid)) {
$statement->bindParam(':app_uuid', $this->app_uuid);
}
if (isset($this->app_name) && strlen($this->app_name) > 0) {
if (isset($this->app_name) && !empty($this->app_name)) {
$statement->bindParam(':app_name', $this->app_name);
}
$statement->bindParam(':remote_address', $_SERVER['REMOTE_ADDR']);