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

FIX #32791 Lost user and THM when updating task time #32822

Draft
wants to merge 1 commit into
base: 20.0
Choose a base branch
from

Conversation

mdeweerd
Copy link
Contributor

FIX #32791 Lost user and THM when updating task time

The task time was assigned the user '0' when updating, which resulted in an error where a NULL object was used.
This resulted in a partially replaced record with no user and empty THM.

The correction adds the use of a DB transaction to avoid inconsistency in case of an error.
The correction uses the fields from the original record if no new fields are provided in the POST arguments

# FIX Dolibarr#32791 Lost user and THM when updating task time

The task time was assigned the user '0' when updating, which resulted in an
error where a NULL object was used.
This resulted in a partially replaced record with no user and empty THM.

The correction adds the use of a DB transaction to avoid inconsistency in case
of an error.
The correction uses the fields from the original record if no new fields
are provided in the POST arguments
@mdeweerd mdeweerd marked this pull request as ready for review January 28, 2025 00:49
@hregis
Copy link
Contributor

hregis commented Jan 28, 2025

@mdeweerd GETPOSTINT return 0 if the value is null, you can use GETPOST(xxxx, 'int') instead

@mdeweerd
Copy link
Contributor Author

@mdeweerd GETPOSTINT return 0 if the value is null, you can use GETPOST(xxxx, 'int') instead

The code first validates that the value is provided and not '' before using the int value.
I normally would use intermediate variables to get the POST value and then reuse that, but that's not the method used in dolibarr. In that case, $val = GETPOST(xxx, 'int'); if($val!=='') {$otherval=(int)$val;}

Anyway, this code works for me: I can update a line. I also tested on a line that I fixed in the DB without updating the cost value (which was 0) and the cost was updated to the correct value when I saved the line (without any modifications made).

@mdeweerd mdeweerd marked this pull request as draft January 28, 2025 17:54
@mdeweerd
Copy link
Contributor Author

Draft again, some cases are not ok.

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.

2 participants