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

Bug with removing attachments not synced with db #172

Closed
tvb opened this issue Mar 24, 2014 · 2 comments
Closed

Bug with removing attachments not synced with db #172

tvb opened this issue Mar 24, 2014 · 2 comments
Milestone

Comments

@tvb
Copy link
Contributor

tvb commented Mar 24, 2014

@tobscure I have tried to fix the attachment plugin so removing attachments is now working as well. See my commit https://github.com/tristanvanbokkem/esoTalk/commit/c76eb510c2a5dda92089b5c4169b4412716f1c49 and https://github.com/tristanvanbokkem/esoTalk/commit/79506a117a929919466900931b9954b73aef14d3 (and https://github.com/tristanvanbokkem/esoTalk/commit/e3f5172de46e5f08125a9b17412e8c0c7b3fe86d for a tiny mistake)

There is still a bug where the attachment will not be deleted from filesystem if it has not been written to the database yet. (reproduce by: edit post -> add attachment -> remove attachment without saving the reply) This is due the following code part:

$attachment = $model->getById($attachmentId);

// Make sure the user has permission to edit this post.
$permission = false;

if (!empty($attachment[0]["postId"])) {
    $post = ET::postModel()->getById($attachment[0]["postId"]);

    $conversation = ET::conversationModel()->getById($post["conversationId"]);
    $permission = ET::postModel()->canEditPost($post, $conversation);
}
else {
    $permission = ET::$session->userId == $attachment[0]["draftMemberId"];
}

if (!$permission) {
    $this->renderMessage(T("Error"), T("message.noPermission"));
return false;
}

The problem is that since the attachment has yet to be written to the database the following part will return null.

$attachment = $model->getById($attachmentId);

and therefor you will hit

if (!$permission)

I could not find a quick solution to fix that part. Maybe you can look into it?

@tvb
Copy link
Contributor Author

tvb commented Apr 12, 2014

Can be closed.

@tvb tvb closed this as completed Apr 12, 2014
@tobyzerner tobyzerner reopened this Apr 15, 2014
@tvb
Copy link
Contributor Author

tvb commented Apr 17, 2014

@tobscure Do you have time to look into this one before you go back to uni?

@tobyzerner tobyzerner added this to the 1.0.0g4 milestone Apr 25, 2014
tobyzerner added a commit that referenced this issue May 7, 2014
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

2 participants