-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 When updating task details, keep original fields when they are not shown in the task table #32822
base: 20.0
Are you sure you want to change the base?
Conversation
@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 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). |
Draft again, some cases are not ok. |
I fixed the one affecting me. Commented the patch, but I am sure there is a better solution :-)
For me this fix works for my problem. |
Did you check if the task in the table still has the user after the change? The patch changes the documented functionnality of the method - it doe nos longer filter on a specific third party if the third party that is examined is the same as the one of the user. |
As I wrote I commented the patch and I am sure there are better solutions. My problem was:
Currently some users added times and it looks good. The function by itself, as I understood, only return projects the user has rights too as string or array? |
In the latest code this was added versus 19.0.2, so maybe that is your reason or your fix: htdocs/projet/tasks/time.php if (!$user->hasRight('projet', 'all', 'lire')) {
// Get list of project id allowed to user (in a string list separated by comma)
// TODO This may generate performance trouble when list of project is very large. Solution can be
o complete $filterproj with filters on project.
$filterproj = '';
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $user->socid > 0 ? $user->socid : , $filterproj);
$sql .= " AND p.rowid IN (".$db->sanitize($projectsListId).")"; // public and assigned to, or restricted to company for external users
} |
That code was my start investigating. $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $user->socid > 0 ? $user->socid : , $filterproj); returns an empty value in my case, because sql2 query from the getProjectsAuthorizedForUser in my case is an empty result. at least since 20.0.3 socid in the function is the socid of the business partner socid of the business partner the user is linked too and not the socid of the project/task itself. |
I assume the solution would be to address the "socid named here:
as PROJECT->socid here. I assume $socid is filled wrong in 20.x.x. |
My interpretation of the code in time.php is that this restriction is added only if the user does not have the right to see all projets and so the projects are restricted to his socid. So in this case the question is what rule allows the user access to the project + what the reason is to show the project on this page. Apparently this restristion was introduced in #30362 . |
I think this code does make the entry/ies available to internal users if the project is linked to a 3rd party business partner: // Internal users must see project he is contact to even if project linked to a third party he can't see. But I think since 20.x somewhere else $socid if filled with the id of the businesspartner the logged in user is linked too and not with the socid where the project is linked too. But I have not found where $socid without any $something->socid is set. |
@vsatmydynipnet You should never say that your solution is the best solution or the only solution because you don't have a global vision of all the interactions! You see what you see because that's what you want to see... |
@hregis where I said my code is the best solution? I wrote: I was happy to fix my problem, but I am sure, somebody with deeper knowledge shoulld look into this one and fix the $socid change finally. |
@vsatmydynipnet ah ? sorry i don't understand your words !
|
# 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
Putting into draft again, there still is a case where there is an issue. |
The other issue occured when I tried to update the start time. I think I had already seen this before. The fix is to update both the timespent_date and timespent_datehour fields. It's unclear why we need both AND the timespent_withhour. I also added the taskid (fk_element) for editline to allow verifying it was update. As it was not provided it was always deleting the entry first, so now it updates the entry. Assigning it to 'id' limits the list of time spent to the task after the update. |
There is still suspicious change like addition of the old_taskid param when we should have it when we retreive the timespent to edit. |
& Pb 2) Hiding some columns generate lose of data hidden if we edit line ? The initial problem occurs when I remove the user column from the timespent view. In this case the user is not part of the POST submission. Pb 3) Timespend delete/add in stead of update. In the code there is a test to check if the task to which the timespent entry is attached has changed or not. If that is the case, then there was a delete/add, if not an update; When I added the original task id as a "POST id" value, then after the update this resulted in a view specific to the task, and not all the tasks of the project. So I added old_task_id instead to return to the expected view after the update. Pb 4) When changing the hour/time of a timespent entry, this was not taken into account. |
FIX #32791 When updating task details, keep original fields when they are not shown in the task table
This fixes lost user and THM when updating task time, and other lost fields.
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