FIX To avoid sending an empty object to doActions

This commit is contained in:
Clément 2024-12-10 00:16:02 +01:00 committed by GitHub
parent 78ece8355f
commit 2c58bcc0b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -93,6 +93,17 @@ if (!$user->hasRight('projet', 'lire')) {
* Actions
*/
$object = new Project($db);
if ($id > 0 || !empty($ref)) {
$object->fetch($id, $ref);
$object->fetch_thirdparty();
if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($object, 'fetchComments') && empty($object->comments)) {
$object->fetchComments();
}
$object->info($object->id);
}
$parameters = array('id' => $socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
@ -112,16 +123,6 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
*/
$form = new Form($db);
$object = new Project($db);
if ($id > 0 || !empty($ref)) {
$object->fetch($id, $ref);
$object->fetch_thirdparty();
if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($object, 'fetchComments') && empty($object->comments)) {
$object->fetchComments();
}
$object->info($object->id);
}
$agenda = (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) ? '/'.$langs->trans("Agenda") : '';
$title = $langs->trans('Events').$agenda.' - '.$object->ref.' '.$object->name;
if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/projectnameonly/', getDolGlobalString('MAIN_HTML_TITLE')) && $object->name) {