From e28de18a9b78b6e4508b5d6874929e82d43dbf28 Mon Sep 17 00:00:00 2001 From: Hystepik Date: Tue, 13 Jun 2023 16:01:52 +0200 Subject: [PATCH 1/2] Fix : deprecated warnings on various pages --- htdocs/comm/action/class/actioncomm.class.php | 4 ++-- htdocs/core/class/html.formfile.class.php | 2 +- htdocs/core/class/html.formmail.class.php | 8 +++++--- htdocs/core/lib/company.lib.php | 2 +- htdocs/core/lib/functions.lib.php | 10 +++++++--- htdocs/core/modules/project/mod_project_simple.php | 3 ++- htdocs/fourn/class/fournisseur.commande.class.php | 2 +- htdocs/fourn/class/fournisseur.facture.class.php | 2 +- 8 files changed, 20 insertions(+), 13 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index ab26ed88105..f16acdd1384 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1718,8 +1718,8 @@ class ActionComm extends CommonObject $tooltip .= '
'; //$tooltip .= '
'.img_picto('', 'email').' '.$langs->trans("Email").''; $tooltip .= '
'.$langs->trans('MailTopic').': '.dol_escape_htmltag($this->email_subject); - $tooltip .= '
'.$langs->trans('MailFrom').': '.str_replace(array('<', '>'), array('&lt', '&gt'), $this->email_from); - $tooltip .= '
'.$langs->trans('MailTo').': '.str_replace(array('<', '>'), array('&lt', '&gt'), $this->email_to); + $tooltip .= '
'.$langs->trans('MailFrom').': '.str_replace(array('<', '>'), array('&lt', '&gt'), !empty($this->email_from) ? $this->email_from : ''); + $tooltip .= '
'.$langs->trans('MailTo').': '.str_replace(array('<', '>'), array('&lt', '&gt'), !empty($this->email_to) ? $this->email_to : ''); if (!empty($this->email_tocc)) { $tooltip .= '
'.$langs->trans('MailCC').': '.str_replace(array('<', '>'), array('&lt', '&gt'), $this->email_tocc); } diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index b60e26d2931..e7e10e0cbb6 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1986,7 +1986,7 @@ class FormFile } elseif ($sortfield == "date") { $sortfield = "datea"; } else { - $sortfield = null; + $sortfield = ''; } $res = $link->fetchAll($links, $object->element, $object->id, $sortfield, $sortorder); $param .= (isset($object->id) ? '&id='.$object->id : ''); diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 04510aca821..c0386b55a3f 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -432,7 +432,9 @@ class FormMail extends Form if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelselected') && GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1')) { if (!empty($arraydefaultmessage->joinfiles) && !empty($this->param['fileinit']) && is_array($this->param['fileinit'])) { foreach ($this->param['fileinit'] as $file) { - $this->add_attached_files($file, basename($file), dol_mimetype($file)); + if (!empty($file)) { + $this->add_attached_files($file, basename($file), dol_mimetype($file)); + } } } } @@ -1083,7 +1085,7 @@ class FormMail extends Form $tmparray = $this->withto; foreach ($tmparray as $key => $val) { $tmparray[$key] = str_replace(array('<', '>'), array('(', ')'), $tmparray[$key]); - $tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true); + $tmparray[$key] = dol_htmlentities($tmparray[$key], ENT_QUOTES|ENT_SUBSTITUTE, 'UTF-8', true); } $withtoselected = GETPOST("receiver", 'array'); // Array of selected value @@ -1121,7 +1123,7 @@ class FormMail extends Form $tmparray = $this->withtocc; foreach ($tmparray as $key => $val) { $tmparray[$key] = str_replace(array('<', '>'), array('(', ')'), $tmparray[$key]); - $tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true); + $tmparray[$key] = dol_htmlentities($tmparray[$key], ENT_QUOTES|ENT_SUBSTITUTE, 'UTF-8', true); } $withtoccselected = GETPOST("receivercc", 'array'); // Array of selected value $out .= $form->multiselectarray("receivercc", $tmparray, $withtoccselected, null, null, 'inline-block minwidth500', null, ""); diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 46f4bdf4b2f..a1959bf1994 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -2006,7 +2006,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) { $labeltype = 'AC_OTH'; } - if (preg_match('/^TICKET_MSG/', $actionstatic->code)) { + if (!empty($actionstatic->code) && preg_match('/^TICKET_MSG/', $actionstatic->code)) { $labeltype = $langs->trans("Message"); } else { if (!empty($arraylist[$labeltype])) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 6b2cbaf2938..dbf63706e43 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -7273,9 +7273,13 @@ function dolGetFirstLineOfText($text, $nboflines = 1, $charset = 'UTF-8') $firstline = preg_replace('/]*>.*$/s', '', $text); // The s pattern modifier means the . can match newline characters $firstline = preg_replace('/]*>.*$/s', '', $firstline); // The s pattern modifier means the . can match newline characters } else { - $firstline = preg_replace('/[\n\r].*/', '', $text); + if (isset($text)) { + $firstline = preg_replace('/[\n\r].*/', '', $text); + } else { + $firstline = ''; + } } - return $firstline.((strlen($firstline) != strlen($text)) ? '...' : ''); + return $firstline.(isset($firstline) && isset($text) && (strlen($firstline) != strlen($text)) ? '...' : ''); } else { $ishtml = 0; if (dol_textishtml($text)) { @@ -8119,7 +8123,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__EXTRAFIELD_'.strtoupper($key).'__'] = $object->array_options['options_'.$key]; $substitutionarray['__EXTRAFIELD_'.strtoupper($key).'_FORMATED__'] = price($object->array_options['options_'.$key]); } elseif ($extrafields->attributes[$object->table_element]['type'][$key] != 'separator') { - $substitutionarray['__EXTRAFIELD_'.strtoupper($key).'__'] = $object->array_options['options_'.$key]; + $substitutionarray['__EXTRAFIELD_'.strtoupper($key).'__'] = !empty($object->array_options['options_'.$key]) ? $object->array_options['options_'.$key] :''; } } } diff --git a/htdocs/core/modules/project/mod_project_simple.php b/htdocs/core/modules/project/mod_project_simple.php index 921b68f492b..4d5faaf7a87 100644 --- a/htdocs/core/modules/project/mod_project_simple.php +++ b/htdocs/core/modules/project/mod_project_simple.php @@ -150,7 +150,8 @@ class mod_project_simple extends ModeleNumRefProjects $date = (empty($project->date_c) ? dol_now() : $project->date_c); //$yymm = strftime("%y%m",time()); - $yymm = strftime("%y%m", $date); + //$yymm = strftime("%y%m", $date); + $yymm = date("%y%m", $date); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index e043b4556f3..fe8d07d90c9 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -487,7 +487,7 @@ class CommandeFournisseur extends CommonOrder $this->multicurrency_total_tva = $obj->multicurrency_total_tva; $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; - $this->extraparams = (array) json_decode($obj->extraparams, true); + $this->extraparams = isset($obj->extraparams) ? (array) json_decode($obj->extraparams, true) : array(); $this->db->free($resql); diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 8563dd96d7c..73f66d7fb02 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1003,7 +1003,7 @@ class FactureFournisseur extends CommonInvoice $this->multicurrency_total_tva = $obj->multicurrency_total_tva; $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; - $this->extraparams = (array) json_decode($obj->extraparams, true); + $this->extraparams = isset($obj->extraparams) ? (array) json_decode($obj->extraparams, true) : array(); $this->socid = $obj->socid; $this->socnom = $obj->socnom; From afbcaa6f91b2d4bcd0c998c9a036db144bc7bdd3 Mon Sep 17 00:00:00 2001 From: Hystepik Date: Wed, 14 Jun 2023 10:10:55 +0200 Subject: [PATCH 2/2] match eldy adviced --- htdocs/core/modules/project/mod_project_simple.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/project/mod_project_simple.php b/htdocs/core/modules/project/mod_project_simple.php index 4d5faaf7a87..ba1d04023f3 100644 --- a/htdocs/core/modules/project/mod_project_simple.php +++ b/htdocs/core/modules/project/mod_project_simple.php @@ -151,7 +151,7 @@ class mod_project_simple extends ModeleNumRefProjects //$yymm = strftime("%y%m",time()); //$yymm = strftime("%y%m", $date); - $yymm = date("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is