yii2mod / yii2-comments

Comments module for Yii2
MIT License
159 stars 64 forks source link

Problem with the encoding of the createComment using CommentWidget #104

Open marcelom87 opened 4 years ago

marcelom87 commented 4 years ago

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.