Drupal - 无明显原因加载节点
(抱歉,这是一个相当模糊的问题。我试图变得更清晰[并且确实更加面向代码]
失败了...) :-/
//
我已经为 Drupal 安装了 Firebug模块,我注意到它显示我显然在每个页面上加载相同的八个节点对象,没有明显的原因。这些都是相同的内容类型(该网站使用许多其他内容类型)。
看起来它们实际上是该一种内容类型的所有节点,除了那些由开发者模块作为虚拟内容生成的节点。
我已经多次刷新缓存了。
有没有办法计算出这些节点是从哪里加载的???
(Sorry this is rather a vague question. My attempts to be clearer [and indeed to be more code-oriented]
have failed...) :-/
//
I've installed the Firebug for Drupal module, and I notice that it shows I'm apparently loading the same eight node objects on every page for no apparent reason. These are all of the same content type (the site uses many other content types).
It seems they are actually all the nodes of this one content type, excepting those produced as dummy content by the developer module.
I've flushed the cache multiple times.
Is there a way to work out where these nodes are being loaded from???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
安装devel.module,在node_load()函数中添加
ddebug_backtrace();
。重新加载网站。现在您应该看到 8 个可浏览的回溯,它们会告诉您哪个函数调用了 node_load()。Install devel.module, add
ddebug_backtrace();
inside the node_load() function. Reload the site. Now you should see 8 browsable backtraces which will tell you which function calls node_load().据猜测,您可能有一个块(来自视图或模块)在每个请求上查询这些节点。
http://heydon.com.au/node/1044对此行为有一个简短的描述。如果是这样,解决方法是从渲染的区域中删除该块,或者将其配置为仅在您希望运行它的页面上显示(并因此渲染)。
Drupal 缓存应该阻止匿名用户运行这些查询(当然,这取决于缓存和块设置)。
At a guess, you probably have a block (from a view or module) which is querying those nodes on every request.
http://heydon.com.au/node/1044 has a short writeup on this behaviour. If so, the fix is to remove that block from the regions which are rendered, or configure it to only be displayed (and therefore rendered) on pages where you want it to be run.
Drupal caching should prevent those queries being run for anonymous users (depending on the caching and block settings, of course).
我在第三方模块中遇到过这种情况,这些模块不必要地重复调用 node_load() 。我建议您禁用所有第 3 方模块,重试节点加载并一一重新启用它们,直到您发现行为不当的模块。
祝你好运!
I've had this happen with 3rd party modules that were repeatedly calling node_load() needlessly. What I would suggest is for you to disable all 3rd party modules, retry you node loads and re-enable them one by one until you catch the misbehaving module.
Good-luck!