Skip to content

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

Closed
@austin92jus

Description

@austin92jus

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions