Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Commit

Permalink
fix(Upload): Fix Upload Torrent can't save in database
Browse files Browse the repository at this point in the history
In old version , when save torrent in database the onwer_id will get from app()->session.
However, in commit 4258e5f ,
We remove user info from session and use app()->user to get curuser object.
But This Line is forget to change and will raise this Error when upload torrent:
`SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'owner_id' cannot be null`
  • Loading branch information
Rhilip committed Feb 2, 2019
1 parent 4262301 commit 26d3902
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/controllers/TorrentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function actionUpload()
try {
$torrent->flush();
} catch (\Exception $e) {
return $this->render("errors/action_fail.html.twig", ['title' => 'Upload Failed', 'msg' => $torrent->getError()]);
return $this->render("errors/action_fail.html.twig", ['title' => 'Upload Failed', 'msg' => $e->getMessage()]);
}

return app()->response->redirect("/torrents/details?id=" . $torrent->id);
Expand Down
2 changes: 1 addition & 1 deletion apps/models/form/TorrentUploadForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function flush()
app()->pdo->beginTransaction();
try {
app()->pdo->insert('torrents', [
'owner_id' => app()->session->get('user')['id'], // FIXME it's not good to get user by this way!!!!!
'owner_id' => app()->user->getId(),
'info_hash' => $this->info_hash,
'status' => $this->status,
'title' => $this->title,
Expand Down

0 comments on commit 26d3902

Please sign in to comment.