sabersma

sabersma

这家伙有点懒,还没写个性签名!

  • 财富值85
  • 威望值0
  • 总积分95

个人信息

  • 回复了 的回答

    flash内容存储在session中, 和debug module没什么关系.

    addFlash('a', 'b') 之后, 再getFlash('a')之后, 是可以销毁这条消息.

    但是 : 是在下次请求中销毁, 本次请求的后续处理中还存在.

    其实也就是setFlash()参数$removeAfterAccess = true (delete after access) or false (delete until the next call) 两种情况下的自动销毁没有生效,但是其他方式的显式删除flash是可以的。(第四个case == 第一个case, 忽略它吧)

    是别的地方有什么需要配置吗?

  • 回复了 的回答

    flash内容存储在session中, 和debug module没什么关系.

    addFlash('a', 'b') 之后, 再getFlash('a')之后, 是可以销毁这条消息.

    但是 : 是在下次请求中销毁, 本次请求的后续处理中还存在.

    额,输出部分格式贴乱了,,凑合着看吧

  • 回复了 的回答

    flash内容存储在session中, 和debug module没什么关系.

    addFlash('a', 'b') 之后, 再getFlash('a')之后, 是可以销毁这条消息.

    但是 : 是在下次请求中销毁, 本次请求的后续处理中还存在.


    额,不好意思我记错了,getFlash()时置delete=true 或是调用$session->removeFlash()都是有效的。但是除此之外的自动销毁还是无效。刚才写了下测试:
    actions:

    public function actionTestFlash() {
        Yii::$app->session->setFlash('delete when access', 'hello world', true);
        Yii::$app->session->setFlash('delete when next call', 'hello world', false);
        Yii::$app->session->setFlash('set delete when getFlash', 'hello world');
        Yii::$app->session->setFlash('set nothing, wait for auto delete in the next call', 'hello world');
    }
    
    public function actionNewCall1() {
        return $this->render('new_call1');
    }
    
    public function actionNewCall2() {
        return $this->render('new_call2');
    }
    

    new_call1.php:

    $session = Yii::$app->session;
    var_dump('delete when access' . ' - ' . $session->getFlash('delete when access'));
    var_dump('delete when next call' . ' - ' . $session->getFlash('delete when next call'));
    var_dump('set delete when getFlash' . ' - ' . $session->getFlash('set delete when getFlash', null, true));
    var_dump('set nothing, wait for auto delete in the next call' . ' - ' . $session->getFlash('set nothing, wait for auto delete in the next call'));
    var_dump($_SESSION);
    

    new_call2.php:

    $session = Yii::$app->session;
    $flashes = $session->getAllFlashes();
    
    var_dump($flashes);
    var_dump($_SESSION);
    $session->removeAllFlashes();
    

    new-call1的输出:

    string(32) "delete when access - hello world"
    string(35) "delete when next call - hello world"
    string(38) "set delete when getFlash - hello world"
    string(64) "set nothing, wait for auto delete in the next call - hello world"
    array(4) {
      ["delete when access"]=>
      string(11) "hello world"
      ["__flash"]=>
      array(3) {
        ["delete when access"]=>
        int(1)
        ["delete when next call"]=>
        int(0)
        ["set nothing, wait for auto delete in the next call"]=>
        int(1)
      }
      ["delete when next call"]=>
      string(11) "hello world"
      ["set nothing, wait for auto delete in the next call"]=>
      string(11) "hello world"
    }
    

    new_call2输出:

    array(3) {
      ["delete when access"]=>
      string(11) "hello world"
      ["delete when next call"]=>
      string(11) "hello world"
      ["set nothing, wait for auto delete in the next call"]=>
      string(11) "hello world"
    }
    array(4) {
      ["delete when access"]=>
      string(11) "hello world"
      ["__flash"]=>
      array(3) {
        ["delete when access"]=>
        int(1)
        ["delete when next call"]=>
        int(0)
        ["set nothing, wait for auto delete in the next call"]=>
        int(1)
      }
      ["delete when next call"]=>
      string(11) "hello world"
      ["set nothing, wait for auto delete in the next call"]=>
      string(11) "hello world"
    }
    

    除了在getFlash()时设置delete=true的那次之外其余三次均没有正常销毁,当然,removeAllFlashes()之后整个世界都清净了。

  • 2015-11-25 已签到
    连续签到2天,获得了10个金钱
  • 回复了 的回答

    flash内容存储在session中, 和debug module没什么关系.

    addFlash('a', 'b') 之后, 再getFlash('a')之后, 是可以销毁这条消息.

    但是 : 是在下次请求中销毁, 本次请求的后续处理中还存在.

    这个我是知道的,补充一下,是在不加载debug module的情况下。getFlash()且非同一次请求,没有销毁这条信息,
    即使是在getFlash()中将参数delete显示置为true也没用。

  • 提出了问题
    addFlash()的内容不能被正常销毁
  • 你的$identity 的类需要继承一下IdentityInterface接口

  • 2015-11-24 已签到
    连续签到1天,获得了5个金钱
职场新人 等级规则
95/100
资料完整度
10/100
用户活跃度
0/100

Ta的关注

0

Ta的粉丝

0

Ta的访客

1