在PROD环境中不能使用闪光灯的方法
-
20-09-2019 - |
题
我使用的symfony 1.4的setFlash和hasFlash方法与WAMP 2.0
本地与我frontend_dev的应用程序,一切工作正常。
但是,在生产环境中,我的测试$this->forward404Unless($user->hasFlash('resultsArray'));
失败。
我认为闪存的方法,其中默认启用。我能做些什么,使之工作好吗?
编辑:我发现了一个有趣的错误消息
下面是我filters.yml文件
# You can find more information about this file on the symfony website:
# http://www.symfony-project.org/reference/1_4/en/12-Filters
rendering: ~
security: ~
# insert your own filters here
cache: ~
flash: ~
execution: ~
在frontend_prod.log,我有:
03月16日5点57分42秒的symfony [信息] {sfPatternRouting}匹配路线为 “主页”(/)/与参数阵列( '模块'=> '主', '动作'=> '索引',)点击 03月16日5时57分42秒的symfony [ERR] {} sfParseException的配置文件 “d:\ WAMP \ BIN \ PHP \ symfony的\ symfony14 \ lib中/配置/配置/ filters.yml” 指定类别 “闪光” 的缺失类键。
解决方案
您拨打的 executeShowResult 的一个重定向/前锋背景下采取行动?闪存寿命有限,并在下次请求后,它会消失。显然, resultsArray 已被冲刷掉。
其他提示
您有在生产(图标或图像)被生成的404和计数作为对404动作的请求(重定向之后)清理掉的闪光变量。
不知道这是答案,但我没有在我的filters.yml文件flash
键,在Symfony的1.4.3应用程序,因为从现场的Symfony抓住版本我没碰过它。你有没有尝试删除从YML文件行,清除缓存,然后再次尝试?
我不知道你是否已经为督促启用缓存?
如果你这样做,并缓存with_layout(或者,如果闪光灯在动作模板,然后缓存相关的动作),那么它将返回缓存页面,而不在随后的意见闪光灯消息。
请确保您有use_flash=true
您factories.yml
user:
class: myUser
param:
timeout: 3600
logging: %SF_LOGGING_ENABLED%
use_flash: true
default_culture: %SF_DEFAULT_CULTURE%
但一个很老的回应,我希望是一些使用到其他人同样的问题的。
@Lunohodov
(对不起张贴的答案,而不是一个评论,但我不能使用的字符限制的这种方式的原因)
下面是动作:
public function executeShowResult()
{
$user = $this->getUser();
$this->forward404Unless($user->hasFlash('resultsArray'));
$this->results = $user->getFlash('resultsArray');
$user->setFlash('resultsArray', $this->results);
$this->pager = new myArrayPager(null, 15);
$this->pager->setResultArray($this->results);
$this->pager->setPage($this->getRequestParameter('page'));
$this->pager->init();
$this->myModule = $this->getRequestParameter('myModule');
$this->myTemplate = $this->getRequestParameter('myTemplate');
$forwardPage = '../../'.$this->getRequestParameter('myModule').'/templates/'.$this->getRequestParameter('myTemplate');
$this->setTemplate($forwardPage);
return sfView::SUCCESS;
}
编辑:另一个有趣的日志。在我的行动,其设置闪光,我已经把日志,测试组和hasFlash方法...和它的工作:
$user = $this->getUser();
$user->setFlash('resultsArray', $this->results);
if ($user->hasFlash('resultsArray'))
{
sfContext::getInstance()->getLogger()->info("The flash is set");
}
else
{
sfContext::getInstance()->getLogger()->info("The flash is NOT set");
}
该日志:
03月16日6时07分13秒的symfony [信息]闪光灯设置
我觉得我失去了一些东西大在这里...