forked from Wavyzz/dolibarr
clean code (#35683)
* clean code * clean code * clean code --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
@@ -907,19 +907,18 @@ class Documents extends DolibarrApi
|
||||
throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.');
|
||||
}
|
||||
|
||||
if (is_object($object)) {
|
||||
if ($fetchbyid) {
|
||||
// @phan-suppress-next-line PhanPluginSuspiciousParamPosition
|
||||
$result = $object->fetch((int) $ref);
|
||||
} else {
|
||||
$result = $object->fetch(0, $ref);
|
||||
}
|
||||
// at this step $object is always an object
|
||||
if ($fetchbyid) {
|
||||
// @phan-suppress-next-line PhanPluginSuspiciousParamPosition
|
||||
$result = $object->fetch((int) $ref);
|
||||
} else {
|
||||
$result = $object->fetch(0, $ref);
|
||||
}
|
||||
|
||||
if ($result == 0) {
|
||||
throw new RestException(404, "Object with ref '".$ref."' was not found.");
|
||||
} elseif ($result < 0) {
|
||||
throw new RestException(500, 'Error while fetching object: '.$object->error);
|
||||
}
|
||||
if ($result == 0) {
|
||||
throw new RestException(404, "Object with ref '".$ref."' was not found.");
|
||||
} elseif ($result < 0) {
|
||||
throw new RestException(500, 'Error while fetching object: '.$object->error);
|
||||
}
|
||||
|
||||
if (!($object->id > 0)) {
|
||||
@@ -1056,7 +1055,8 @@ class Documents extends DolibarrApi
|
||||
}
|
||||
|
||||
$moreinfo = array('note_private' => 'File uploaded using API /documents from IP '.getUserRemoteIP());
|
||||
if (!empty($object) && is_object($object) && $object->id > 0) {
|
||||
// $object may be null
|
||||
if (is_object($object) && $object->id > 0) {
|
||||
$moreinfo['src_object_type'] = $object->table_element;
|
||||
$moreinfo['src_object_id'] = $object->id;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user