Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug-Fix 31206 -Update ticket.class.php markAsRead function #31207

Closed
wants to merge 1 commit into from

Conversation

cbeasley-sbb
Copy link
Contributor

Fix Issue #31206

Sets the object's "fk_statut" to Ticket::STATUS_READ. In the event of rollback reverts the object's "fk_statut" to its old value.

NOTE: I need this fix to be applied to v18.x if and when approved.

fixes Issue # 31206

Sets the object's  "fk_statut" to Ticket::STATUS_READ.
In the event of rollback reverts the object's "fk_statut" to its old value.
@lvessiller-opendsi
Copy link
Contributor

Thanks for your remarks
Why not only set the status before db commit : (line 1735)

if (!$error) {
        $this->fk_statut = Ticket::STATUS_READ;
	$this->db->commit();
	return 1;
}

@cbeasley-sbb
Copy link
Contributor Author

cbeasley-sbb commented Oct 3, 2024

Thanks for your remarks Why not only set the status before db commit : (line 1735)

if (!$error) {
        $this->fk_statut = Ticket::STATUS_READ;
	$this->db->commit();
	return 1;
}

That could work. However, in other trigger situations the primary transaction for the event has already been executed but not committed. This way is more consistent with that pattern. With the approach you suggest $object->old_copy will be identical to the object that has supposedly changed during trigger function execution(s).

  1. change executed
  2. run_triggers called
  3. Trigger functions evaluate the transition with custom logic; Presumably deltas can be identified by comparing $object->X to $object->old_copy->X
  4. main function commits the changes if no errors.

@eldy
Copy link
Member

eldy commented Oct 3, 2024

A fix was pushed into v18. When merging to higher branch, upstream code was modified to use the ->oldcopy instead of $oldStatus var.
16ab86a

@lvessiller-opendsi "Why not only set the status before db commit : (line 1735)"
The set is not required just before the commit because we must do it (the set of values) at begin to have all the new value loaded into the object for the manipulation that will come later (update, trigger, ...)
So setting at end in case of commit should be useless, however, we must revert value in case of rollback using the old value defined into ->oldcopy.

@eldy eldy closed this Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants