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

Closed
austin92jus opened this issue Oct 26, 2024 · 2 comments · Fixed by #182
Closed
Labels
bug Something isn't working

Comments

@austin92jus
Copy link

austin92jus commented Oct 26, 2024

I have written 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

@michalsn michalsn added the bug Something isn't working label Jan 18, 2025
@michalsn
Copy link
Member

You may check #182

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants