Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return true for as_next_scheduled() async actions
The new async psuedo action type uses the NullSchedule to map to a 0000-00-00 00:00:00 date in MySQL and ensure it's always run as soon as possible. However, that meant as_next_scheduled_action() was returning boolean false for the next scheduled timestamp on these, becuase their schedule()->next() value was NULL. We need to return something other than false, because there are pending actions. There were a number of options for this return value: 1. int 0 to represent the absence of a schedule and/or that its scheduled for "the beginning of time" (which is the Unix Epoch in PHP's world). This is risky though, because it will be confused with false via weak comparison operators, so it's likely to create bugs with existing 3rd party code. 2. int 1, to represent a truthy value in int that is still near enough to the beginning of time to communicate the above messages. 3. time() to indicate that the next time any async action should be run is "now" (which is always true for any pending async action because they should be run ASAP). This could cause issues though, if 3rd party code is checking against as_next_scheduled_action() < time(), or for that matter, as_next_scheduled_action() > time(). 4. NULL, to indicate there is a scheduled action (i.e. the return value is not false), but it doesn't have a scheduled timestamp. This return value has the same issue as 0. 5. return boolean true, to indicate there is a scheduled action, but it doesn't have a scheduled timestamp. This seems semantically correct, backward compatible and relatively robust. It will fail against any checks for as_next_scheduled_action() > time() though. I'm not sure if there is anyway around that though.
- Loading branch information