Workflow crontask exception in when calling ValueError: DOMDocument::loadHTML() with empty argument
I'm getting this Exception when my workflows execute:
PHP Fatal error: Uncaught ValueError: DOMDocument::loadHTML(): Argument #1 ($source) must not be empty in /var/www/html/vt/modules/Emails/models/Mailer.php:112
Stack trace:
#0 /var/www/html/vt/modules/Emails/models/Mailer.php(112): DOMDocument->loadHTML()
#1 /var/www/html/vt/modules/com_vtiger_workflow/tasks/VTEmailTask.inc(63): Emails_Mailer_Model->convertToValidURL()
#2 /var/www/html/vt/cron/modules/com_vtiger_workflow/com_vtiger_workflow.service(65): VTEmailTask->doTask()
#3 /var/www/html/vt/cron/modules/com_vtiger_workflow/com_vtiger_workflow.service(72): vtRunTaskJob()
#4 /var/www/html/vt/vtigercron.php(86): require_once('/var/www/html/v...')
#5 {main}
thrown in /var/www/html/vt/modules/Emails/models/Mailer.php on line 112
This is the relevant function:
Documentation for DOMDocument::loadHTML()
: https://www.php.net/manual/en/domdocument.loadhtml.php
I believe that by adding this at the very befinning of the function, should fix it:
if (empty($htmlContent)) {
return '';
}
Not sure yet if the an error would pop up if the caller doesn't get back a url, as the error hasn't come up again.