Remove php8.1 warnings

This commit is contained in:
Laurent Destailleur
2022-10-10 14:46:29 +02:00
parent b6dbdd6757
commit f4dc43914d
3 changed files with 9 additions and 11 deletions

View File

@@ -409,7 +409,6 @@ $dolibarr_cron_allow_cli='0';
//################################# //#################################
// Value to overwrite path to use shared libraries instead of embedded one // Value to overwrite path to use shared libraries instead of embedded one
//$dolibarr_lib_ADODB_PATH='/usr/share/php/adodb';
//$dolibarr_lib_TCPDF_PATH='/usr/share/php/tcpdf'; //$dolibarr_lib_TCPDF_PATH='/usr/share/php/tcpdf';
//$dolibarr_lib_FPDI_PATH='/usr/share/php/fpdi'; //$dolibarr_lib_FPDI_PATH='/usr/share/php/fpdi';
//$dolibarr_lib_FPDF_PATH='/usr/share/php/fpdf'; //$dolibarr_lib_FPDF_PATH='/usr/share/php/fpdf';

View File

@@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2000-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2000-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org> * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2022 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org> * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr> * Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
@@ -2628,8 +2628,8 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
$format = str_replace('%A', '__A__', $format); $format = str_replace('%A', '__A__', $format);
} }
$noadodb = getDolGlobalInt('MAIN_NO_ADODB_FOR_DATE'); $useadodb = getDolGlobalInt('MAIN_USE_LEGACY_ADODB_FOR_DATE', 0);
//$noadodb = 1; // To force test //$useadodb = 1; // To switch to adodb
// Analyze date // Analyze date
$reg = array(); $reg = array();
@@ -2649,7 +2649,7 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
$ssec = (!empty($reg[6]) ? $reg[6] : ''); $ssec = (!empty($reg[6]) ? $reg[6] : '');
$time = dol_mktime($shour, $smin, $ssec, $smonth, $sday, $syear, true); $time = dol_mktime($shour, $smin, $ssec, $smonth, $sday, $syear, true);
if ($noadodb) { if (empty($useadodb)) {
if ($to_gmt) { if ($to_gmt) {
$tzo = new DateTimeZone('UTC'); // when to_gmt is true, base for offsettz and offsetdst (so timetouse) is UTC $tzo = new DateTimeZone('UTC'); // when to_gmt is true, base for offsettz and offsetdst (so timetouse) is UTC
} else { } else {
@@ -2675,7 +2675,7 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
if ($time < 100000000000) { // Protection against bad date values if ($time < 100000000000) { // Protection against bad date values
$timetouse = $time + $offsettz + $offsetdst; // TODO We could be able to disable use of offsettz and offsetdst to use only offsettzstring. $timetouse = $time + $offsettz + $offsetdst; // TODO We could be able to disable use of offsettz and offsetdst to use only offsettzstring.
if ($noadodb) { if (empty($useadodb)) {
if ($to_gmt) { if ($to_gmt) {
$tzo = new DateTimeZone('UTC'); // when to_gmt is true, base for offsettz and offsetdst (so timetouse) is UTC $tzo = new DateTimeZone('UTC'); // when to_gmt is true, base for offsettz and offsetdst (so timetouse) is UTC
} else { } else {
@@ -2705,7 +2705,7 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
if (preg_match('/__b__/i', $format)) { if (preg_match('/__b__/i', $format)) {
$timetouse = $time + $offsettz + $offsetdst; // TODO We could be able to disable use of offsettz and offsetdst to use only offsettzstring. $timetouse = $time + $offsettz + $offsetdst; // TODO We could be able to disable use of offsettz and offsetdst to use only offsettzstring.
if ($noadodb) { if (empty($useadodb)) {
if ($to_gmt) { if ($to_gmt) {
$tzo = new DateTimeZone('UTC'); // when to_gmt is true, base for offsettz and offsetdst (so timetouse) is UTC $tzo = new DateTimeZone('UTC'); // when to_gmt is true, base for offsettz and offsetdst (so timetouse) is UTC
} else { } else {
@@ -2737,7 +2737,7 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
//print "time=$time offsettz=$offsettz offsetdst=$offsetdst offsettzstring=$offsettzstring"; //print "time=$time offsettz=$offsettz offsetdst=$offsetdst offsettzstring=$offsettzstring";
$timetouse = $time + $offsettz + $offsetdst; // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. $timetouse = $time + $offsettz + $offsetdst; // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring.
if ($noadodb) { if (empty($useadodb)) {
if ($to_gmt) { if ($to_gmt) {
$tzo = new DateTimeZone('UTC'); $tzo = new DateTimeZone('UTC');
} else { } else {
@@ -2782,7 +2782,6 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
*/ */
function dol_getdate($timestamp, $fast = false, $forcetimezone = '') function dol_getdate($timestamp, $fast = false, $forcetimezone = '')
{ {
//$datetimeobj = new DateTime('@'.$timestamp);
$datetimeobj = new DateTime(); $datetimeobj = new DateTime();
$datetimeobj->setTimestamp($timestamp); // Use local PHP server timezone $datetimeobj->setTimestamp($timestamp); // Use local PHP server timezone
if ($forcetimezone) { if ($forcetimezone) {

View File

@@ -762,7 +762,7 @@ class JavascriptRenderer
return $uris; return $uris;
} }
if (substr($uri, 0, 1) === '/' || preg_match('/^([a-zA-Z]+:\/\/|[a-zA-Z]:\/|[a-zA-Z]:\\\)/', $uri)) { if ($uri && (substr($uri, 0, 1) === '/' || preg_match('/^([a-zA-Z]+:\/\/|[a-zA-Z]:\/|[a-zA-Z]:\\\)/', $uri))) {
return $uri; return $uri;
} }
return rtrim($root, '/') . "/$uri"; return rtrim($root, '/') . "/$uri";
@@ -778,7 +778,7 @@ class JavascriptRenderer
protected function filterAssetArray($array, $type = null) protected function filterAssetArray($array, $type = null)
{ {
$types = array('css', 'js', 'inline_css', 'inline_js', 'inline_head'); $types = array('css', 'js', 'inline_css', 'inline_js', 'inline_head');
$typeIndex = array_search(strtolower($type), $types); $typeIndex = is_null($type) ? false : array_search(strtolower($type), $types);
return $typeIndex !== false ? $array[$typeIndex] : $array; return $typeIndex !== false ? $array[$typeIndex] : $array;
} }