Igalia/phpreport

Error 500 when creating new task ending at 00:00 if start time is set later

Loirooriol opened this issue · 3 comments

  1. Go to a day with no task, or click to add a new task, so that all the fields are empty
  2. Set the end time to 00:00
  3. Set the start time, e.g. 23:00
  4. Choose some project
  5. Save

Expected: it works.
Actual: "Some Error Occurred While Saving The Changes (please check you haven't clipped working hours)".

The server is producing an error 500. I think it's because

if (($endTimeParse['hour']==0) && ($endTimeParse['minute']==0) && ($initTime != 0)) {

where $initTime is an undefined variable. Maybe set $initTime = NAN at the top, or check isset($initTime).

The user input is parsed in the order in which a user entered it, so it is true that $initTime is not set yet at this point in the code when an end time is set first. We are checking for init time in this line in order to facilitate the addition of 0-hour tasks, but I will move some code outside of the switch statement to do this check. It seems best to avoid any block in the switch statement relying on any of the variables in other blocks since they could come in any order.

Good catch, thanks!

Fixed with:

commit 1dda98ef7c534e0d04bc6f147a0959e1006874b3
Author: Danielle M <danielle@igalia.com>
Date:   Wed Feb 8 10:48:13 2023 -0800

    611 midnight task error (#612)
    
    * Move handling for 0-hour tasks outside switch in createTasksService and add same handling in updateTasksService