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

Problem with the encoding of the createComment using CommentWidget #104

Open
marcelom87 opened this issue Oct 21, 2020 · 0 comments
Open

Comments

@marcelom87
Copy link

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.

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