diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 26293ecc5f5..8250671598f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -7467,7 +7467,7 @@ function get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart = ' // In a future, we may distribute directories on several levels depending on setup and object. // Here, $object->id, $object->ref and $modulepart are required. //var_dump($modulepart); - $path = dol_sanitizeFileName(empty($object->ref) ? (string) (property_exists($object, 'id') ? $object->id : '') : $object->ref); + $path = dol_sanitizeFileName(empty($object->ref) ? (string) ((is_object($object) && property_exists($object, 'id')) ? $object->id : '') : $object->ref); } if (empty($withoutslash) && !empty($path)) {