walinejs / waline

💬 A Simple, Safe Comment System
https://waline.js.org/en/
GNU General Public License v2.0
2.11k stars 371 forks source link

[Bug]: Waline2.5.18前端无法显示评论信息,评论数统计插件显示为0 || [Bug]: Waline2.5.18 front-end cannot display comment information, and the comment number statistics plug-in displays 0 #2591

Open elkan1788 opened 2 weeks ago

elkan1788 commented 2 weeks ago

问题描述 | Describe the bug

在收到用户的评论后,访问管理后台是可以正常查看到评论信息,但在页面前端却不能正常显示。F12查看了后台waline请求路径,发现都是正常的200响应。

1.后台评论显示 后台管理

2.评论插件显示 评论插件

3.评论内容显示 评论内容

问题网站 | Website URL

https://lisenhui.cn/tech/how-to-restart-wsl2.html

服务部署在哪里? | Where your waline deploy?

Vercel (Default)

数据存储在哪里?| Where your comment data store?

LeanCloud(https://leancloud.app)


Problem description | Describe the bug

After receiving the user's comments, the comment information can be viewed normally when accessing the management backend, but it cannot be displayed normally on the front end of the page. F12 checked the background waline request path and found that they were all normal 200 responses.

  1. Backstage comment display Backend management

  2. Comment plug-in display Comment plug-in

  3. Comment content display Comment content

Question Website | Website URL

https://lisenhui.cn/tech/how-to-restart-wsl2.html

Where is the service deployed? | Where your waline deploy?

Vercel (Default)

Where is the data stored? | Where your comment data store?

LeanCloud(https://leancloud.app)

lizheming commented 2 weeks ago

看起来是和不同浏览器下 path 路径的编码问题有关系,建议你评论数那设置 data-path 的时候增加 encodeURIComponent 做下编码。

https://lcweb.lisenhui.cn/comment?type=count&url=/tech/how-to-restart-wsl2.html&lang=zh-CN https://lcweb.lisenhui.cn/comment?type=count&url=%2Ftech%2Fhow-to-restart-wsl2.html&lang=zh-CN


It seems to be related to the encoding problem of path path in different browsers. It is recommended that you add encodeURIComponent when setting data-path in the comments to perform encoding.

https://lcweb.lisenhui.cn/comment?type=count&url=/tech/how-to-restart-wsl2.html&lang=zh-CN https://lcweb.lisenhui.cn/comment?type=count&url=%2Ftech%2Fhow-to-restart-wsl2.html&lang=zh-CN

elkan1788 commented 2 weeks ago

感觉和这个关系不影响不大,使用API工具调试获取都是正常的,就是在站点中调用会出现这样的问题。 image

现有个点更奇怪,就是明明把那些测试的数据都删除了,结果还是在页面中会出现,切换为浏览器隐身模式也还是一样,这里现就只有2条评论。 image image image


I don't think it has much to do with this. It is normal to use API tools to debug and obtain, but such problems will occur when calling on the site. image

The current point is even more strange, that is, even though all the test data has been deleted, the results still appear on the page. Even if the browser is switched to incognito mode, it is still the same. There are only 2 comments here. image image image

lizheming commented 2 weeks ago

应该就是编码的问题,如果你自己处理不了建议换一个唯一字段吧,不要用 pathname


It should be an encoding problem. If you can't handle it yourself, I suggest you change it to a unique field instead of using pathname

elkan1788 commented 2 weeks ago

处理是可以处理的,只是可以明确和编码应该没有问题,因为在后台就只找到2条记录(直接使用路径的wsl2作为关键检索),但为何上面会显示出来6条评论数据呢? leancloud comment


The processing can be handled, but there should be no problem in clearing and coding, because only 2 records are found in the background (directly using wsl2 of the path as the key search), but why are 6 comment data displayed above? leancloud comment

lizheming commented 2 weeks ago

用这个%2Ftech%2Fhow-to-restart-wsl2.html值再搜索下


Use this %2Ftech%2Fhow-to-restart-wsl2.html value and search

elkan1788 commented 2 weeks ago

试过的,没有找搜索到数据。另外也观察到页面的浏览次数统计是正常的,这也是使用url做唯一处理的吧。 image

直接搜索 %2F 也是没有找到相关的数据 image


I tried it, but no data was found. In addition, we also observed that the statistics of the number of page views are normal. This is the only way to use the URL for processing. image

Direct search for %2F also failed to find relevant data. image

lizheming commented 2 weeks ago

要不你导出一份数据发我邮箱吧,我查下问题看看


Why don't you export a copy of the data and send it to my email, and I'll check the problem

elkan1788 commented 2 weeks ago

已导出发送到你的QQ邮箱,劳烦帮忙看看,谢谢。


It has been exported and sent to your QQ mailbox. Could you please help me take a look? Thank you.

lizheming commented 2 weeks ago

你是不是自己换了什么数据库自己忘记掉了,我看你页面上展示的内容,在你发我导出的文件里,根本搜不到啊。

image image

而且从你的截图里看评论列表也很奇怪,一会儿是问有没有收到邮件通知的评论,一会儿是讨论 CDN 屏蔽的评论。这两个都对应着一个页面,但是数据又不一样。

elkan1788 commented 2 weeks ago

没有换数据库哦,一直就是使用的leancloud数据存储方式。之前发的那些测试评论已经删除了,只保留了网友有关于CDN屏蔽的讨论。所以这个how-to-restart-wsl2.html页面只有2条记录。

comments

自己也测试了好久,似乎和缓存有关系啦,用新的设备访问确实是看不出问题来的。😂


The database has not been changed, and the leancloud data storage method has been used. The test comments previously posted have been deleted, leaving only netizens’ discussions about CDN blocking. So this how-to-restart-wsl2.html page only has 2 records.

![comments](https://private-user-images.githubusercontent.com/1217096/345258330-c6ed250d-11b0-44c2-8c7c-49167182f6dc.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOi JnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6Imtle TUiLCJleHAiOjE3MjAxNDIxNzEsIm5iZiI6MTcyMDE0MTg3MSwicGF0aCI6Ii8xMjE3MDk2LzM0 NTI1ODMzMC1jNmVkMjUwZC0xMWIwLTQ0YzItOGM3Yy00OTE2NzE4MmY2ZGMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZ TFNBNTNQUUs0WkElMkYyMDI0MDcwNSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQ W16LURhdGU9MjAyNDA3MDVUMDExMTExWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cm U9NGMxMGE5MjY0OWMxZDI0NzYzYTY2ZTc4YTI4MjcxNjk2OWY4NThkOWE2NzMyMTVhZTgzZWY3YzAzOTNmNjc0ZiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaW Q9MCZyZXBvX2lkPTAifQ.gXOP2mU0AlTXnscwYgaosSRl2rbvq3ugb_e0BCKqvx0)

I have been testing it for a long time, and it seems to be related to the cache. There is indeed no problem when accessing it with a new device. 😂

lizheming commented 2 weeks ago
  1. 接口的数据,和缓存没有关系应该。这个得需要你自己排查下,给我的数据和线上有问题的数据不一致,这块我没办法继续跟进排查。
  2. 登录的问题我好像发现点问题,你的网站域名是不是设置了什么未知 referrer 跳转屏蔽的逻辑,目前看第三方登录相关的都会因为这个跪掉。
  3. The interface data has nothing to do with caching. You need to investigate this yourself. The data given to me is inconsistent with the problematic data online. I cannot continue to follow up on this issue.
  4. I seem to have found something wrong with the login problem. Is your website domain name set up with some unknown referrer jump blocking logic? Currently, anyone related to third-party login will be killed because of this.
elkan1788 commented 2 weeks ago

好的,谢谢Austin大神,后续我再观察一下。


Okay, thank you Austin, I will take a closer look later.

elkan1788 commented 2 weeks ago

@lizheming 有什么办法在count和comment请求时,在URL后面添加个自定义参数呢?比如ts=1720159903

lizheming commented 2 weeks ago

可以自己自定义客户端实现。


You can customize the client implementation yourself.

elkan1788 commented 2 weeks ago

有没可参考的案例学习下,在手册上似乎没有找到这部分的说明,谢谢。


Is there any case study that I can refer to? I can’t seem to find this part of the explanation in the manual. Thank you.

lizheming commented 2 weeks ago

你这个是比较定制化的功能了,需要自己研究下了。简单的说就是官方的代码你自己 fork 过去自己改改。


This is a more customized function, so you need to study it yourself. To put it simply, you can fork the official code and modify it yourself.

elkan1788 commented 2 weeks ago

好的,回头了解一下。


Okay, let’s go back and find out.

lizheming commented 2 weeks ago

目前来看,这个 issue 应该和你做了 CDN 缓存有点关系。如果是你把接口做了 CDN 化的话。个人建议你增加下 postSave 的钩子,发布评论后调 CDN 的接口清空缓存,应该也可以的。


From the current point of view, this issue may have something to do with your CDN caching. If you convert the interface into a CDN. Personally, I suggest you add a postSave hook and adjust the CDN interface to clear the cache after posting a comment. It should also work.

elkan1788 commented 2 weeks ago

也不清楚具体什么情况,如果说是CDN缓存的话,那文章浏览次数统计应该也是会触发才是,但它又是正常的。就只是评论内容相关的接口有缓存现象,所以有点懵圈。


I don’t know what the specific situation is. If it is CDN caching, then the statistics of article views should also be triggered, but it is normal. It's just that the interface related to the comment content is cached, so I'm a bit confused.