Sulu,尝试保存页面/帖子时出现与哈希相关的奇怪错误?

问题描述

直到最近一切都运行良好。现在,当我尝试保存(创建或更新)任何页面或帖子时,我在表单顶部收到错误消息“错误 - 尝试保存表单时出错”。

在错误日志中我看到这个错误:

“未捕获的 PHP 异常 Sulu\Component\Rest\Exception\InvalidHashException:”类型为“Sulu\Bundle\ArticleBundle\Document\ArticleDocument”的实体的给定哈希,ID 为“9e0720a7-5565-4a6f- a735-8a186b8fef9b”与当前哈希不匹配。该实体可能同时已被编辑。”在 /var/www/html/vendor/sulu/sulu/src/Sulu/Component/Hash/RequestHashChecker.php line 53"

尝试从管理员清除 symfony 缓存、网站缓存,重新启动 docker 容器。

我完全不知道我做了什么导致这个错误。请帮忙。

更新:我刚刚注意到的奇怪的事情。当我尝试保存某篇文章并出现该错误并返回概述页面(即列出该类型的所有文章)时,我会看到未更改的文章标题。但是当我点击编辑它时,我看到改变的标题?!?概述页面上的标题和编辑页面上的标题不是从同一个地方使用的吗?这怎么可能?

更新:

现在,即使我从头开始重新设置项目,保存文章也会导致该错误。更多信息:

在堆栈跟踪中最后执行的命令是:

in vendor/elasticsearch/elasticsearch/src/Elasticsearch/ConnectionPool/StaticNoPingConnectionPool.php (line 64)

它发出“在您的集群中没有找到活动节点”

当我在执行时设置项目:

php bin/console ongr:es:index:create

出现错误:

{"error":{"root_cause":[{"type":"resource_already_exists_exception","reason  
  ":"index [su_articles/sWs5F1uzSFO8bFiZqF1Egw] already exists","index_uuid":  
  "sWs5F1uzSFO8bFiZqF1Egw","index":"su_articles"}],"type":"resource_already_e  
  xists_exception","reason":"index [su_articles/sWs5F1uzSFO8bFiZqF1Egw] alrea  
  dy exists","index_uuid":"sWs5F1uzSFO8bFiZqF1Egw","index":"su_articles"},"st  
  atus":400} 

当我跑步时:

php bin/console ongr:es:index:create --manager=live

我得到了类似的:

In Connection.php line 675:
  {"error":{"root_cause":[{"type":"resource_already_exists_exception","reason":"index [su_articles_live/Pissm9ycRj-o79K4wrrD  
  AA] already exists","index_uuid":"Pissm9ycRj-o79K4wrrDAA","index":"su_articles_live"}],"type":"resource_already_exists_exc  
  eption","reason":"index [su_articles_live/Pissm9ycRj-o79K4wrrDAA] already exists","i  
  ndex":"su_articles_live"},"status":400} 

还要提一下,现在保存页面有效,但保存文章无效。

解决方法

这为我解决了 ElasticSearch 索引创建问题:

php bin/console ongr:es:index:drop --force
,

错误可能发生在以下情况。

  • 预期案例 其他人确实像您一样编辑了同一篇文章并确实保存了它
  • 意外情况您的 phpcr 缓存不同步
  • 意外情况您设置了多服务器,但您的 cache.app 未配置为使用中央缓存

因此,如果首先是意外情况之一,您应该使用以下命令清除 cache.pools:

bin/console cache:pool:prune

如果您设置了多服务器,请确保配置中央缓存。在这种情况下,大多数使用您在 redis-server 中配置的 cache.yaml,例如:

# config/packages/prod/cache.yaml
framework:
    cache:
        default_redis_provider: "%env(resolve:REDIS_DSN)%"
        app: cache.adapter.redis

还要确保您使用最新版本,并可能根据 sulu/skeleton 更新您的 phpcr 缓存配置:https://github.com/sulu/skeleton/blob/2.x/config/packages/prod/sulu_document_manager.yaml,在您的情况下,当性能无关紧要时,您可以禁用 phpcr 缓存,我不建议这样做。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...