diff --git a/htdocs/categories/categorie.class.php b/htdocs/categories/categorie.class.php index a0c9afb2055..2a5c65a57ed 100644 --- a/htdocs/categories/categorie.class.php +++ b/htdocs/categories/categorie.class.php @@ -533,7 +533,7 @@ class Categorie return -1; } - // Charge tableau des categories + // Init $this->cats array $sql = "SELECT c.rowid, c.label as label, ca.fk_categorie_fille as rowid_fille"; $sql.= " FROM ".MAIN_DB_PREFIX."categorie as c"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_association as ca"; @@ -570,7 +570,7 @@ class Categorie dolibarr_syslog("Categorie::get_full_arbo call to build_path_from_id_categ", LOG_DEBUG); foreach($this->cats as $key => $val) { - if (isset($motherof[$key])) continue; + if (isset($this->motherof[$key])) continue; $this->build_path_from_id_categ($key,0); // Process a path of a root category (no parent exists) } @@ -591,12 +591,12 @@ class Categorie { dolibarr_syslog("Categorie::build_path_from_id_categ id_categ=".$id_categ." protection=".$protection, LOG_DEBUG); - if (! empty($this->cats[$id_categ]['fullpath'])) - { + //if (! empty($this->cats[$id_categ]['fullpath'])) + //{ // Already defined - dolibarr_syslog("Categorie::build_path_from_id_categ fullpath and fulllabel already defined", LOG_WARNING); - return; - } + // dolibarr_syslog("Categorie::build_path_from_id_categ fullpath and fulllabel already defined", LOG_WARNING); + // return; + //} // Define fullpath and fulllabel if (isset($this->cats[$id_categ]['id_mere'])) @@ -616,7 +616,7 @@ class Categorie // Process all childs on several levels of this category $protection++; - if ($protection > 20) return; // On ne traite pas plus de 20 niveaux + if ($protection > 10) return; // On ne traite pas plus de 10 niveaux de profondeurs if (! is_array($this->cats[$id_categ]['id_children'])) return; foreach($this->cats[$id_categ]['id_children'] as $key => $idchild) { diff --git a/mysql/migration/2.5.0-2.6.0.sql b/mysql/migration/2.5.0-2.6.0.sql index 2864bf41313..b2462ded8b5 100644 --- a/mysql/migration/2.5.0-2.6.0.sql +++ b/mysql/migration/2.5.0-2.6.0.sql @@ -63,4 +63,6 @@ delete from llx_categorie_association where fk_categorie_mere = fk_categorie_fil -- Put at the end. Cas have duplicate values +ALTER TABLE llx_categorie_association drop index idx_categorie_association_fk_categorie_fille ALTER TABLE llx_categorie_association ADD UNIQUE INDEX uk_categorie_association (fk_categorie_mere, fk_categorie_fille); +ALTER TABLE llx_categorie_association ADD UNIQUE INDEX uk_categorie_association_fk_categorie_fille (fk_categorie_fille); diff --git a/mysql/tables/llx_categorie_association.key.sql b/mysql/tables/llx_categorie_association.key.sql index 0a4d78a440c..46a39b3c9e7 100644 --- a/mysql/tables/llx_categorie_association.key.sql +++ b/mysql/tables/llx_categorie_association.key.sql @@ -21,10 +21,8 @@ -- ============================================================================ -ALTER TABLE llx_categorie_association ADD INDEX idx_categorie_association_fk_categorie_mere (fk_categorie_mere); -ALTER TABLE llx_categorie_association ADD INDEX idx_categorie_association_fk_categorie_fille (fk_categorie_fille); - ALTER TABLE llx_categorie_association ADD UNIQUE INDEX uk_categorie_association (fk_categorie_mere, fk_categorie_fille); +ALTER TABLE llx_categorie_association ADD UNIQUE INDEX uk_categorie_association_fk_categorie_fille (fk_categorie_fille); ALTER TABLE llx_categorie_association ADD CONSTRAINT fk_categorie_asso_fk_categorie_mere FOREIGN KEY (fk_categorie_mere) REFERENCES llx_categorie (rowid); ALTER TABLE llx_categorie_association ADD CONSTRAINT fk_categorie_asso_fk_categorie_fille FOREIGN KEY (fk_categorie_fille) REFERENCES llx_categorie (rowid);