From dc15b2ee79f3a25722eee498b86b34f121de1ef2 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 20 Mar 2024 13:39:11 +0100 Subject: [PATCH 01/27] Qual: Bump logToCheckStyle for better filename handling # Qual: Bump logToCheckStyle for better filename handling Some notifications from the PHPCS step in pre-commit extracted too many characters for the filename in a specific case. The update to logToCheckStyle fixes that. --- .github/workflows/pre-commit.yml | 2 +- .github/workflows/windows-ci.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index b29ae8aa809..671a266c767 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -106,7 +106,7 @@ jobs: ls -l ~/.cache/pre-commit/ - name: Convert Raw Log to Annotations - uses: mdeweerd/logToCheckStyle@2024.3.2 + uses: mdeweerd/logToCheckStyle@v2024.3.4 if: ${{ failure() }} with: in: ${{ env.RAW_LOG }} diff --git a/.github/workflows/windows-ci.yaml b/.github/workflows/windows-ci.yaml index edcb9d39226..cb467055156 100644 --- a/.github/workflows/windows-ci.yaml +++ b/.github/workflows/windows-ci.yaml @@ -150,7 +150,7 @@ jobs: for /f "tokens=2 delims==" %%A in ('doskey /m:err') do EXIT /B %%A - name: Convert Raw Log to Annotations - uses: mdeweerd/logToCheckStyle@2024.3.2 + uses: mdeweerd/logToCheckStyle@v2024.3.4 if: ${{ failure() }} with: in: ${{ env.PHPUNIT_LOG }} From 33486f10c05b9e24796aa29ced078ccf31b13d3f Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 20 Mar 2024 13:58:43 +0100 Subject: [PATCH 02/27] Fix PhanTypeMismatchReturnNullable by initialising return value --- htdocs/adherents/class/adherent.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index c6ce7429708..f71fa705c3f 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -560,12 +560,13 @@ class Adherent extends CommonObject * Return translated label by the nature of a adherent (physical or moral) * * @param string $morphy Nature of the adherent (physical or moral) - * @param int $addbadge Add badge (1=Full label, 2=First letters only) + * @param int<0,2> $addbadge Add badge (1=Full label, 2=First letters only) * @return string Label */ public function getmorphylib($morphy = '', $addbadge = 0) { global $langs; + $s = ''; // Clean var if (!$morphy) { @@ -573,7 +574,6 @@ class Adherent extends CommonObject } if ($addbadge) { - $s = ''; $labeltoshowm = $langs->trans("Moral"); $labeltoshowp = $langs->trans("Physical"); if ($morphy == 'phy') { From 3b93de27097f3a8926d1d9f750a952472dffde8c Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 20 Mar 2024 14:10:45 +0100 Subject: [PATCH 03/27] Fix PhanTypeMismatchReturnNullable by initialising return value + Some PHPdoc typing --- .../adherents/class/adherentstats.class.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index f99b20f86d5..612f408edd9 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -3,6 +3,7 @@ * Copyright (c) 2005-2011 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2023 Waël Almoman + * Copyright (C) 2024 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 @@ -168,15 +169,15 @@ class AdherentStats extends Stats /** * Return count of member by status group by adh type, total and average * - * @param int $numberYears Number of years to scan (0 = all) - * @return array Array with total of draft, pending, uptodate, expired, resiliated for each member type + * @param int $numberYears Number of years to scan (0 = all) + * @return array Array with total of draft, pending, uptodate, expired, resiliated for each member type */ public function countMembersByTypeAndStatus($numberYears = 0) { global $user; $now = dol_now(); - $endYear = date('Y'); + $endYear = (int) date('Y'); $startYear = $endYear - $numberYears; $sql = "SELECT t.rowid as fk_adherent_type, t.libelle as label"; @@ -224,7 +225,7 @@ class AdherentStats extends Stats 'members_resiliated' => (int) $objp->members_resiliated ); $totalrow = 0; - foreach ($MembersCountArray[$objp->fk_adherent_type] as $key=>$nb) { + foreach ($MembersCountArray[$objp->fk_adherent_type] as $key => $nb) { if ($key != 'label') { $totalrow += $nb; $totalstatus[$key] += $nb; @@ -244,16 +245,17 @@ class AdherentStats extends Stats /** * Return count of member by status group by adh type, total and average * - * @param int $numberYears Number of years to scan (0 = all) - * @return array Array with total of draft, pending, uptodate, expired, resiliated for each member tag + * @param int $numberYears Number of years to scan (0 = all) + * @return array Array with total of draft, pending, uptodate, expired, resiliated for each member tag */ public function countMembersByTagAndStatus($numberYears = 0) { global $user; $now = dol_now(); - $endYear = date('Y'); + $endYear = (int) date('Y'); $startYear = $endYear - $numberYears; + $MembersCountArray = []; $sql = "SELECT c.rowid as fk_categorie, c.label as label"; $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_DRAFT, "'members_draft'", 'NULL').") as members_draft"; @@ -282,7 +284,6 @@ class AdherentStats extends Stats if ($result) { $num = $this->db->num_rows($result); $i = 0; - $MembersCountArray = []; $totalstatus = array( 'label' => 'Total', 'members_draft' => 0, @@ -304,7 +305,7 @@ class AdherentStats extends Stats 'members_resiliated' => (int) $objp->members_resiliated ); $totalrow = 0; - foreach ($MembersCountArray[$objp->fk_categorie] as $key=>$nb) { + foreach ($MembersCountArray[$objp->fk_categorie] as $key => $nb) { if ($key != 'label') { $totalrow += $nb; $totalstatus[$key] += $nb; From 3a27977b46fc942eb664e9f933bbab556051f5d8 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 20 Mar 2024 14:18:37 +0100 Subject: [PATCH 04/27] Fix PhanTypeMismatchReturnNullable with typing test --- htdocs/comm/action/class/actioncomm.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index f4f77bcaa9d..09e73b188f8 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1393,7 +1393,7 @@ class ActionComm extends CommonObject * * @param User $user Object user * @param int $load_state_board Load indicator array this->nb - * @return WorkboardResponse|int Return integer <0 if KO, WorkboardResponse if OK + * @return WorkboardResponse|int<-1,1> Return integer <0 if KO, WorkboardResponse if OK */ public function load_board($user, $load_state_board = 0) { @@ -1462,7 +1462,7 @@ class ActionComm extends CommonObject } $this->db->free($resql); - if (empty($load_state_board)) { + if (empty($load_state_board) && $response instanceof WorkboardResponse) { return $response; } else { return 1; From 0a1a663e3471360ce6a8b79e8df535ad027f6609 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 20 Mar 2024 14:21:35 +0100 Subject: [PATCH 05/27] Fix PhanTypeMismatchReturnNullable with initialisation --- htdocs/comm/propal/class/api_proposals.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index aa1e3d0e980..546d40d052d 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2020 Thibault FOUCART * Copyright (C) 2022 ATM Consulting * Copyright (C) 2022 OpenDSI + * Copyright (C) 2024 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 @@ -410,6 +411,7 @@ class Proposals extends DolibarrApi } $errors = []; + $updateRes = 0; $this->db->begin(); foreach ($request_data as $TData) { From d245dab56b56dcfab7454a395b790052a094a9c3 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 20 Mar 2024 14:56:14 +0100 Subject: [PATCH 06/27] Fix PhanTypeMismatchReturnNullable by setting variable --- htdocs/projet/class/task.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 45dcad80025..84d78726599 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -2051,9 +2051,10 @@ class Task extends CommonObjectLine $this->error = $clone_task->error; $error++; } - // End - if (!$error) { + if ($error) { + $clone_task_id = 0; // For static tool check + } else { $clone_task_id = $clone_task->id; $clone_task_ref = $clone_task->ref; From 7e1bf61c0db34f4deb6308e03472444a8da63249 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 20 Mar 2024 17:59:48 +0100 Subject: [PATCH 07/27] Fix PhanTypeMismatchReturnNullable with init --- htdocs/core/class/html.formprojet.class.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 9bbc5e75018..b6f50754c6b 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2018 Charlene Benke * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 @@ -686,7 +687,7 @@ class FormProjets extends Form * @param string $morecss Add more css * @param int $noadmininfo 0=Add admin info, 1=Disable admin info * @param int $addcombojs 1=Add a js combo - * @return int|string The HTML select list of element or '' if nothing or -1 if KO + * @return int<-1,-1>|string The HTML select list of element or '' if nothing or -1 if KO */ public function selectOpportunityStatus($htmlname, $preselected = '-1', $showempty = 1, $useshortlabel = 0, $showallnone = 0, $showpercent = 0, $morecss = '', $noadmininfo = 0, $addcombojs = 0) { @@ -701,6 +702,7 @@ class FormProjets extends Form if ($resql) { $num = $this->db->num_rows($resql); $i = 0; + $sellist = ''; if ($num > 0) { $sellist = ''; print ''; $newcardbutton = ''; -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition')); $newcardbutton .= dolGetButtonTitleSeparator(); $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/variants/card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); @@ -561,7 +563,7 @@ foreach ($object->fields as $key => $val) { // Extra fields 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; @@ -618,7 +620,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; @@ -757,7 +759,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; // Other @@ -826,7 +828,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; diff --git a/htdocs/workstation/workstation_list.php b/htdocs/workstation/workstation_list.php index 2d1e9d9fefc..3638739a101 100644 --- a/htdocs/workstation/workstation_list.php +++ b/htdocs/workstation/workstation_list.php @@ -2,6 +2,7 @@ /* Copyright (C) 2007-2017 Laurent Destailleur * Copyright (C) 2020 Gauthier VERDOL + * Copyright (C) 2024 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 @@ -149,6 +150,7 @@ 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('workstation', 'workstation', 'read'); $permissiontoadd = $user->hasRight('workstation', 'workstation', 'write'); From 44ef0de1ef1a8440bb666a32bf77990426fba2bb Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 20 Mar 2024 20:05:35 +0100 Subject: [PATCH 22/27] Fix null return by initialising return value, forcing type --- htdocs/core/class/stats.class.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php index 14b636dd2ab..135c9118e03 100644 --- a/htdocs/core/class/stats.class.php +++ b/htdocs/core/class/stats.class.php @@ -129,6 +129,7 @@ abstract class Stats if ($foundintocache) { // Cache file found and is not too old dol_syslog(get_class($this).'::'.__FUNCTION__." read data from cache file ".$newpathofdestfile." ".$filedate."."); $data = json_decode(file_get_contents($newpathofdestfile), true); + '@phan-var-force array,array{0:int<1,12>,1:int}> $data'; } else { $year = $startyear; $sm = $startmonth - 1; @@ -188,7 +189,7 @@ abstract class Stats * @param int $cachedelay Delay we accept for cache file (0=No read, no save of cache, -1=No read but save) * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month * @param int $startmonth month of the fiscal year start min 1 max 12 ; if 1 = january - * @return array Array of values + * @return array,array> Array of values */ public function getAmountByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0, $startmonth = 1) { @@ -199,6 +200,7 @@ abstract class Stats } $datay = array(); + $data = array(); // Return value // Search into cache if (!empty($cachedelay)) { @@ -238,7 +240,6 @@ abstract class Stats $year++; } - $data = array(); // $data = array('xval'=>array(0=>xlabel,1=>yval1,2=>yval2...),...) for ($i = 0; $i < 12; $i++) { $data[$i][] = isset($datay[$endyear][($i + $sm) % 12]['label']) ? $datay[$endyear][($i + $sm) % 12]['label'] : $datay[$endyear][($i + $sm) % 12][0]; // set label @@ -272,17 +273,17 @@ abstract class Stats } /** - * @param int $year year number - * @return array array of values + * @param int $year year number + * @return array,array{0:int<1,12>,1:int|float}> Array of values */ abstract protected function getAverageByMonth($year); /** - * Return average of entity by month for several years + * Return average of entity by month for several years * * @param int $endyear Start year * @param int $startyear End year - * @return array{int<0,11>,array} Array of values + * @return array> Array of values */ public function getAverageByMonthWithPrevYear($endyear, $startyear) { @@ -291,6 +292,7 @@ abstract class Stats } $datay = array(); + $data = array(); $year = $startyear; while ($year <= $endyear) { @@ -298,8 +300,6 @@ abstract class Stats $year++; } - $data = array(); - for ($i = 0; $i < 12; $i++) { $data[$i][] = $datay[$endyear][$i][0]; $year = $startyear; @@ -353,6 +353,7 @@ abstract class Stats if ($foundintocache) { // Cache file found and is not too old dol_syslog(get_class($this).'::'.__FUNCTION__." read data from cache file ".$newpathofdestfile." ".$filedate."."); $data = json_decode(file_get_contents($newpathofdestfile), true); + '@phan-var-force array,array{0:int<1,12>,1:int|float}> $data'; // Phan can't decode json_decode's return value } else { // This method is defined in parent object only, not into abstract, so we disable phpstan warning /** @phpstan-ignore-next-line */ From 5ee5a4ac2c705b8225a4eff1ee0068b1b197462d Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 20 Mar 2024 20:49:03 +0100 Subject: [PATCH 23/27] Suppress PhanDeprecatedFunction message for stripe --- htdocs/stripe/admin/stripe.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index d5a27ba20fb..919e80088c6 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -4,6 +4,7 @@ * Copyright (C) 2017 Saasprov * Copyright (C) 2018-2022 Thibault FOUCART * Copyright (C) 2018 Frédéric France + * Copyright (C) 2024 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 @@ -256,6 +257,7 @@ if (empty($conf->stripeconnect->enabled)) { } } $endpoint->url = $url; + // @phan-suppress-next-line PhanDeprecatedFunction $endpoint->save(); if ($endpoint->status == 'enabled') { @@ -328,6 +330,7 @@ if (empty($conf->stripeconnect->enabled)) { } } $endpoint->url = $url; + // @phan-suppress-next-line PhanDeprecatedFunction $endpoint->save(); if ($endpoint->status == 'enabled') { print ''; From 942239b5d633be96558b2ac59c3f6543a2d52a81 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 20 Mar 2024 19:56:20 +0100 Subject: [PATCH 24/27] Update PHPdoc to show nullable return --- htdocs/core/db/sqlite3.class.php | 12 ++++++------ htdocs/core/modules/DolibarrModules.class.php | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/core/db/sqlite3.class.php b/htdocs/core/db/sqlite3.class.php index 060e7318b65..1c28d1d71a8 100644 --- a/htdocs/core/db/sqlite3.class.php +++ b/htdocs/core/db/sqlite3.class.php @@ -389,14 +389,14 @@ class DoliDBSqlite3 extends DoliDB } /** - * Execute a SQL request and return the resultset + * Execute a SQL request and return the resultset * - * @param string $query SQL query string - * @param int $usesavepoint 0=Default mode, 1=Run a savepoint before and a rollbock to savepoint if error (this allow to have some request with errors inside global transactions). + * @param string $query SQL query string + * @param int $usesavepoint 0=Default mode, 1=Run a savepoint before and a rollbock to savepoint if error (this allow to have some request with errors inside global transactions). * Note that with Mysql, this parameter is not used as Myssql can already commit a transaction even if one request is in error, without using savepoints. - * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) - * @param int $result_mode Result mode (not used with sqlite) - * @return bool|SQLite3Result Resultset of answer + * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) + * @param int $result_mode Result mode (not used with sqlite) + * @return bool|SQLite3Result|null Resultset of answer */ public function query($query, $usesavepoint = 0, $type = 'auto', $result_mode = 0) { diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 0e0eb57ca22..850ec739d06 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1295,7 +1295,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } if (!$dirfound) { - dol_syslog("A module ask to load sql files into ".$reldir." but this directory was not found.", LOG_WARNING); + dol_syslog("A module wants to load sql files from ".$reldir." but this directory was not found.", LOG_WARNING); } return $ok; } From 53c628f2197d1177e53e9420380de8ac12010f84 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 20 Mar 2024 20:06:46 +0100 Subject: [PATCH 25/27] Cast DolEditor::Create to string to avoid mistyping as void --- htdocs/core/class/commonobject.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b826ea69205..41a9a69114d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7269,7 +7269,7 @@ abstract class CommonObject if (!preg_match('/search_/', $keyprefix)) { // If keyprefix is search_ or search_options_, we must just use a simple text field require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, false, ROWS_5, '90%'); - $out = $doleditor->Create(1, '', true, '', '', '', $morecss); + $out = (string) $doleditor->Create(1, '', true, '', '', '', $morecss); } else { $out = ''; } @@ -7277,7 +7277,7 @@ abstract class CommonObject if (!preg_match('/search_/', $keyprefix)) { // If keyprefix is search_ or search_options_, we must just use a simple text field require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, isModEnabled('fckeditor') && $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_5, '90%'); - $out = $doleditor->Create(1, '', true, '', '', $moreparam, $morecss); + $out = (string) $doleditor->Create(1, '', true, '', '', $moreparam, $morecss); } else { $out = ''; } From 2496d20d4fe19067463e67fe3a615e52c792d80a Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 20 Mar 2024 23:38:28 +0100 Subject: [PATCH 26/27] Fix nullable return with if($ok == 1) in stead of if($ok) # Fix nullable return with if($ok == 1) in stead of if($ok) This seems to be a bug in Phan where if($ok) changes the type of $ok. Testing with '$ok == 1' instead fixes the issue. This has been reported to the phan team. --- htdocs/core/modules/DolibarrModules.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 850ec739d06..41d2b20efd1 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1126,7 +1126,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @param string $reldir Relative directory where to scan files. Example: '/install/mysql/' or '/module/sql/' * @param string $onlywithsuffix Only with the defined suffix - * @return int Return integer <=0 if KO, >0 if OK + * @return int<0,1> Return integer <=0 if KO, >0 if OK */ protected function _load_tables($reldir, $onlywithsuffix = '') { @@ -1135,6 +1135,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $error = 0; $dirfound = 0; + $ok = 1; if (empty($reldir)) { return 1; @@ -1142,9 +1143,8 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; - $ok = 1; foreach ($conf->file->dol_document_root as $dirroot) { - if ($ok) { + if ($ok == 1) { $dirsql = $dirroot.$reldir; $ok = 0; From ba9a84667225316dee92134d9a5a5178eb8af485 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Mar 2024 12:50:30 +0100 Subject: [PATCH 27/27] Fix trans missing --- dev/translation/dynamic_translation_keys.lst | 1 + 1 file changed, 1 insertion(+) diff --git a/dev/translation/dynamic_translation_keys.lst b/dev/translation/dynamic_translation_keys.lst index 6be815d4eca..47ab2e14a79 100644 --- a/dev/translation/dynamic_translation_keys.lst +++ b/dev/translation/dynamic_translation_keys.lst @@ -40,6 +40,7 @@ Reservation ACCOUNTING_ACCOUNT_CUSTOMER ACCOUNTING_ACCOUNT_CUSTOMER_Desc ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY +ACCOUNTING_ACCOUNT_EXPENSEREPORT ACCOUNTING_ACCOUNT_SUPPLIER ACCOUNTING_ACCOUNT_SUPPLIER_Desc ACCOUNTING_ACCOUNT_SUSPENSE