From 469ced0a8de91ec3e93c99d2ae93adf26dbdf68a Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 19 Feb 2025 22:04:38 +0100 Subject: [PATCH] Qual: Fix phan notices (ticket,variants,webhook) --- dev/tools/phan/baseline.txt | 30 +++----- ...terface_50_modTicket_TicketEmail.class.php | 2 +- htdocs/ticket/agenda.php | 8 +-- htdocs/ticket/card.php | 69 ++++++++++--------- htdocs/ticket/class/actions_ticket.class.php | 14 ++-- htdocs/ticket/class/ticket.class.php | 29 ++++---- htdocs/ticket/class/ticketstats.class.php | 6 +- htdocs/ticket/contact.php | 4 +- htdocs/ticket/document.php | 5 +- htdocs/ticket/index.php | 5 +- htdocs/ticket/list.php | 4 +- htdocs/ticket/messaging.php | 8 +-- htdocs/ticket/stats/index.php | 4 +- htdocs/variants/ajax/get_attribute_values.php | 8 +-- htdocs/variants/card.php | 11 +-- .../variants/class/ProductAttribute.class.php | 4 +- .../class/ProductCombination.class.php | 22 +++--- htdocs/variants/combinations.php | 14 ++-- htdocs/variants/list.php | 19 +++-- .../productattributevalueline_edit.tpl.php | 7 ++ htdocs/webhook/target_card.php | 4 +- htdocs/webhook/target_list.php | 26 +++---- 22 files changed, 149 insertions(+), 154 deletions(-) diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index 5d7c8558d06..281e4bc81ba 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -9,9 +9,9 @@ */ return [ // # Issue statistics: - // PhanTypeMismatchArgument : 1470+ occurrences + // PhanTypeMismatchArgument : 1430+ occurrences // PhanUndeclaredProperty : 500+ occurrences - // PhanTypeMismatchArgumentNullable : 320+ occurrences + // PhanTypeMismatchArgumentNullable : 310+ occurrences // PhanPluginUnknownArrayMethodReturnType : 170+ occurrences // PhanTypeMismatchProperty : 120+ occurrences // PhanPluginUnknownArrayMethodParamType : 110+ occurrences @@ -25,14 +25,14 @@ return [ // PhanUndeclaredConstant : 15+ occurrences // PhanTypeMismatchArgumentNullableInternal : 10+ occurrences // PhanUndeclaredMethod : 9 occurrences - // PhanTypeComparisonFromArray : 8 occurrences + // PhanTypeComparisonFromArray : 7 occurrences // PhanPluginDuplicateExpressionBinaryOp : 6 occurrences // PhanTypeArraySuspiciousNull : 6 occurrences // PhanParamTooMany : 5 occurrences // PhanPluginDuplicateArrayKey : 4 occurrences // PhanEmptyFQSENInClasslike : 3 occurrences // PhanInvalidFQSENInClasslike : 3 occurrences - // PhanPluginSuspiciousParamPosition : 3 occurrences + // PhanPluginSuspiciousParamPosition : 2 occurrences // PhanTypeMismatchDimAssignment : 2 occurrences // PhanTypeSuspiciousStringExpression : 2 occurrences // PhanAccessMethodProtected : 1 occurrence @@ -643,19 +643,12 @@ return [ 'htdocs/takepos/index.php' => ['PhanPluginUndeclaredVariableIsset'], 'htdocs/takepos/invoice.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredGlobalVariable'], 'htdocs/takepos/split.php' => ['PhanPluginUndeclaredVariableIsset'], - 'htdocs/ticket/agenda.php' => ['PhanTypeMismatchArgument'], - 'htdocs/ticket/card.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'], - 'htdocs/ticket/class/actions_ticket.class.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'], + 'htdocs/ticket/card.php' => ['PhanUndeclaredProperty'], + 'htdocs/ticket/class/actions_ticket.class.php' => ['PhanUndeclaredProperty'], 'htdocs/ticket/class/api_tickets.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'], 'htdocs/ticket/class/cticketcategory.class.php' => ['PhanUndeclaredProperty'], - 'htdocs/ticket/class/ticket.class.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'], - 'htdocs/ticket/class/ticketstats.class.php' => ['PhanTypeMismatchArgument'], + 'htdocs/ticket/class/ticket.class.php' => ['PhanUndeclaredProperty'], 'htdocs/ticket/contact.php' => ['PhanTypeMismatchArgument'], - 'htdocs/ticket/document.php' => ['PhanTypeMismatchArgument'], - 'htdocs/ticket/index.php' => ['PhanPossiblyUndeclaredGlobalVariable'], - 'htdocs/ticket/list.php' => ['PhanTypeMismatchArgument'], - 'htdocs/ticket/messaging.php' => ['PhanTypeMismatchArgument'], - 'htdocs/ticket/stats/index.php' => ['PhanTypeMismatchArgument'], 'htdocs/user/bank.php' => ['PhanTypeMismatchArgument'], 'htdocs/user/card.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchProperty'], 'htdocs/user/class/api_users.class.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchProperty'], @@ -666,19 +659,12 @@ return [ 'htdocs/user/group/card.php' => ['PhanTypeMismatchArgument'], 'htdocs/user/list.php' => ['PhanTypeMismatchArgument'], 'htdocs/user/param_ihm.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'], - 'htdocs/variants/ajax/get_attribute_values.php' => ['PhanTypeComparisonFromArray'], - 'htdocs/variants/card.php' => ['PhanTypeMismatchArgument'], - 'htdocs/variants/class/ProductAttribute.class.php' => ['PhanTypeMismatchArgumentNullable'], - 'htdocs/variants/class/ProductCombination.class.php' => ['PhanPluginSuspiciousParamPosition', 'PhanTypeMismatchArgument'], - 'htdocs/variants/combinations.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchProperty'], - 'htdocs/variants/list.php' => ['PhanTypeMismatchArgument'], 'htdocs/variants/tpl/productattributevalueline_edit.tpl.php' => ['PhanUndeclaredProperty'], 'htdocs/variants/tpl/productattributevalueline_view.tpl.php' => ['PhanUndeclaredProperty'], 'htdocs/viewimage.php' => ['PhanUndeclaredMethod'], 'htdocs/webhook/class/api_webhook.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'], 'htdocs/webhook/class/target.class.php' => ['PhanUndeclaredMethod'], - 'htdocs/webhook/target_card.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'], - 'htdocs/webhook/target_list.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'], + 'htdocs/webhook/target_card.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/webportal/admin/setup.php' => ['PhanTypeMismatchArgument'], 'htdocs/webportal/class/html.formcardwebportal.class.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanUndeclaredProperty'], 'htdocs/webportal/class/html.formlistwebportal.class.php' => ['PhanTypeInvalidDimOffset', 'PhanTypeMismatchArgument', 'PhanUndeclaredProperty'], diff --git a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php index ec0864bba1b..5f248d984ed 100644 --- a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php +++ b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php @@ -313,7 +313,7 @@ class InterfaceTicketEmail extends DolibarrTriggers /** * Return if contact source is external or thirdparty * - * @param array{source:string,id:int,rowid:int,email:string,civility:string,firstname:string,lastname:string,labeltype:string,libelle:string,socid:int,code:string,status:int,statuscontact:string,fk_c_typecontact:string,phone:string,phone_mobile:string,nom:string} $contact + * @param array{source:string,id:int,rowid:int,email:string,civility:string,firstname:string,lastname:string,labeltype:string,libelle:string,socid:int,code:string,status:int,statuscontact:int,fk_c_typecontact:int,phone:string,phone_mobile:string,phone_perso?:string,nom:string} $contact * @return bool */ static function ($contact) { diff --git a/htdocs/ticket/agenda.php b/htdocs/ticket/agenda.php index 91bbd1ed699..c5bd3d00e07 100644 --- a/htdocs/ticket/agenda.php +++ b/htdocs/ticket/agenda.php @@ -1,6 +1,6 @@ - * Copyright (C) 2024 MDW +/* Copyright (C) 2013-2016 Jean-François FERRY + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -214,7 +214,7 @@ if (isModEnabled("societe")) { if ($action != 'editcustomer' && $permissiontoadd) { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetThirdParty'), 0).' '; } - $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, $action == 'editcustomer' ? 'editcustomer' : 'none', '', 1, 0, 0, array(), 1); + $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, (string) $object->socid, $action == 'editcustomer' ? 'editcustomer' : 'none', '', 1, 0, 0, array(), 1); } // Project @@ -226,7 +226,7 @@ if (isModEnabled('project')) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, (string) $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $morehtmlref .= '
'; diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index b30c1c9bdd5..c6c6adf30df 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -6,7 +6,7 @@ * Copyright (C) 2021 Alexandre Spangaro * Copyright (C) 2022-2023 Charlene Benke * Copyright (C) 2023 Benjamin Falière - * Copyright (C) 2024-2025 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Irvine FLEITH * * This program is free software; you can redistribute it and/or modify @@ -509,7 +509,7 @@ if (empty($reshook)) { // Set progress status if ($action == 'set_progression' && $user->hasRight('ticket', 'write')) { if ($object->fetch(GETPOSTINT('id'), '', GETPOST('track_id', 'alpha')) >= 0) { - $result = $object->setProgression(GETPOST('progress', 'alpha')); + $result = $object->setProgression(GETPOSTINT('progress')); $url = 'card.php?track_id=' . $object->track_id; header("Location: " . $url); @@ -985,7 +985,7 @@ if ($action == 'create' || $action == 'presend') { if ($action != 'editcustomer' && $permissiontoedit) { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetThirdParty'), 0).' '; } - $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, $action == 'editcustomer' ? 'editcustomer' : 'none', '', 1, 0, 0, array(), 1); + $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, (string) $object->socid, $action == 'editcustomer' ? 'editcustomer' : 'none', '', 1, 0, 0, array(), 1); if (!empty($object->socid)) { $morehtmlref .= ' - '.img_picto($langs->trans("Tickets"), 'ticket', 'class="pictofixedwidth"').' '.$langs->trans("TicketHistory").''; } @@ -1001,7 +1001,7 @@ if ($action == 'create' || $action == 'presend') { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, (string) $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $object->fetchProject(); @@ -1355,81 +1355,82 @@ if ($action == 'create' || $action == 'presend') { foreach (array('internal', 'external') as $source) { $tmpobject = $object; $tab = $tmpobject->listeContact(-1, $source); - '@phan-var-force array $tab'; - $num = is_array($tab) ? 0 : count($tab); + // '@phan-var-force array $tab'; + $num = is_array($tab) ? count($tab) : 0; $i = 0; foreach (array_keys($tab) as $i) { + $tab_i = &$tab[$i]; $var = !$var; print '
'; print '
'; - if ($tab[$i]['source'] == 'internal') { + if ($tab_i['source'] == 'internal') { echo $langs->trans("User"); } - if ($tab[$i]['source'] == 'external') { + if ($tab_i['source'] == 'external') { echo $langs->trans("ThirdPartyContact"); } print '
'; print '
'; - if ($tab[$i]['socid'] > 0) { - $companystatic->fetch($tab[$i]['socid']); + if ($tab_i['socid'] > 0) { + $companystatic->fetch($tab_i['socid']); echo $companystatic->getNomUrl(-1); } - if ($tab[$i]['socid'] < 0) { + if ($tab_i['socid'] < 0) { echo getDolGlobalString('MAIN_INFO_SOCIETE_NOM'); } - if (!$tab[$i]['socid']) { + if (!$tab_i['socid']) { echo ' '; } print '
'; print '
'; - if ($tab[$i]['source'] == 'internal') { - if ($userstatic->fetch($tab[$i]['id'])) { + if ($tab_i['source'] == 'internal') { + if ($userstatic->fetch($tab_i['id'])) { print $userstatic->getNomUrl(-1); } } - if ($tab[$i]['source'] == 'external') { - if ($contactstatic->fetch($tab[$i]['id'])) { + if ($tab_i['source'] == 'external') { + if ($contactstatic->fetch($tab_i['id'])) { print $contactstatic->getNomUrl(-1); } } print '
-
' . $tab[$i]['libelle'].'
'; +
' . $tab_i['libelle'].'
'; print '
'; - print dol_print_phone($tab[$i]['phone'], '', 0, 0, 'AC_TEL').'
'; + print dol_print_phone($tab_i['phone'], '', 0, 0, 'AC_TEL').'
'; - if (!empty($tab[$i]['phone_perso'])) { + if (array_key_exists('phone_perso', $tab_i) && !empty($tab_i['phone_perso'])) { //print img_picto($langs->trans('PhonePerso'),'object_phoning.png','',0,0,0).' '; - print '
'.dol_print_phone($tab[$i]['phone_perso'], '', 0, 0, 'AC_TEL').'
'; + print '
'.dol_print_phone((string) $tab_i['phone_perso'], '', 0, 0, 'AC_TEL').'
'; } - if (!empty($tab[$i]['phone_mobile'])) { + if (!empty($tab_i['phone_mobile'])) { //print img_picto($langs->trans('PhoneMobile'),'object_phoning.png','',0,0,0).' '; - print dol_print_phone($tab[$i]['phone_mobile'], '', 0, 0, 'AC_TEL').'
'; + print dol_print_phone($tab_i['phone_mobile'], '', 0, 0, 'AC_TEL').'
'; } print '
'; print '
'; if ($object->status >= 0) { - echo ''; + echo ''; } - if ($tab[$i]['source'] == 'internal') { - $userstatic->id = $tab[$i]['id']; - $userstatic->lastname = $tab[$i]['lastname']; - $userstatic->firstname = $tab[$i]['firstname']; - echo $userstatic->LibStatut($tab[$i]['statuscontact'], 3); + if ($tab_i['source'] == 'internal') { + $userstatic->id = $tab_i['id']; + $userstatic->lastname = $tab_i['lastname']; + $userstatic->firstname = $tab_i['firstname']; + echo $userstatic->LibStatut($tab_i['statuscontact'], 3); } - if ($tab[$i]['source'] == 'external') { - $contactstatic->id = $tab[$i]['id']; - $contactstatic->lastname = $tab[$i]['lastname']; - $contactstatic->firstname = $tab[$i]['firstname']; - echo $contactstatic->LibStatut($tab[$i]['statuscontact'], 3); + if ($tab_i['source'] == 'external') { + $contactstatic->id = $tab_i['id']; + $contactstatic->lastname = $tab_i['lastname']; + $contactstatic->firstname = $tab_i['firstname']; + echo $contactstatic->LibStatut($tab_i['statuscontact'], 3); } if ($object->status >= 0) { echo ''; @@ -1642,7 +1643,7 @@ if ($action == 'create' || $action == 'presend') { $codelang = $object->thirdparty->default_lang; } - print $formfile->showdocuments('ticket', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', 0, '', $codelang); + print $formfile->showdocuments('ticket', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $codelang); // Show links to link elements $tmparray = $form->showLinkToObjectBlock($object, array(), array('ticket'), 1); diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index d673b108b14..bc43ab88bbb 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2016 Christophe Battarel * Copyright (C) 2024 Destailleur Laurent * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -263,9 +263,9 @@ class ActionsTicket extends CommonHookActions /** * View html list of message for ticket * - * @param boolean $show_private Show private messages - * @param boolean $show_user Show user who make action - * @param Ticket $object Object ticket + * @param bool $show_private Show private messages + * @param bool $show_user Show user who make action + * @param Ticket $object Object ticket * @return void */ public function viewTicketMessages($show_private, $show_user, $object) @@ -412,9 +412,9 @@ class ActionsTicket extends CommonHookActions /** * View list of message for ticket with timeline display * - * @param boolean $show_private Show private messages - * @param boolean $show_user Show user who make action - * @param Ticket $object Object ticket + * @param bool $show_private Show private messages + * @param bool $show_user Show user who make action + * @param Ticket $object Object ticket * @return void */ public function viewTicketTimelineMessages($show_private, $show_user, Ticket $object) diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 92c95699183..24e29b93cd7 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -217,7 +217,7 @@ class Ticket extends CommonObject public $cache_types_tickets; /** - * @var array cache msgs ticket + * @var array cache msgs ticket // fk_contact_author is email, not key in the cache */ public $cache_msgs_ticket; @@ -852,9 +852,9 @@ class Ticket extends CommonObject if (is_array($filter)) { foreach ($filter as $key => $value) { if (strpos($key, 'date')) { // To allow $filter['YEAR(s.dated)']=>$year - $sql .= " AND ".$this->db->sanitize($key)." = '".$this->db->escape($value)."'"; + $sql .= " AND ".$this->db->sanitize($key)." = '".$this->db->escape((string) $value)."'"; } elseif (($key == 't.fk_user_assign') || ($key == 't.type_code') || ($key == 't.category_code') || ($key == 't.severity_code') || ($key == 't.fk_soc')) { - $sql .= " AND ".$this->db->sanitize($key)." = '".$this->db->escape($value)."'"; + $sql .= " AND ".$this->db->sanitize($key)." = '".$this->db->escape((string) $value)."'"; } elseif ($key == 't.fk_statut') { if (is_array($value) && count($value) > 0) { $sql .= " AND ".$this->db->sanitize($key)." IN (".$this->db->sanitize(implode(',', $value)).")"; @@ -864,7 +864,7 @@ class Ticket extends CommonObject } elseif ($key == 't.fk_contract') { $sql .= " AND ".$this->db->sanitize($key).' = '.((int) $value); } else { - $sql .= " AND ".$this->db->sanitize($key)." LIKE '%".$this->db->escape($this->db->escapeforlike($value))."%'"; + $sql .= " AND ".$this->db->sanitize($key)." LIKE '%".$this->db->escape($this->db->escapeforlike((string) $value))."%'"; } } @@ -1091,7 +1091,7 @@ class Ticket extends CommonObject $sql .= " message=".(isset($this->message) ? "'".$this->db->escape($this->message)."'" : "null").","; $sql .= " fk_statut=".(isset($this->status) ? (int) $this->status : "0").","; $sql .= " resolution=".(isset($this->resolution) ? (int) $this->resolution : "null").","; - $sql .= " progress=".(isset($this->progress) ? "'".$this->db->escape($this->progress)."'" : "null").","; + $sql .= " progress=".(isset($this->progress) ? "'".$this->db->escape((string) $this->progress)."'" : "null").","; $sql .= " timing=".(isset($this->timing) ? "'".$this->db->escape($this->timing)."'" : "null").","; $sql .= " type_code=".(isset($this->type_code) ? "'".$this->db->escape($this->type_code)."'" : "null").","; $sql .= " category_code=".(isset($this->category_code) ? "'".$this->db->escape($this->category_code)."'" : "null").","; @@ -2274,7 +2274,7 @@ class Ticket extends CommonObject * Retrieve information about external contacts * * @param int $status Status of user or company - * @return array|int<-1,-1> Array with data : firstname, lastname, socid (-1 for internal users), email, code, libelle, status + * @return array|int<-1,-1> Array with data : firstname, lastname, socid (-1 for internal users), email, code, libelle, status */ public function getInfosTicketExternalContact($status = -1) { @@ -2345,7 +2345,7 @@ class Ticket extends CommonObject * @param int $list 0:Return array contains all properties, 1:Return array contains just id * @param string $code Filter on this code of contact type ('SHIPPING', 'BILLING', ...) * @param int $status Status of user or company - * @return array|int<-1,-1> Array of array('email'=>..., 'lastname'=>...) + * @return array|int<-1,-1> Array of array('email'=>..., 'lastname'=>...) */ public function listeContact($statusoflink = -1, $source = 'external', $list = 0, $code = '', $status = -1) { @@ -2422,22 +2422,25 @@ class Ticket extends CommonObject $labelType = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->type_contact_label); $tab[$i] = array( 'source' => $obj->source, - 'socid' => $obj->socid, - 'id' => $obj->id, + 'socid' => (int) $obj->socid, + 'id' => (int) $obj->id, 'nom' => $obj->lastname, // For backward compatibility 'civility' => $obj->civility, 'lastname' => $obj->lastname, 'firstname' => $obj->firstname, 'email' => $obj->email, - 'rowid' => $obj->rowid, + 'rowid' => (int) $obj->rowid, 'code' => $obj->code, 'libelle' => $labelType, // deprecated, replaced with labeltype 'labeltype' => $labelType, 'status' => $obj->statuslink, - 'statuscontact' => $obj->statuscontact, - 'fk_c_type_contact' => $obj->fk_c_type_contact, + 'statuscontact' => (int) $obj->statuscontact, + 'fk_c_type_contact' => (int) $obj->fk_c_type_contact, 'phone' => $obj->phone, 'phone_mobile' => $obj->phone_mobile); + if ($source == 'external') { + $tab[$i]['phone_perso'] = $obj->phone_perso; + } } else { $tab[$i] = $obj->id; } @@ -2695,7 +2698,7 @@ class Ticket extends CommonObject $object->message = GETPOST("message", "restricthtml"); $object->private = GETPOST("private_message", "alpha"); - $send_email = GETPOSTINT('send_email'); + $send_email = (bool) GETPOSTINT('send_email'); // Copy attached files (saved into $_SESSION) as linked files to ticket. Return array with final name used. $resarray = $object->copyFilesForTicket(); diff --git a/htdocs/ticket/class/ticketstats.class.php b/htdocs/ticket/class/ticketstats.class.php index 3ec67e15f23..e3d09a07a32 100644 --- a/htdocs/ticket/class/ticketstats.class.php +++ b/htdocs/ticket/class/ticketstats.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -125,7 +125,7 @@ class TicketStats extends Stats { $sql = "SELECT date_format(datec,'%m') as dm, sum(".$this->field.")"; $sql .= " FROM ".$this->from; - $sql .= " WHERE date_format(datec,'%Y') = '".$this->db->escape($year)."'"; + $sql .= " WHERE date_format(datec,'%Y') = '".$this->db->escape((string) $year)."'"; $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; $sql .= $this->db->order('dm', 'DESC'); @@ -145,7 +145,7 @@ class TicketStats extends Stats { $sql = "SELECT date_format(datec,'%m') as dm, avg(".$this->field.")"; $sql .= " FROM ".$this->from; - $sql .= " WHERE date_format(datec,'%Y') = '".$this->db->escape($year)."'"; + $sql .= " WHERE date_format(datec,'%Y') = '".$this->db->escape((string) $year)."'"; $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; $sql .= $this->db->order('dm', 'DESC'); diff --git a/htdocs/ticket/contact.php b/htdocs/ticket/contact.php index 64dee97164e..6af140e129c 100644 --- a/htdocs/ticket/contact.php +++ b/htdocs/ticket/contact.php @@ -2,7 +2,7 @@ /* Copyright (C) 2011-2016 Jean-François Ferry * Copyright (C) 2011 Regis Houssin * Copyright (C) 2016 Christophe Battarel - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -262,7 +262,7 @@ if ($id > 0 || !empty($track_id) || !empty($ref)) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, (string) $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $morehtmlref .= '
'; diff --git a/htdocs/ticket/document.php b/htdocs/ticket/document.php index ae935b8f101..16d89ed34ee 100644 --- a/htdocs/ticket/document.php +++ b/htdocs/ticket/document.php @@ -5,6 +5,7 @@ * Copyright (C) 2010 Juanjo Menent * Copyright (C) 2013-2016 Jean-François Ferry * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -184,7 +185,7 @@ if ($object->id) { if ($action != 'editcustomer' && $permissiontoadd) { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetThirdParty'), 0).' '; } - $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, $action == 'editcustomer' ? 'editcustomer' : 'none', '', 1, 0, 0, array(), 1); + $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, (string) $object->socid, $action == 'editcustomer' ? 'editcustomer' : 'none', '', 1, 0, 0, array(), 1); } // Project @@ -196,7 +197,7 @@ if ($object->id) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, (string) $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $morehtmlref .= '
'; diff --git a/htdocs/ticket/index.php b/htdocs/ticket/index.php index b3e5b8cb332..7d39d10d9e2 100644 --- a/htdocs/ticket/index.php +++ b/htdocs/ticket/index.php @@ -2,7 +2,7 @@ /* Copyright (C) 2013-2016 Jean-François FERRY * Copyright (C) 2019 Nicolas ZABOURI * Copyright (C) 2021-2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -110,6 +110,7 @@ $param_year = 'DOLUSERCOOKIE_ticket_by_status_year'; $param_shownb = 'DOLUSERCOOKIE_ticket_by_status_shownb'; $param_showtot = 'DOLUSERCOOKIE_ticket_by_status_showtot'; $autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE')); +$showtot = 0; if (in_array('DOLUSERCOOKIE_ticket_by_status', $autosetarray)) { $endyear = GETPOSTINT($param_year); $shownb = GETPOST($param_shownb, 'alpha'); @@ -185,6 +186,7 @@ if ($user->socid > 0) { } $sql .= " GROUP BY t.fk_statut"; +$dataseries = array(); $result = $db->query($sql); if ($result) { while ($objp = $db->fetch_object($result)) { @@ -217,7 +219,6 @@ if ($result) { include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; // This define $badgeStatusX - $dataseries = array(); $colorseries = array(); $dataseries[] = array('label' => $langs->transnoentitiesnoconv($object->labelStatusShort[Ticket::STATUS_NOT_READ]), 'data' => round($tick['unread'])); diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 009bf1536f8..8896258c625 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -5,7 +5,7 @@ * Copyright (C) 2019-2021 Juanjo Menent * Copyright (C) 2019-2020 Laurent Destailleur * Copyright (C) 2023 Charlene Benke - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Benjamin Falière * Copyright (C) 2024 Frédéric France * @@ -1111,7 +1111,7 @@ while ($i < $imaxinloop) { if (!empty($arrayfields['t.'.$key]['checked'])) { print '$key)) { - print ' title="'.dol_escape_htmltag($object->$key).'"'; + print ' title="'.dol_escape_htmltag((string) $object->$key).'"'; } print '>'; if ($key == 'fk_statut') { diff --git a/htdocs/ticket/messaging.php b/htdocs/ticket/messaging.php index 7e35d9aa060..6d0368cb407 100644 --- a/htdocs/ticket/messaging.php +++ b/htdocs/ticket/messaging.php @@ -1,6 +1,6 @@ - * Copyright (C) 2024 MDW +/* Copyright (C) 2013-2016 Jean-François FERRY + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -211,7 +211,7 @@ if (isModEnabled("societe")) { if ($action != 'editcustomer' && $permissiontoadd) { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetThirdParty'), 0).' '; } - $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, $action == 'editcustomer' ? 'editcustomer' : 'none', '', 1, 0, 0, array(), 1); + $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, (string) $object->socid, $action == 'editcustomer' ? 'editcustomer' : 'none', '', 1, 0, 0, array(), 1); } } @@ -224,7 +224,7 @@ if (isModEnabled('project')) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, (string) $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/ticket/stats/index.php b/htdocs/ticket/stats/index.php index beefb4f0e6f..f020f29bf15 100644 --- a/htdocs/ticket/stats/index.php +++ b/htdocs/ticket/stats/index.php @@ -1,6 +1,6 @@ - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -181,7 +181,7 @@ print ''; // User print ''.$langs->trans("CreatedBy").''; print img_picto('', 'user', 'class="pictofixedwidth"'); -print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300'); +print $form->select_dolusers($userid, 'userid', 1, null, 0, '', '', '0', 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300'); // Status print ''.$langs->trans("Status").''; $liststatus = $object->fields['fk_statut']['arrayofkeyval']; diff --git a/htdocs/variants/ajax/get_attribute_values.php b/htdocs/variants/ajax/get_attribute_values.php index da94b3fa172..3d03826d000 100644 --- a/htdocs/variants/ajax/get_attribute_values.php +++ b/htdocs/variants/ajax/get_attribute_values.php @@ -2,6 +2,7 @@ /* Copyright (C) 2016 Marcos García * Copyright (C) 2022 Open-Dsi * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -85,11 +86,4 @@ $prodattrval = new ProductAttributeValue($db); $res = $prodattrval->fetchAllByProductAttribute($id, false, 1); -if ($res == -1) { - print json_encode(array( - 'error' => 'Internal error' - )); - exit(); -} - print json_encode($res, JSON_PARTIAL_OUTPUT_ON_ERROR); diff --git a/htdocs/variants/card.php b/htdocs/variants/card.php index eebd41e3494..d490f94a2a5 100644 --- a/htdocs/variants/card.php +++ b/htdocs/variants/card.php @@ -2,6 +2,7 @@ /* Copyright (C) 2016 Marcos García * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2022 Open-Dsi + * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -50,7 +51,7 @@ $cancel = GETPOST('cancel', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'productattribute'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); -$lineid = GETPOST('lineid', 'alpha'); +$lineid = GETPOSTINT('lineid'); // Security check if (!isModEnabled('variants')) { @@ -124,14 +125,14 @@ if (empty($reshook)) { // Action to move up and down lines of object if ($action == 'up' && $permissiontoedit) { - $object->line_up(GETPOST('rowid'), false); + $object->line_up(GETPOSTINT('rowid'), false); - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.GETPOST('rowid')); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.GETPOSTINT('rowid')); exit(); } elseif ($action == 'down' && $permissiontoedit) { - $object->line_down(GETPOST('rowid'), false); + $object->line_down(GETPOSTINT('rowid'), false); - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.GETPOST('rowid')); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.GETPOSTINT('rowid')); exit(); } diff --git a/htdocs/variants/class/ProductAttribute.class.php b/htdocs/variants/class/ProductAttribute.class.php index 2a6fd052745..963fef367f7 100644 --- a/htdocs/variants/class/ProductAttribute.class.php +++ b/htdocs/variants/class/ProductAttribute.class.php @@ -1445,8 +1445,8 @@ class ProductAttribute extends CommonObject * @param int $i I * @param int $dateSelector 1=Show also date range input fields * @param Societe $seller Object of seller third party - * @param Societe $buyer Object of buyer third party - * @param int $selected Object line selected + * @param ?Societe $buyer Object of buyer third party + * @param int<0,1> $selected Object line selected * @param ?Extrafields $extrafields Object of extrafields * @param string $defaulttpldir Directory where to find the template (deprecated) * @return void diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 6b6524028fb..088a56488a4 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -632,7 +632,7 @@ class ProductCombination * Retrieves the combination that matches the given features. * * @param int $prodid Id of parent product - * @param array $features Format: [$attr] => $attr_val + * @param array $features Format: [$attr] => $attr_val * @return false|ProductCombination False if not found */ public function fetchByProductCombination2ValuePairs($prodid, array $features) @@ -985,23 +985,23 @@ class ProductCombination $prodcomb2val = new ProductCombination2ValuePair($this->db); //Retrieve all product combinations - $combinations = $this->fetchAllByFkProductParent($origProductId); + $combinationObjects = $this->fetchAllByFkProductParent($origProductId); - foreach ($combinations as $combination) { - $variations = array(); + foreach ($combinationObjects as $combinationObject) { + $combinations = array(); - foreach ($prodcomb2val->fetchByFkCombination($combination->id) as $tmp_pc2v) { - $variations[$tmp_pc2v->fk_prod_attr] = $tmp_pc2v->fk_prod_attr_val; + foreach ($prodcomb2val->fetchByFkCombination($combinationObject->id) as $tmp_pc2v) { + $combinations[$tmp_pc2v->fk_prod_attr] = $tmp_pc2v->fk_prod_attr_val; } - $variation_price_percentage = $combination->variation_price_percentage; - $variation_price = $combination->variation_price; + $variation_price_percentage = $combinationObject->variation_price_percentage; + $variation_price = $combinationObject->variation_price; if (getDolGlobalInt('PRODUIT_MULTIPRICES') && getDolGlobalInt('PRODUIT_MULTIPRICES_LIMIT') > 1) { $variation_price_percentage = [ ]; $variation_price = [ ]; - foreach ($combination->combination_price_levels as $productCombinationLevel) { + foreach ($combinationObject->combination_price_levels as $productCombinationLevel) { $variation_price_percentage[$productCombinationLevel->fk_price_level] = $productCombinationLevel->variation_price_percentage; $variation_price[$productCombinationLevel->fk_price_level] = $productCombinationLevel->variation_price; } @@ -1010,11 +1010,11 @@ class ProductCombination if ($this->createProductCombination( $user, $destProduct, - $variations, + $combinations, array(), $variation_price_percentage, $variation_price, - $combination->variation_weight + $combinationObject->variation_weight ) < 0) { return -1; } diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index eb1ecceddc4..76393d921e2 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -3,7 +3,7 @@ * Copyright (C) 2017 Laurent Destailleur * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2022 Open-Dsi - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -177,7 +177,7 @@ if (($action == 'add' || $action == 'create') && $usercancreate && empty($massac //First, sanitize foreach ($features as $feature) { $explode = explode('-', $feature); - if ($prodattr->fetch($explode[0]) <= 0 || $prodattr_val->fetch($explode[1]) <= 0) { + if ($prodattr->fetch((int) $explode[0]) <= 0 || $prodattr_val->fetch((int) $explode[1]) <= 0) { continue; } @@ -196,7 +196,7 @@ if (($action == 'add' || $action == 'create') && $usercancreate && empty($massac // sanit_feature is an array with 1 (and only 1) value per attribute. // For example: Color->blue, Size->Small, Option->2 if (!$prodcomb->fetchByProductCombination2ValuePairs($id, $sanit_features)) { - $result = $prodcomb->createProductCombination($user, $object, $sanit_features, array(), $level_price_impact_percent, $level_price_impact, $weight_impact, $reference); + $result = $prodcomb->createProductCombination($user, $object, $sanit_features, array(), $level_price_impact_percent, $level_price_impact, (float) $weight_impact, $reference); if ($result > 0) { setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); unset($_SESSION['addvariant_'.$object->id]); @@ -319,7 +319,7 @@ if (($action == 'add' || $action == 'create') && $usercancreate && empty($massac // Update product variant ref $product_child = new Product($db); $product_child->fetch($prodcomb->fk_product_child); - $product_child->oldcopy = clone $product_child; // @phan-ignore-current-line PhanTypeMismatchProperty + $product_child->oldcopy = clone $product_child; // @phan-suppress-current-line PhanTypeMismatchProperty $product_child->ref = $reference; $result = $product_child->update($product_child->id, $user); @@ -438,7 +438,7 @@ if (!empty($id) || !empty($ref)) { if (isModEnabled("product") && isModEnabled("service")) { $typeformat = 'select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service"); print ''; - print (!getDolGlobalString('PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey("Type", 'fk_product_type', $object->type, $object, $usercancreate, $typeformat) : $langs->trans('Type'); + print (!getDolGlobalString('PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey("Type", 'fk_product_type', (string) $object->type, $object, (int) $usercancreate, $typeformat) : $langs->trans('Type'); print ''; print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, $usercancreate, $typeformat); print ''; @@ -517,7 +517,7 @@ if (!empty($id) || !empty($ref)) { $toprint = array(); foreach ($features as $feature) { $explode = explode('-', $feature); - if ($prodattr->fetch($explode[0]) <= 0 || $prodattr_val->fetch($explode[1]) <= 0) { + if ($prodattr->fetch((int) $explode[0]) <= 0 || $prodattr_val->fetch((int) $explode[1]) <= 0) { continue; } $toprint[] = '
  • ' . $prodattr->label.' : '.$prodattr_val->value . @@ -531,6 +531,8 @@ if (!empty($id) || !empty($ref)) { $title = $langs->trans('EditProductCombination'); } + $prodattr_alljson = null; + $prodattr_all = null; if ($action == 'add') { $prodattr_all = $prodattr->fetchAll(); diff --git a/htdocs/variants/list.php b/htdocs/variants/list.php index 0ce02d3624c..15700e1ed5a 100644 --- a/htdocs/variants/list.php +++ b/htdocs/variants/list.php @@ -1,7 +1,7 @@ * Copyright (C) 2022 Open-Dsi - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Benjamin Falière * Copyright (C) 2024 Frédéric France * @@ -125,8 +125,8 @@ foreach ($object->fields as $key => $val) { $visible = (int) dol_eval((string) $val['visible'], 1); $arrayfields['t.'.$key] = array( 'label' => $val['label'], - 'checked' => (($visible < 0) ? 0 : 1), - 'enabled' => (abs($visible) != 3 && (bool) dol_eval($val['enabled'], 1)), + 'checked' => (($visible < 0) ? '0' : '1'), + 'enabled' => (string) (int) (abs($visible) != 3 && (bool) dol_eval($val['enabled'], 1)), 'position' => $val['position'], 'help' => isset($val['help']) ? $val['help'] : '' ); @@ -134,15 +134,15 @@ foreach ($object->fields as $key => $val) { } $arrayfields['nb_of_values'] = array( 'label' => $langs->trans('NbOfDifferentValues'), - 'checked' => 1, - 'enabled' => 1, + 'checked' => '1', + 'enabled' => '1', 'position' => 40, 'help' => '' ); $arrayfields['nb_products'] = array( 'label' => $langs->trans('NbProducts'), - 'checked' => 1, - 'enabled' => 1, + 'checked' => '1', + 'enabled' => '1', 'position' => 50, 'help' => '' ); @@ -151,7 +151,6 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan $permissiontoread = $user->hasRight('variants', 'read'); $permissiontoadd = $user->hasRight('variants', 'write'); @@ -754,13 +753,13 @@ while ($i < $imaxinloop) { if (!empty($arrayfields['t.' . $key]['checked'])) { print '$key)) { - print ' title="'.dol_escape_htmltag($object->$key).'"'; + print ' title="'.dol_escape_htmltag((string) $object->$key).'"'; } print '>'; if ($key == 'status') { print $object->getLibStatut(5); } elseif ($key == 'rowid') { - print $object->showOutputField($val, $key, $object->id, ''); + print $object->showOutputField($val, $key, (string) $object->id, ''); } else { print $object->showOutputField($val, $key, $object->$key, ''); } diff --git a/htdocs/variants/tpl/productattributevalueline_edit.tpl.php b/htdocs/variants/tpl/productattributevalueline_edit.tpl.php index 5eb54a875c9..eee8781878b 100644 --- a/htdocs/variants/tpl/productattributevalueline_edit.tpl.php +++ b/htdocs/variants/tpl/productattributevalueline_edit.tpl.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -41,6 +42,12 @@ * @var int $num */ +' +@phan-var-force string $action +@phan-var-force int $i +@phan-var-force int $num +'; + // Protection to avoid direct call of template if (empty($object) || !is_object($object)) { print "Error, template page can't be called as URL"; diff --git a/htdocs/webhook/target_card.php b/htdocs/webhook/target_card.php index 02b216c7ffc..bae95eb9a56 100644 --- a/htdocs/webhook/target_card.php +++ b/htdocs/webhook/target_card.php @@ -1,7 +1,7 @@ * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -158,7 +158,7 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; if ($action == 'set_thirdparty' && $permissiontoadd) { - $object->setValueFrom('fk_soc', GETPOSTINT('fk_soc'), '', '', 'date', '', $user, $triggermodname); + $object->setValueFrom('fk_soc', GETPOSTINT('fk_soc'), '', null, 'date', '', $user, $triggermodname); } if ($action == 'classin' && $permissiontoadd) { $object->setProject(GETPOSTINT('projectid')); diff --git a/htdocs/webhook/target_list.php b/htdocs/webhook/target_list.php index 30e70a8ea09..ac0b0c91686 100644 --- a/htdocs/webhook/target_list.php +++ b/htdocs/webhook/target_list.php @@ -1,7 +1,7 @@ - * Copyright (C) ---Put here your own copyright and developer email--- * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -122,11 +122,11 @@ foreach ($object->fields as $key => $val) { if (!empty($val['visible'])) { $visible = (int) dol_eval((string) $val['visible'], 1); $arrayfields['t.'.$key] = array( - 'label'=>$val['label'], - 'checked'=>(($visible < 0) ? 0 : 1), - 'enabled'=>(abs($visible) != 3 && (bool) dol_eval($val['enabled'], 1)), - 'position'=>$val['position'], - 'help'=> isset($val['help']) ? $val['help'] : '' + 'label' => $val['label'], + 'checked' => (($visible < 0) ? '0' : '1'), + 'enabled' => (string) (int) (abs($visible) != 3 && (bool) dol_eval($val['enabled'], 1)), + 'position' => $val['position'], + 'help' => isset($val['help']) ? $val['help'] : '' ); } } @@ -563,7 +563,7 @@ foreach ($object->fields as $key => $val) { } elseif ($key == 'lang') { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; $formadmin = new FormAdmin($db); - print $formadmin->select_language((isset($search[$key]) ? $search[$key] : ''), 'search_lang', 0, null, 1, 0, 0, 'minwidth100imp maxwidth125', 2); + print $formadmin->select_language((isset($search[$key]) ? $search[$key] : ''), 'search_lang', 0, array(), 1, 0, 0, 'minwidth100imp maxwidth125', 2); } else { print ''; } @@ -574,7 +574,7 @@ foreach ($object->fields as $key => $val) { include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters = array('arrayfields'=>$arrayfields); +$parameters = array('arrayfields' => $arrayfields); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; /*if (!empty($arrayfields['anotherfield']['checked'])) { @@ -621,7 +621,7 @@ foreach ($object->fields as $key => $val) { // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); +$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; /*if (!empty($arrayfields['anotherfield']['checked'])) { @@ -727,13 +727,13 @@ while ($i < $imaxinloop) { if (!empty($arrayfields['t.'.$key]['checked'])) { print '$key)) { - print ' title="'.dol_escape_htmltag($object->$key).'"'; + print ' title="'.dol_escape_htmltag((string) $object->$key).'"'; } print '>'; if ($key == 'status') { print $object->getLibStatut(5); } elseif ($key == 'rowid') { - print $object->showOutputField($val, $key, $object->id, ''); + print $object->showOutputField($val, $key, (string) $object->id, ''); } else { print $object->showOutputField($val, $key, $object->$key, ''); } @@ -758,7 +758,7 @@ while ($i < $imaxinloop) { // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; /*if (!empty($arrayfields['anotherfield']['checked'])) { @@ -803,7 +803,7 @@ if ($num == 0) { $db->free($resql); -$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint;