Skip to content
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

TaskLog expects a string to be set as an output, but Events::trigger() returns bool #179

Open
austin92jus opened this issue Oct 26, 2024 · 1 comment

Comments

@austin92jus
Copy link

I have write the events with schedule to run every hour But it throw error
TypeError: Cannot assign true to property CodeIgniter\Tasks\TaskLog::$output of type ?string
public static function sent_unqueue_mail()
{
$repo = new SQLEmail_listRepository();
$data = $repo->getUnQueueJobs();
$totalJob = 0;
if (is_array($data) && count($data)) {
$eLib = new \Mail\Libraries\Email();
foreach ($data as $k => $v) {
try {
$eLib->send($v);
$totalJob++;
} catch (\Exception $e) {
log_message('error', "Failed to send email for job $k: " . $e->getMessage());
}
}
}
log_message('info', "Sent Unqueue Completed $totalJob");
return ["Sent Unqueue Completed"];
}
I assigned events
Events::on('sent_unqueue_mail', '\Mail\Events\EventsMail::sent_unqueue_mail');
please help me to resolve this issues

@ddevsr
Copy link
Contributor

ddevsr commented Oct 28, 2024

Return Event::trigger() is boolean, but TaskLog strict to string|null in output. I confirm this bug

https://github.com/codeigniter4/tasks/blob/develop/src/Task.php#L250

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants