Drupal:drupal_set_message 不显示消息 [英] Drupal: drupal_set_message doesnt display a message

查看:13
本文介绍了Drupal:drupal_set_message 不显示消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户在我的网站上注册时,我似乎无法收到来自 drupal_set_message 的消息.我使用的是 Drupal 6.14.

I cannot seem to get a message from drupal_set_message when a user registers on my site. I'm using Drupal 6.14.

在 user.module 中添加打印:

Adding a print in the user.module:

function user_register_submit($form, &$form_state) {
  ...
      if ($notify) {
        ...
      }
      else {
        drupal_set_message(t('Your password and further instructions have been sent to your e-mail address.'));
        print 'xxxxxx';
        $form_state['redirect'] = '';
        return;
      }
    }
    ...

}

它打印'xxxxx';

It prints 'xxxxx';

$_SESSION 变量的 var_dump 给出状态消息,drupal_set_message 不显示,所以看起来也不错.

A var_dump of the $_SESSION variable gives the status message, which drupal_set_message doesnt display, so that looks fine also.

我已经卸载了所有模块,只剩下核心部分,并且现在使用 Garland 作为主题.

I've uninstalled all my modules, only core remains, and using Garland now as a theme.

此外,我已经安装了一个全新的 Drupal,它给了我一个很好的状态消息.

Furthermore, I've installed a fresh Drupal installation, and there it gives me a nice status message.

然后我从全新安装中比较了我的 .htaccess 和 Drupal.修改了我的,使它们相等.

Then i compared my .htaccess and Drupal's, from the fresh install. Modified mine to make them equal.

没有任何帮助.

有什么想法吗?

推荐答案

很好地找到了原因——几周前我遇到了完全相同的问题.

nicely done finding the cause - I had this exact same problem a couple of weeks or so ago.

现在,原因:

Drupal 会话通过 ID 号(如果您查看,您可以在数据库的会话表中看到)链接到用户.Drupal 也有它自己的会话处理功能,其中之一是检查当前会话是否与有效的用户帐户相关联 - 对于匿名用户,即用户 0 -(如果多个会话无关紧要)对每个用户都是开放的 - 当如此多的匿名用户访问您的网站时肯定会发生这种情况).

Drupal sessions are linked by ID number (you can see this in the session table in the database if you look) to the user. Drupal also has it's own session handling functions, and one of those is a check to see if the current session is associated with a valid user account - and for anonymous users, that is the user 0 - (it doesn't matter if multiple sessions are open per user - which is certainly what happens when so many anonymous users visit your site).

如果 Drupal 没有找到当前会话的有效用户,则重新生成会话 - 意味着之前的信息丢失.

If Drupal does not find a valid user for the current session, then the session is regenerated anew - meaning the previous information is lost.

最近的一条评论促使我对答案进行了更深入的讨论,因为我已经找到了导致错误的最可能原因.

A recent comment has prompted me to add a bit more depth to the answer as I have since found the most likely cause for the error.

基本上,这是匿名用户使用 ID 0.如果您将 0 值插入 MySQL 中的自动递增字段,该值实际上将成为序列中的下一个可用值(因此,自动递增字段设置为 10 的表将在 11 而不是 0 处插入).

Basically, it's the use of ID 0 for the anonymous user. If you INSERT a 0 value into an auto-incrementing field in MySQL, the value will actually become the next available value in the sequence (so, a table with auto-incrementing field set to 10 will INSERT at 11 and not 0).

我们遇到了这个问题,因为我们在开发过程中使用 MySQL 转储来导出和导入备份.

We hit the problem because we were using MySQL dumps for exporting and importing backups during development.

这篇关于Drupal:drupal_set_message 不显示消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆