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

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

问题描述

当用户在我的网站上注册时,似乎无法从drupal_set_message获取消息。
我正在使用Drupal 6.14。



在user.module中添加打印:

  function user_register_submit($ form,& $ form_state){
...
if($ notify){
...
}
else {
drupal_set_message(t('您的密码和进一步的说明已发送到您的电子邮件地址。
print'xxxxxx';
$ form_state ['redirect'] ='';
return;
}
}
...

}

打印xxxxx;



$ $ var $ _SESSION 变量给出状态消息,其中 drupal_set_message 不显示,所以看起来不错。



我已经卸载了我所有的模块,只有核心遗骸,现在使用Garland作为主题。



此外,我已经安装了一个新的Drupal安装,那里给我一个很好的状态信息。



然后我比较了.htaccess和Drupal的,从新安装。



没有任何帮助。



任何想法?

解决方案

很好地找到原因 - 几周前我有这个完全相同的问题。



现在,原因如下:



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



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



编辑:



最近的评论促使我添加一些更深入的答案,因为我发现最可能的错误原因。



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

我们遇到问题,因为我们在开发期间使用MySQL转储来导出和导入备份。


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

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;
      }
    }
    ...

}

It prints 'xxxxx';

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

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

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

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

Nothing helps.

Any thoughts?

解决方案

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

Now, for the reason:

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).

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

Edit:

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.

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).

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

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

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