We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
php -v
7.1.16
php --ri swoole
4.0.0-beta
Laravel
Lumen
5.5.40
使用第三方库flash做表单验证提醒,当第一次提醒成功时候有一次提醒,当第二次成功的时候有两个提醒,每次会增多,刷新都没用,而在fpm下运行不会出现此结果,该库的地址https://github.com/laracasts/flash,麻烦大神帮我看看
reproducible
steps
// controller flash("添加成功")->success()->important(); return view('test'); // view @extends('layouts.app') @section('content') @include('flash::message') @endsection
The text was updated successfully, but these errors were encountered:
使用Swoole Http Server后,单例、全局变量、静态变量会被常驻内存,这是导致出现此问题的根本原因。而在FPM每次请求开始时初始化变量,请求完成后所有变量会自动回收。所以表现不一样。 要解决这个问题,最直接有效的就是每次请求前重置或请求完成后清理这些请求上下文。 具体参考单例问题。
请求前重置
请求完成后清理
请求上下文
具体到这里issue,因FlashServiceProvider中注册的是单例,所以此单例的成员$messages也被常驻内存,调用flash("添加成功")->success()->important();是往$messages中追加,故消息提醒会叠加。 FlashNotifier.php#L95 Collection.php#L1719
FlashServiceProvider
$messages
flash("添加成功")->success()->important();
最终解决方案有两个:
中间件
处理前
请求完成后
app('flash')->clear();
Sorry, something went wrong.
按照文档设置 register_providers 已经解决,谢谢
No branches or pull requests
php -v
)7.1.16
php --ri swoole
)4.0.0-beta
Laravel
/Lumen
version(check composer.json & composer.lock)5.5.40
使用第三方库flash做表单验证提醒,当第一次提醒成功时候有一次提醒,当第二次成功的时候有两个提醒,每次会增多,刷新都没用,而在fpm下运行不会出现此结果,该库的地址https://github.com/laracasts/flash,麻烦大神帮我看看
reproducible
code block andsteps
The text was updated successfully, but these errors were encountered: