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

Lost task time entry when changing assigned task from overview #32791

Open
mdeweerd opened this issue Jan 25, 2025 · 10 comments
Open

Lost task time entry when changing assigned task from overview #32791

mdeweerd opened this issue Jan 25, 2025 · 10 comments
Labels
Bug This is a bug (something does not work as expected)

Comments

@mdeweerd
Copy link
Contributor

Bug

I edited 2 time items spent on tasks on "projet/tasks/time.php" to change their task and they are no longer available in the time spent list (same page).

The following error messages could be related:

apache error.log:

dolibarr[172404]:     33 Functions.lib::dol_print_date function called with a bad value from page /dolibarr/projet/tasks/time.php
dolibarr[172404]:     33 Functions.lib::dol_print_date function called with a bad value from page /dolibarr/projet/tasks/time.php
dolibarr[174936]:     33 Functions.lib::dol_print_date function called with a bad value from page /dolibarr/projet/tasks/time.php
[Sat Jan 25 15:52:21.578945 2025] [php:warn] [pid 174936:tid 174936] [client 192.168.0.254:39636] PHP Warning:  Attempt to read property "thm" on null in /home/www/.../dolibarr20/htdocs/projet/class/task.class.php on line 1510, referer: https://.../projet/tasks/time.php?id=60&action=editline&token=c18e0e02e2c44cdd152a63011bd94608&lineid=560&contextpage=timespentlist&projectid=78&withproject=1&sortfield=t.element_date%2Ct.element_datehour%2Ct.rowid&sortorder=DESC%2CDESC%2CDESC&tab=timespent&page_y=343.4666748046875 
dolibarr[174936]:     33 Functions.lib::dol_print_date function called with a bad value from page /dolibarr/projet/tasks/time.php

I have multiple entires in dolibarr.log that may be related:

2025-01-25 14:52:21 WARNING  174936     33  Functions.lib::dol_print_date function called with a bad value from page /dolibarr/projet/tasks/time.php
2025-01-25 14:52:48 WARNING  174807     33 Project::fetch Bad parameters

I checked the database and found the items in llx_element_time. I notided that "fk_user" was '0' which was not the case for the other items, so I change that back to 1 and the items were listed again.
I also notice that the value for thm is now null while this is not the case for the other items.

Dolibarr Version

20.0.3

Environment PHP

No response

Environment Database

No response

Steps to reproduce the behavior and expected behavior

This happened when I edited an existing entry on projet/tasks/time.php (for a project) and changed the task, then validated ("Enregistrer").

Attached files

No response

@mdeweerd mdeweerd added the Bug This is a bug (something does not work as expected) label Jan 25, 2025
@hregis
Copy link
Contributor

hregis commented Jan 25, 2025

@mdeweerd I can't reproduce the error, the project module is used in conjunction with the "Event Organization" module?
is it possible to have a screenshot of the page before pressing save? thanks

@mdeweerd mdeweerd changed the title Loose task time tracking when changing class from overview Lost task time entry when changing assigned task from overview Jan 25, 2025
@mdeweerd
Copy link
Contributor Author

mdeweerd commented Jan 25, 2025

The Event Organisation module is inactive:
Image

Header:
Image
Line:

Image

@hregis
Copy link
Contributor

hregis commented Jan 25, 2025

@mdeweerd how do you get this?

Image

@hregis
Copy link
Contributor

hregis commented Jan 25, 2025

Image

@hregis
Copy link
Contributor

hregis commented Jan 25, 2025

@mdeweerd ah ok, this is the "salaries" module

@mdeweerd
Copy link
Contributor Author

I'll check how I get that, however, 'obj_thm_user' seems to be null in this code according to the error.log from apache:

                        // Update hourly rate of this time spent entry
                        $resql_thm_user = $this->db->query("SELECT thm FROM " . MAIN_DB_PREFIX . "user WHERE rowid = " . ((int) $timespent->fk_user));
                        if (!empty($resql_thm_user)) {
                                $obj_thm_user = $this->db->fetch_object($resql_thm_user);
                                $timespent->thm = $obj_thm_user->thm;
                        }
                        $res_update = $timespent->update($user);

Is the key to fetch_object correct as this is thm ? Seems to not return a value in my case (not tested)?

@mdeweerd
Copy link
Contributor Author

mdeweerd commented Jan 25, 2025

@mdeweerd how do you get this?

Image

The column before the value is the product column - I can see code for that in time.php .

The html code is (darkreader is inserted by a browser extension):

<td class="nowraponall"><span class="fas fa-concierge-bell" style="color: rgb(166, 153, 68); --darkreader-inline-color: #fffd7a;" data-darkreader-inline-color=""></span><input type="hidden" name="fk_product" id="fk_product" value="0"><!-- Javascript code for autocomplete of field fk_product -->
<script>
XXX;</script><input type="text" class="minwidth100 maxwidth500 ui-autocomplete-input" name="search_fk_product" id="search_fk_product" value="" autocomplete="off"></td>

@hregis
Copy link
Contributor

hregis commented Jan 25, 2025

@mdeweerd and "thm" field are empty in llx_user for the user ?

@mdeweerd
Copy link
Contributor Author

@mdeweerd ah ok, this is the "salaries" module

That's probably linked to how the value is determined. But there is an average daily rate on a user which is likely used and for which the fetch seems to be failing (user/card.php?id=1):

Image

Is there a way to use database transactions in dolibarr? It could help to secure the database in case of fatal errors such as a property or method access on null.

@mdeweerd
Copy link
Contributor Author

Just tried it again, got this:

Image

Before that I added code to do this in a DB transaction: so the entry is not "lost".

mdeweerd added a commit to mdeweerd/dolibarr that referenced this issue Jan 28, 2025
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This is a bug (something does not work as expected)
Projects
None yet
Development

No branches or pull requests

2 participants