0

如何调试此异常?它位于显示最近查看的项目的部分中,该部分位于显示单个项目的页面上。两个部分的模板在 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><br />

            </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(数组|5|,闭包,TYPO3\Fluid\Core\Rendering\RenderingContext) 113 {closure}() 112 TYPO3\Fluid\Core\ViewHelper\AbstractConditionViewHelper::renderThenChild() 111 TYPO3\Fluid\ViewHelpers\IfViewHelper_Original::render( TRUE) 110 call_user_func_array(array|2|, array|1|) 109 TYPO3\Fluid\Core\ViewHelper\AbstractViewHelper::callRenderMethod() 108 TYPO3\Fluid\Core\ViewHelper\AbstractViewHelper::initializeArgumentsAndRender() 107 FluidCache_Mycompany_Store_Product_action_recentlyViewedProducts_1f6458e2b69625fca8d5707e4161562d5d061770::section_4f9be057f0ea5d2ba72fd2c810e8d7b9aa98b469(TYPO3\Fluid\Core\Rendering\RenderingContext)106 TYPO3\Fluid\View\AbstractTemplateView::renderSection(“内容”,数组|1|,假)

Security_Development.log 的底部看起来像这样,上面有许多类似的错误,所以我怀疑它与问题有关:

14-11-05 13:48:48 64.39.189.157
对资源“TYPO3_Neos_Backend_GeneralAccess”的信息流访问被拒绝(0 拒绝,0 授予,1 弃权)。

谢谢

4

1 回答 1

3

问题是productArticle您用于asin的内容f:for之前已分配给此模板(外部f:for)。因此,例如,在您执行操作时:

$this->view->assignMultiple(array(
        'message' => 'xxx',
        'messages' => $messages,
));

你不能这样做<f:for each="{messages}" as="message">,因为message已经分配了。使用类似msgloopedMessage..

您可以使用<f:debug>外部 f:for 检查您的 productArticle 是否为 NULL。

关于拒绝访问 - 当您向控制器添加新操作时,您必须刷新缓存。

于 2014-11-06T08:17:16.913 回答