diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php
index 7a449f3e7ea..6e4f6892e05 100644
--- a/htdocs/core/class/extrafields.class.php
+++ b/htdocs/core/class/extrafields.class.php
@@ -1766,15 +1766,18 @@ class ExtraFields
}
}
} else {
- require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
-
$toprint = array();
$obj = $this->db->fetch_object($resql);
- $c = new Categorie($this->db);
- $c->fetch($obj->rowid);
- $ways = $c->print_all_ways(); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text
- foreach ($ways as $way) {
- $toprint[] = '
color ? ' style="background: #'.$c->color.';"' : ' style="background: #bbb"').'>'.img_object('', 'category').' '.$way.'';
+ if ($obj->rowid) {
+ require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
+ $c = new Categorie($this->db);
+ $result = $c->fetch($obj->rowid);
+ if ($result > 0) {
+ $ways = $c->print_all_ways(); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text
+ foreach ($ways as $way) {
+ $toprint[] = 'color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . img_object('', 'category') . ' ' . $way . '';
+ }
+ }
}
$value = ''.implode(' ', $toprint).'
';
}