Skip to content

Attempt to read property "id" on null in JobController::actionPush() #31

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

Open
xcopy opened this issue Dec 3, 2024 · 0 comments
Open

Comments

@xcopy
Copy link

xcopy commented Dec 3, 2024

$uid = $record->getSender()->push($record->createJob());
$newRecord = PushRecord::find()->byJob($record->sender_name, $uid)->one();
return $this
->success(Module::t('notice', 'The job is pushed again.'))
->redirect(['view', 'id' => $newRecord->id]);

The $uid variable will be null in case if beforePush event has been handled (i.e. $event->handled set to true in the particular behavior).

Here is the proposed solution:

if ($uid = $record->getSender()->push($record->createJob())) {
    $newRecord = PushRecord::find()->byJob($record->sender_name, $uid)->one();

    $this->success(Module::t('notice', 'The job is pushed again.'));
    $id = $newRecord->id;
} else {
    $this->error(Module::t('notice', 'The job cannot be pushed again because the "beforePush" event has already been handled.'));
    $id = $record->id;
}

return $this->redirect(['view', 'id' => $id]);

Not sure about the error message.

What you say guys?

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

1 participant