如何调试此异常?它位于显示最近查看的项目的部分中,该项目位于显示单个项目的页面上 . 两个部分的模板在for循环中使用相同的变量名称,例如 <f:for each="{productArticles}" as="productArticle">
但是当列出最近查看的项目时,并不总是抛出异常(只显示那些项目的链接) . 例外情况似乎只发生在:我在显示礼品卡的页面上,然后我从下拉菜单中选择一个不同的礼品卡(显示不同的礼品卡面额),然后当页面刷新以显示不同的卡片然后我想显示的第一张卡片现在是最近浏览过的物品之一 . 但是,如果我转到另一页然后返回礼品卡页面,则可能不会出现错误 .
Exception while rendering
page<TYPO3.Neos:Page>/
body<TYPO3.TypoScript:Template>/
content/
main<TYPO3.Neos:PrimaryContent>/
default<TYPO3.TypoScript:Matcher>/
element<TYPO3.Neos:ContentCollection>/
itemRenderer<TYPO3.Neos:ContentCase>/
default<TYPO3.TypoScript:Matcher>/
element<TYPO3.Neos.NodeTypes:TwoColumn>/
columns<TYPO3.TypoScript:Collection>/
itemRenderer<TYPO3.Neos.NodeTypes:MultiColumnItem>/
columnContent<TYPO3.Neos:ContentCollection>/
itemRenderer<TYPO3.Neos:ContentCase>/
default<TYPO3.TypoScript:Matcher>/
element<MyCompany.Store:RecentlyViewedProduct>:
Duplicate variable declaration, "productArticle" already set! (20141105131932df2032)
这是模板:
<f:layout name="Default" />
<f:section name="Title">
<h3>
<f:translate id="MyCompany.Store.Recently-Viewed">Recently Viewed</f:translate>
</h3>
</f:section>
<f:section name="Content">
<f:if condition="{productArticles}">
<f:then>
<f:for each="{productArticles}" as="productArticle">
<f:link.action action="showProductArticle" controller="Product" arguments="{productArticle: productArticle}">{productArticle.product.name}</f:link.action>
</f:for>
</f:then>
<f:else>
<p>
<f:translate id="MyCompany.Store.No-Recently-Viewed">No recently viewed product</f:translate>
</p>
</f:else>
</f:if>
</f:section>
和模板的动作:
/**
* Shows most recently viewed products
*
* @param \MyCompany\Store\Domain\Model\ProductArticle $productArticle
* @return void
*/
public function recentlyViewedProductsAction() {
$recentProduct = $this->cart->getProductArticle();
$recentProductThree = array_reverse($recentProduct);
array_splice($recentProductThree, 3);
if (count($recentProduct) !== 0) {
$this->view->assign('productArticles', $recentProductThree);
}
}
关于重复var的消息对我来说是有意义的,如果异常总是抛出,因为其他模板也使用它,但由于它只是偶尔抛出,我不知道该怎么做 .
异常日志如下所示
/home/thebigcat/domains/store.thebigcat.ca/public_html/releases/20131219160416/Data/Temporary/Development/Cache/Code/Flow_Object_Classes/TYPO3_Fluid_ViewHelpers_ForViewHelper.php第116行中未捕获的异常#1224479063:重复变量声明,“productArticle “已经定了! 115 TYPO3 \ Fluid \ Core \ ViewHelper \ TemplateVariableContainer_Original :: add(“productArticle”,TYPO3 \ Flow \ Persistence \ Doctrine \ Proxies _CG __ \ Mycompany \ Store \ Domain \ Model \ ProductArticle)114 TYPO3 \ Fluid \ ViewHelpers \ ForViewHelper_Original :: renderStatic( array | 5 |,Closure,TYPO3 \ Fluid \ Core \ Rendering \ RenderingContext)113 ()112 TYPO3 \ Fluid \ Core \ ViewHelper \ AbstractConditionViewHelper :: renderThenChild()111 TYPO3 \ Fluid \ ViewHelpers \ IfViewHelper_Original :: render( TRUE)110 call_user_func_array(阵列| 2 |,阵列| 1 |)109 TYPO3 \流体\核心\视图助手\ AbstractViewHelper :: callRenderMethod()108 TYPO3 \流体\核心\视图助手\ AbstractViewHelper :: initializeArgumentsAndRender()107 FluidCache_Mycompany_Store_Product_action_recentlyViewedProducts_1f6458e2b69625fca8d5707e4161562d5d061770 :: section_4f9be057f0ea5d2ba72fd2c810e8d7b9aa98b469 (TYPO3 \ Fluid \ Core \ Rendering \ RenderingContext)106 TYPO3 \ Fluid \ View \ AbstractTemplateView :: renderSection(“Content”,数组| 1 |,FALSE)
Security_Development.log的底部看起来像这样,上面有很多类似的错误,所以我怀疑它与问题有关:
14-11-05 13:48:48 64.39.189.157 INFO Flow Access在资源“TYPO3_Neos_Backend_GeneralAccess”上被拒绝(0被拒绝,0被授予,1弃权) .
谢谢
1 回答
问题是你在
f:for
中用于as
的productArticle
被分配到此模板之前(在f:for
之外) . 所以例如在你的行动中你做了:你不能做
<f:for each="{messages}" as="message">
因为已经分配了message
. 使用像msg
或loopedMessage
这样的东西 .您可以在f:之外使用
<f:debug>
来检查productArticle是否为NULL .关于拒绝访问 - 当您向控制器添加新操作时,您必须刷新缓存 .