schedules task error

Status
Not open for further replies.

wezetel

Active Member
Tried to create a scheduled task (with cron-php).
Beside the never stopping spinner beside the list selection, the main problem is, that I can't save the task:
Save failed with the following error: Field 'created' doesn't have a default value
 
Oh...
As a workaround you can set #_fabrik_cron.created default to current timestamp (or allow NULL) directly in the DB.
Spinner below list - yes... (it doesn't hurt).
 
strange enough: one of my three testsites already had a default set in the DB...probably because I don't update all three at the same time
 
Maybe from some former beta or so. There have been several tests with null dates, updates from old sites, different DB versions etc.
Can you try:
Reset the created column to no default, not null (the J! standard for created)
Modifiy function save($data) in \administrator\components\com_fabrik\models\cron.php line 142ff (adding the missing created and modified params)
Code:
    public function save($data)
    {
        $date = Factory::getDate();
     
        if (FArrayHelper::getValue($data, 'lastrun') == '')
        {
            $data['lastrun'] = $date->toSql();
        }
        else
        {
            $timeZone = new \DateTimeZone($this->config->get('offset'));
            $data['lastrun']     = Factory::getDate($data['lastrun'], $timeZone)->toSql(false);
        }

        //New record
        if (empty($data['id']) )
        {
            $data['created']    = $date->toSql();
            $data['created_by']    = $this->user->get('id');
            $data['created_by_alias'] =  $this->user->get('username');

        }
        $data['params']        = json_encode($data['params']);
        $data['modified']    = $date->toSql();
        $data['modified_by']    = $this->user->get('id');

        return parent::save($data);
    }
 
What I've done
  • reset the default of created to None in the DB
  • tried to create a task (to be sure) -> failed
  • applied your code change
  • tried to create a task -> success
Your code is working -- GREAT
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top