我收到报告称,某用户在点击头像时,通知会加载。(这是最近升级到 2.4.0.beta10 后的情况。)系统中只有一个非标准插件,但不太可能是导致问题的原因,而且该问题目前只影响一个用户(至少据我们所知)。(随后我尝试在不加载该插件的情况下进行升级,但问题仍未解决。)启用 safe-mode 也无济于事。
当访问特定用户的 /u/username/notifications 页面时,没有显示任何通知,但点击“回复”、“点赞”等分类时,却能显示对应类型的通知项。我进入 psql 并执行了 reindex table notifications,未报错。
点击头像时,JavaScript 控制台报错如下:
_application-4715c32620ba9b83af00144510f68ca0f0bae8f745edf2339e3f249ceee88c3f.js:77240 Uncaught TypeError: Cannot read property 'dasherize' of undefined
查看代码:
return [this.attach(notificationName.dasherize() + "-notification-item", attrs, {}, { fallbackWidgetName: "default-notification-item" }), (0, _virtualDom.h)("span.time", (0, _node.dateNode)(attrs.created_at))];
在我看来(当然也可能完全猜错),问题可能出在获取通知时出现了错误或返回了 nil/null/空值?
我在 Rails 中查询该用户的通知时并未出现问题:
pry(main)> Notification.where(user_id: 870).count
=> 372
# 这条命令也能返回结果:
u=User.find(870)
Notification.recent_report(u)
我现在已经想不出其他办法了。
