Skip to content

Problem with the encoding of the createComment using CommentWidget #104

Open
@marcelom87

Description

@marcelom87

Hi,

First of all, thank you very much for creating this extension.

I used recently the yii2-comments with a shared host from Bluehost and I was receiving a 405 error during the creation of a new comment.
I figured out that was something related to the crypted/serialized json message that was being corrupted somehow during the form submission. I also noticed that the serialized data was already encoded in utf8. But the issue continued.
To solve this issue, I had to use the base64_encode, such as next:

File: yii2-comments/widgets/Comment.php -> line 18
From:
'action' => Url::to(['/comment/default/create', 'entity' => $encryptedEntity]),
To:
'action' => Url::to(['/comment/default/create', 'entity' => base64_encode($encryptedEntity)]),

File: yii2-comments/controllers/DefaultController.php -> line 110
From:
$commentModel->setAttributes($this->getCommentAttributesFromEntity($entity));
To:
$commentModel->setAttributes($this->getCommentAttributesFromEntity(base64_decode($entity)));

This solved the issue.
Thank you very much.
Cheers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions