Drupal node.Auto_increment 字段跳到亿(从五十万)的原因?

发布于 2024-10-21 05:20:42 字数 875 浏览 2 评论 0 原文

我的 Drupal 节点表上的 nid 字段从 254,107 跃升至 500,220,117。是什么导致了这种情况?我没有弄乱 Auto_increment 字段。

我发现 drupal_write_record 和 node_save 函数调用中对于任何可能导致此 nid 跳转的人为错误的余地很小,node_save 接受的参数是节点对象。

错误构建的节点对象会导致 Auto_increment 字段跳转吗?即,对于某种奇怪的错误,代码在将 nid 字段传递给 node_save 之前将其切换为其他内容?如果这是真的,则错误将出现在node_save之前的代码中,但它也可能位于流氓 hook_invoke_nodeapi,因为 node_save() 在函数开头调用此代码片段:

// Let modules modify the node before it is saved to the database.
node_invoke_nodeapi($node, 'presave');

您将如何设置一个测试来检测此情况?

我可能会在 node_save() 中设置一个奇异的条件断点(或其中几个),特别是在 db_query()。在 db_query() 中,断点很可能包含正则表达式。然后我可以设置某种自动化测试,将各种节点类型保存到数据库中(考虑开发模块)并查看是否出现某些内容。如果我发现任何问题,我会自己回答这个问题,除非其他人过去有类似的经历并首先回答。

The nid field on my Drupal node table jumped from from 254,107 to 500,220,117. What could have caused that? I haven't messed up with the Auto_increment field.

I see very little leeway in the drupal_write_record and node_save function calls for any kind human errors that could cause this nid jump, node_save what accepts as an argument is a node object.

Could a badly built node object cause a jump in the Auto_increment field? i.e. that for some sort of weird bug the code switches the nid field with something else before passing it to node_save? If this were true, the bug would be in the code preceding the node_save, but it could also be inside a rougue hook_invoke_nodeapi, since node_save() calls this snippet at the beginning of the function:

// Let modules modify the node before it is saved to the database.
node_invoke_nodeapi($node, 'presave');

How would you go about setting a test for detecting this?

I will probably set up an exotic conditional breakpoint (or a couple of them) within node_save(), and particularly on the last line of db_query(). In db_query() the breakpoint will most likely contain a regular expression. Then I could set some sort of automated test that saves all kinds of node types into the database (thinking about the devel module) and see if something appears. If I find anything I will answer myself the question, unless someone else had a similar experience in the past and answers first.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暮凉 2024-10-28 05:20:42

是的,如果没有更多信息,我们无法知道。 Drupal 使用什么进行排序取决于您所使用的版本。请参阅了解更多信息。

Yeah, we can't know without more information. What Drupal uses for it's sequencing depends on the version you are using. See this for more info.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文