From ad0504645e3632d169d0f253bb5eb4db8b7e18b9 Mon Sep 17 00:00:00 2001 From: Joe Hunt Date: Thu, 29 Nov 2018 09:13:49 +0100 Subject: [PATCH 1/1] Fixed php 7.2 count() compatibility and intval cast in number_format2 parameter 2. --- admin/db/maintenance_db.inc | 2 +- includes/current_user.inc | 2 +- includes/ui/ui_globals.inc | 5 ++++- reporting/includes/fpdi/fpdi.php | 2 +- reporting/includes/reports_classes.inc | 2 +- sales/includes/sales_db.inc | 2 +- 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/admin/db/maintenance_db.inc b/admin/db/maintenance_db.inc index ab7334f0..af6f5777 100644 --- a/admin/db/maintenance_db.inc +++ b/admin/db/maintenance_db.inc @@ -183,7 +183,7 @@ function update_extensions($extensions) { } // update per company files - $cnt = max(1, count($db_connections)); + $cnt = max(1, count_array($db_connections)); for($i = 0; $i < $cnt; $i++) { $newexts = $extensions; diff --git a/includes/current_user.inc b/includes/current_user.inc index 23887cb6..edfae0a9 100644 --- a/includes/current_user.inc +++ b/includes/current_user.inc @@ -315,7 +315,7 @@ function number_format2($number, $decimals=0) $dec = $decimals; } - $num = number_format($number, $dec, $dsep, $tsep); + $num = number_format($number, intval($dec), $dsep, $tsep); return $decimals==='max' ? rtrim($num, '0') : $num; diff --git a/includes/ui/ui_globals.inc b/includes/ui/ui_globals.inc index 15601c9f..ecb3ca4e 100644 --- a/includes/ui/ui_globals.inc +++ b/includes/ui/ui_globals.inc @@ -62,7 +62,10 @@ function get_global_curr_code() return $_SESSION['wa_global_curr_code']; } - +function count_array($array) +{ + return (is_array($array)) ? count($array) : 0; +} //-------------------------------------------------------------------------------------- diff --git a/reporting/includes/fpdi/fpdi.php b/reporting/includes/fpdi/fpdi.php index d9ab7ced..097491df 100644 --- a/reporting/includes/fpdi/fpdi.php +++ b/reporting/includes/fpdi/fpdi.php @@ -486,7 +486,7 @@ class FPDI extends FPDF_TPL { * close all files opened by parsers */ function _closeParsers() { - if ($this->state > 2 && count($this->parsers) > 0) { + if ($this->state > 2 && is_array($this->parsers) && count($this->parsers) > 0) { foreach ($this->parsers as $k => $_){ $this->parsers[$k]->closeFile(); $this->parsers[$k] = null; diff --git a/reporting/includes/reports_classes.inc b/reporting/includes/reports_classes.inc index 419f69ef..77399c3f 100644 --- a/reporting/includes/reports_classes.inc +++ b/reporting/includes/reports_classes.inc @@ -34,7 +34,7 @@ class BoxReports function addReportClass($class_name, $class_id=null) { if (!$class_id) - $class_id = is_array($this->ar_classes) ? count($this->ar_classes) : 0; + $class_id = count_array($this->ar_classes); $this->ar_classes[$class_id] = $class_name; return $class_id; diff --git a/sales/includes/sales_db.inc b/sales/includes/sales_db.inc index 46500230..d58d8cf7 100644 --- a/sales/includes/sales_db.inc +++ b/sales/includes/sales_db.inc @@ -368,7 +368,7 @@ function get_sales_child_documents($trans_type, $trans_no) // FIXME - credit notes retrieved here should be those linked to invoices containing // at least one line from related invoice - if (!count($trans_no)) + if (!count_array($trans_no)) return false; $childs = get_sales_child_numbers($trans_type, $trans_no, false); if (!count($childs)) -- 2.30.2