From 3b8331de7f51d31f7f27f8aa7b6179b1fa74b71d Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 15 Apr 2026 21:03:26 +0200 Subject: [PATCH 1/4] FIX wrong "REFERENCES" for foreign key of fk_project_task (report this fix in 23 to 24) (#37874) * FIX wrong foreign key for project task (report this fix in 23 to 24) * FIX drop foreign key before drop index * FIX missing install sql file --- htdocs/install/mysql/migration/22.0.0-23.0.0.sql | 8 ++++++-- .../tables/llx_categorie_project_task-project.key.sql | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/install/mysql/migration/22.0.0-23.0.0.sql b/htdocs/install/mysql/migration/22.0.0-23.0.0.sql index f1e29481df6..c8f9e2b17df 100644 --- a/htdocs/install/mysql/migration/22.0.0-23.0.0.sql +++ b/htdocs/install/mysql/migration/22.0.0-23.0.0.sql @@ -54,10 +54,14 @@ create table llx_categorie_project_task ( ALTER TABLE llx_categorie_project_task ADD PRIMARY KEY pk_categorie_propal (fk_categorie, fk_project_task); --noqa:enable=PRS ALTER TABLE llx_categorie_project_task ADD INDEX idx_categorie_project_fk_categorie (fk_categorie); -ALTER TABLE llx_categorie_project_task ADD INDEX idx_categorie_project_fk_task (fk_project_task); ALTER TABLE llx_categorie_project_task ADD CONSTRAINT fk_categorie_project_task_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid); -ALTER TABLE llx_categorie_project_task ADD CONSTRAINT fk_categorie_project_task_rowid FOREIGN KEY (fk_project_task) REFERENCES llx_projet (rowid); +ALTER TABLE llx_categorie_project_task DROP FOREIGN KEY fk_categorie_project_task_rowid; +-- VMYSQL4.1 DROP INDEX idx_categorie_project_fk_task ON llx_categorie_project_task; +-- VPGSQL8.2 DROP INDEX idx_categorie_project_fk_task; +ALTER TABLE llx_categorie_project_task ADD INDEX idx_categorie_project_fk_task (fk_project_task); +ALTER TABLE llx_categorie_project_task ADD CONSTRAINT fk_categorie_project_task_rowid FOREIGN KEY (fk_project_task) REFERENCES llx_projet_task (rowid); + UPDATE llx_actioncomm SET elementtype = 'project_task' WHERE elementtype = 'task'; diff --git a/htdocs/install/mysql/tables/llx_categorie_project_task-project.key.sql b/htdocs/install/mysql/tables/llx_categorie_project_task-project.key.sql index 44712571a8d..1bf2e33f53d 100644 --- a/htdocs/install/mysql/tables/llx_categorie_project_task-project.key.sql +++ b/htdocs/install/mysql/tables/llx_categorie_project_task-project.key.sql @@ -22,4 +22,4 @@ ALTER TABLE llx_categorie_project_task ADD INDEX idx_categorie_project_fk_catego ALTER TABLE llx_categorie_project_task ADD INDEX idx_categorie_project_fk_task (fk_project_task); ALTER TABLE llx_categorie_project_task ADD CONSTRAINT fk_categorie_project_task_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid); -ALTER TABLE llx_categorie_project_task ADD CONSTRAINT fk_categorie_project_task_rowid FOREIGN KEY (fk_project_task) REFERENCES llx_projet (rowid); +ALTER TABLE llx_categorie_project_task ADD CONSTRAINT fk_categorie_project_task_rowid FOREIGN KEY (fk_project_task) REFERENCES llx_projet_task (rowid); From 284190cc10e8005a2234890fda5abb7076d6b7bd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Apr 2026 13:15:19 +0200 Subject: [PATCH 2/4] Fix select default value missing --- htdocs/public/members/new.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 174c4db8f88..8cca1d81aad 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -806,6 +806,7 @@ if (getDolGlobalString('MEMBER_SKIP_TABLE') || getDolGlobalString('MEMBER_NEWFOR $morInput.prop({disabled: true, checked: false}); */ $span1.addClass("member-individual-back").removeClass("nonature-back"); $span2.removeClass("member-company-back").addClass("nonature-back"); + $("#phisicalinput").prop("checked", true); $tdLast.addClass("fieldrequired"); $tdFirst.addClass("fieldrequired"); $tdCompany.removeClass("fieldrequired"); @@ -816,6 +817,7 @@ if (getDolGlobalString('MEMBER_SKIP_TABLE') || getDolGlobalString('MEMBER_NEWFOR $morInput.prop({disabled: false, checked: true}); */ $span2.addClass("member-company-back").removeClass("nonature-back"); $span1.removeClass("member-individual-back").addClass("nonature-back"); + $("#moralinput").prop("checked", true); $tdCompany.addClass("fieldrequired"); $tdLast.removeClass("fieldrequired"); $tdFirst.removeClass("fieldrequired"); From 616fe3efe320aa29eb58acc39e06588261b65e6c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Apr 2026 15:19:40 +0200 Subject: [PATCH 3/4] Fix regression on some php versions --- htdocs/core/lib/pdf.lib.php | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 04b4960a6c6..443e82e6c96 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -88,7 +88,7 @@ function pdf_getFormat($outputlangs = null, $mode = 'setup') { global $conf, $db, $langs; - dol_syslog("pdf_getFormat Get paper format with mode=".$mode." MAIN_PDF_FORMAT=".(!getDolGlobalString('MAIN_PDF_FORMAT') ? 'null' : $conf->global->MAIN_PDF_FORMAT)." outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null')." and langs->defaultlang=".(is_object($langs) ? $langs->defaultlang : 'null')); + dol_syslog("pdf_getFormat Get paper format with mode=".$mode." MAIN_PDF_FORMAT=".getDolGlobalString('MAIN_PDF_FORMAT')." outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null')." and langs->defaultlang=".(is_object($langs) ? $langs->defaultlang : 'null')); // Default value if setup was not done and/or entry into c_paper_format not defined $width = 210; @@ -242,7 +242,9 @@ function pdf_getEncryption($pathoffile) //ob_start(); @($parser = new TCPDF_PARSER(ltrim($content))); - [$xref, $data] = $parser->getParsedData(); + $tmp = $parser->getParsedData(); + $xref = $tmp[0]; + $data = $tmp[1] ?? null; unset($parser); //ob_end_clean(); @@ -265,10 +267,8 @@ function pdf_getEncryption($pathoffile) */ function pdf_getPDFFont($outputlangs) { - global $conf; - if (getDolGlobalString('MAIN_PDF_FORCE_FONT')) { - return $conf->global->MAIN_PDF_FORCE_FONT; + return getDolGlobalString('MAIN_PDF_FORCE_FONT'); } $font = 'Helvetica'; // By default, for FPDI, or ISO language on TCPDF @@ -311,8 +311,7 @@ function pdf_getPDFFontSize($outputlangs) */ function pdf_getHeightForLogo($logo, $url = false) { - global $conf; - $height = (!getDolGlobalString('MAIN_DOCUMENTS_LOGO_HEIGHT') ? 20 : $conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT); + $height = getDolGlobalInt('MAIN_DOCUMENTS_LOGO_HEIGHT', 20); $maxwidth = 130; include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; $tmp = dol_getImageSize($logo, $url); @@ -1296,7 +1295,10 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $pdf->SetDrawColor(224, 224, 224); // Option for footer text color if (getDolGlobalString('PDF_FOOTER_TEXT_COLOR')) { - [$r, $g, $b] = sscanf(getDolGlobalString('PDF_FOOTER_TEXT_COLOR'), '%d, %d, %d'); + $tmparray = sscanf(getDolGlobalString('PDF_FOOTER_TEXT_COLOR'), '%d, %d, %d'); + $r = $tmparray[0]; + $g = $tmparray[1]; + $b = $tmparray[2]; $pdf->SetTextColor($r, $g, $b); } @@ -1334,7 +1336,10 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ // Option for footer background color (without freetext zone) if (getDolGlobalString('PDF_FOOTER_BACKGROUND_COLOR')) { - [$r, $g, $b] = sscanf($conf->global->PDF_FOOTER_BACKGROUND_COLOR, '%d, %d, %d'); + $tmparray = sscanf(getDolGlobalString('PDF_FOOTER_BACKGROUND_COLOR'), '%d, %d, %d'); + $r = $tmparray[0]; + $g = $tmparray[1]; + $b = $tmparray[2]; $pdf->setAutoPageBreak(false, 0); // Disable auto pagebreak $pdf->Rect(0, $dims['hk'] - $posy + $freetextheight, $dims['wk'] + 1, $marginwithfooter + 1, 'F', array(), $fill_color = array($r, $g, $b)); $pdf->setAutoPageBreak(true, 0); // Restore pagebreak @@ -1386,7 +1391,10 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ // Option for footer background color (without freetext zone) if (getDolGlobalString('PDF_FOOTER_BACKGROUND_COLOR')) { - [$r, $g, $b] = sscanf($conf->global->PDF_FOOTER_BACKGROUND_COLOR, '%d, %d, %d'); + $tmparray = sscanf(getDolGlobalString('PDF_FOOTER_BACKGROUND_COLOR'), '%d, %d, %d'); + $r = $tmparray[0]; + $g = $tmparray[1]; + $b = $tmparray[2]; $pdf->setAutoPageBreak(false, 0); // Disable auto pagebreak $pdf->Rect(0, $dims['hk'] - $posy + $freetextheight, $dims['wk'] + 1, $marginwithfooter + 1, 'F', array(), $fill_color = array($r, $g, $b)); $pdf->setAutoPageBreak(true, 0); // Restore pagebreak @@ -1844,7 +1852,8 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, } if (isset($productCustomerPrice) && !empty($productCustomerPrice->ref_customer)) { - switch ($conf->global->PRODUIT_CUSTOMER_PRICES_PDF_REF_MODE) { + $idcustprice = getDolGlobalInt('PRODUIT_CUSTOMER_PRICES_PDF_REF_MODE'); + switch ($idcustprice) { case 1: $ref_prodserv = $productCustomerPrice->ref_customer; break; From 1abd3d001c1290b94c1aadccb798e76b7d2e226a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 17 Apr 2026 02:18:43 +0200 Subject: [PATCH 4/4] Fix IDOR - Can read ticket even if assigned to another sale representative - Credit by Nguy Minh Tuan - Sun Asterisk --- htdocs/core/lib/security.lib.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index d66feae5592..2e89de5a733 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -1204,10 +1204,10 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl $sql .= " AND dbt.".$dbt_keyfield." = ".((int) $user->socid); } elseif (isModEnabled("societe") && !$user->hasRight('societe', 'client', 'voir')) { // If internal user without permission to see all thirdparties: Check permission for internal users that are restricted on their objects + if (empty($dbt_keyfield)) { + dol_print_error(null, 'Param dbt_keyfield is required but not defined'); + } if ($feature != 'ticket') { - if (empty($dbt_keyfield)) { - dol_print_error(null, 'Param dbt_keyfield is required but not defined'); - } $sql = "SELECT COUNT(sc.fk_soc) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -1227,7 +1227,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = dbt.".$dbt_keyfield." AND sc.fk_user = ".((int) $user->id); $sql .= " WHERE dbt.".$dbt_select." IN (".$db->sanitize($objectid, 1).")"; $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; - $sql .= " AND (sc.fk_user = ".((int) $user->id)." OR sc.fk_user IS NULL)"; + $sql .= " AND (sc.fk_user = ".((int) $user->id)." OR dbt.".$dbt_keyfield." IS NULL OR dbt.".$dbt_keyfield." = 0)"; } } elseif (isModEnabled('multicompany')) { // If multicompany, and user is an internal user with all permissions, check that object is in correct entity