From e505ebf0f72ccdf236c3ff037121aaa1e01cab07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Fali=C3=A8re?= Date: Wed, 3 Apr 2024 15:03:16 +0200 Subject: [PATCH 1/3] FIX: categories protection limit --- htdocs/categories/class/categorie.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 063207be7d8..1461435ea71 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -11,7 +11,7 @@ * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2016 Charlie Benke * Copyright (C) 2018-2023 Frédéric France - * Copyright (C) 2023 Benjamin Falière + * Copyright (C) 2023-2024 Benjamin Falière * * 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 @@ -1180,6 +1180,8 @@ class Categorie extends CommonObject $resql = $this->db->query($sql); if ($resql) { $i = 0; + $nbcateg = $this->db->num_rows($resql); + while ($obj = $this->db->fetch_object($resql)) { $this->cats[$obj->rowid]['rowid'] = $obj->rowid; $this->cats[$obj->rowid]['id'] = $obj->rowid; @@ -1201,7 +1203,7 @@ class Categorie extends CommonObject dol_syslog(get_class($this)."::get_full_arbo call to buildPathFromId", LOG_DEBUG); foreach ($this->cats as $key => $val) { //print 'key='.$key.'
'."\n"; - $this->buildPathFromId($key, 0); // Process a branch from the root category key (this category has no parent) + $this->buildPathFromId($key, (!empty($nbcateg) ? $nbcateg : 0)); // Process a branch from the root category key (this category has no parent) } // Include or exclude leaf including $markafterid from tree From 2fbe1fe149e42e4ae6c4e3005b46ed0962747070 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 4 Apr 2024 18:55:32 +0200 Subject: [PATCH 2/3] Update categorie.class.php --- htdocs/categories/class/categorie.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 1461435ea71..82dac135fda 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1159,7 +1159,8 @@ class Categorie extends CommonObject } $this->cats = array(); - + $nbcateg = 0; + // Init this->motherof that is array(id_son=>id_parent, ...) $this->load_motherof(); $current_lang = $langs->getDefaultLang(); @@ -1203,7 +1204,7 @@ class Categorie extends CommonObject dol_syslog(get_class($this)."::get_full_arbo call to buildPathFromId", LOG_DEBUG); foreach ($this->cats as $key => $val) { //print 'key='.$key.'
'."\n"; - $this->buildPathFromId($key, (!empty($nbcateg) ? $nbcateg : 0)); // Process a branch from the root category key (this category has no parent) + $this->buildPathFromId($key, $nbcateg); // Process a branch from the root category key (this category has no parent) } // Include or exclude leaf including $markafterid from tree From d32bb1668f8b6d9c8c3951352f868e91d357c469 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 4 Apr 2024 18:58:10 +0200 Subject: [PATCH 3/3] Update categorie.class.php --- htdocs/categories/class/categorie.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 82dac135fda..4430d835df4 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1160,7 +1160,7 @@ class Categorie extends CommonObject $this->cats = array(); $nbcateg = 0; - + // Init this->motherof that is array(id_son=>id_parent, ...) $this->load_motherof(); $current_lang = $langs->getDefaultLang();