Fix #10453 - Workflow fails when action used business hours to calculate date when running via cron #10454
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Use fixUpFormatting to correct date formats back to DB format so that fromDB is passed a date in DB format:
$value = $businessHours->addBusinessHours($amount, $timedate->fromDb($bean->$dateToUse))
Description
Use fix up formatting to set dates to db format, if not set and running from cron then a 500 is thrown:
[16-Jun-2024 15:12:15 UTC] PHP Fatal error: Uncaught TypeError: AOBH_BusinessHours::addBusinessHours(): Argument #2 ($date) must be of type ?DateTime, bool given, called in /var/www/SuiteCRMCorePR/modules/AOW_Actions/actions/actionCreateRecord.php on line 279 and defined in /var/www/SuiteCRMCorePR/modules/AOBH_BusinessHours/AOBH_BusinessHours.php:185
Stack trace:
#0 /var/www/SuiteCRMCorePR/modules/AOW_Actions/actions/actionCreateRecord.php(279): AOBH_BusinessHours->addBusinessHours()
#1 /var/www/SuiteCRMCorePR/modules/AOW_Actions/actions/actionCreateRecord.php(170): actionCreateRecord->set_record()
#2 /var/www/SuiteCRMCorePR/modules/AOW_WorkFlow/AOW_WorkFlow.php(1046): actionCreateRecord->run_action()
#3 /var/www/SuiteCRMCorePR/modules/AOW_WorkFlow/AOW_WorkFlow.php(214): AOW_WorkFlow->run_actions()
#4 /var/www/SuiteCRMCorePR/modules/AOW_WorkFlow/AOW_WorkFlow.php(198): AOW_WorkFlow->run_flow()
#5 /var/www/SuiteCRMCorePR/modules/Schedulers/_AddJobsHere.php(836): AOW_WorkFlow->run_flows()
#6 /var/www/SuiteCRMCorePR/modules/SchedulersJobs/SchedulersJob.php(529): processAOW_Workflow()
#7 /var/www/SuiteCRMCorePR/include/SugarQueue/SugarCronJobs.php(191): SchedulersJob->runJob()
#8 /var/www/SuiteCRMCorePR/include/SugarQueue/SugarCronJobs.php(233): SugarCronJobs->executeJob()
#9 /var/www/SuiteCRMCorePR/cron.php(100): SugarCronJobs->runCycle()
#10 {main}
thrown in /var/www/SuiteCRMCorePR/modules/AOBH_BusinessHours/AOBH_BusinessHours.php on line 185
Motivation and Context
How To Test This
Types of changes
Final checklist