vhs icon indicating copy to clipboard operation
vhs copied to clipboard

When using EXT:frontend_editing and clicking on "show hidden content" an exception appears

Open erredeco opened this issue 4 years ago • 12 comments

I found this error when using EXT:frontend_editing and clicking on the "show hidden content element" icon:

Schermata 2020-01-23 alle 23 25 21

An exception appears:

(1/1) #1384611413 TYPO3Fluid\Fluid\Core\ViewHelper\Exception
No record was found. The "record" or "uid" argument must be specified.

in /Siti/typo3.9.demo.it/public/typo3conf/ext/vhs/Classes/Utility/ErrorUtility.php line 25

     */
    public static function throwViewHelperException($message = null, $code = null)
    {
        if (version_compare(TYPO3_version, '8.0', '>=')) {
            throw new \TYPO3Fluid\Fluid\Core\ViewHelper\Exception($message, $code);
        }
        throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception($message, $code);
    }
}

at FluidTYPO3\Vhs\Utility\ErrorUtility::throwViewHelperException('No record was found. The "record" or "uid" argument must be specified.', 1384611413)

...

Are the two extensions incompatible?

erredeco avatar Jan 23 '20 22:01 erredeco

@erredeco If possible, can you provide the full stack trace of the error? This would tell me which ViewHelper is used and I can look further into why it receives an empty record.

NamelessCoder avatar Jan 24 '20 09:01 NamelessCoder

vhs-issue.pdf

Is it good for you or do you need a different document?

about the viewhelpers used... scattered inside my page partials I use <v:page.breadCrumb>, <v:menu.directory>, <v:menu>, <v:content.render>, : <v:menu.browse> , <v:page.resources.fal> and <v:page.header>

erredeco avatar Jan 24 '20 10:01 erredeco

That should help - thanks!

NamelessCoder avatar Jan 24 '20 10:01 NamelessCoder

It seems that the problem comes from <v:page.resources.fal> it is used here:

EXT:bhsiteconf/Resources/Private/Partials/Page/Megamenu.html

<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
      xmlns:v="http://typo3.org/ns/FluidTYPO3/Vhs/ViewHelpers"
      data-namespace-typo3-fluid="true">

<div class="accordion-group">
    <v:menu entryLevel="0" levels="1" expandAll="1" >
      
        <f:for each="{menu}" as="item">

        <f:variable name="alt_thumbnail">
            <v:page.resources.fal table="pages" field="nav_thumbnail" uid="{item.uid}" as="images">{images.0.alternative}</v:page.resources.fal>
        </f:variable>


        <f:variable name="description_thumbnail">
            <v:page.resources.fal table="pages" field="nav_thumbnail" uid="{item.uid}" as="images">{images.0.description}</v:page.resources.fal>
        </f:variable>



            <f:if condition="{item.hasSubPages}">
                <div class="collapse dropdown-mega collapsetoggle" id="a{item.uid}" aria-labelledby="al-{item.uid}">
                    <div class="container--extrawide">
                        <f:if condition="{item.nav_thumbnail}">
                            <div class="dropdown-mega__image-text-container">
                                <img class="dropdown-mega__image img-fluid" src="{f:uri.image(src:item.nav_thumbnail,treatIdAsReference:1,cropVariant:'default',width:'335')} " alt="{alt_thumbnail}" />

                                <f:if condition="{description_thumbnail}">
                                    <div class="dropdown-mega__text">
                                        <p>{description_thumbnail}</p>
                                    </div>                                    
                                </f:if>
                            </div>
                        </f:if>
   
                        <div class="dropdown-mega__menu-container">
                            <v:menu pageUid="{item.uid}" includeSpacers="1" classActive="menu__item--active" classCurrent="menu__item--active" classHasSubpages="">    
                                <ul class="menu menu--mega">  
                                    <f:for each="{menu}" as="subItem">
                                        <f:if condition="{subItem.doktype} == 199">
                                            <f:then>
                                                </ul><!--separatore--><ul class="menu menu--mega">  
                                            </f:then>
                                            <f:else>
                                                <li class="menu__item {subItem.class}">
                                                    <f:link.page pageUid="{subItem.uid}" title="{subItem.linktext}">{subItem.linktext}</f:link.page>
                                                </li>
                                            </f:else>
                                        </f:if>
                                    </f:for>           
                                </ul>
                            </v:menu>  
                        </div>
                    </div>
                </div>
            </f:if>
        </f:for>
    </v:menu>
</div>

</html>

erredeco avatar Jan 24 '20 10:01 erredeco

First part of the puzzle is here: https://github.com/FluidTYPO3/vhs/blob/development/Classes/ViewHelpers/Page/Resources/FalViewHelper.php#L66

VHS uses the default TSFE page repository instance to retrieve records. I'll check how frontend_editing manipulates the repository to achieve "show hidden content".

NamelessCoder avatar Jan 24 '20 10:01 NamelessCoder

Please check if the following changes the behavior:

  • Hit the page in FE with show hidden enabled to get the error
  • In BE, flush all caches
  • Hit the page again

If the error disappears that points to a problem in frontend_editing. If the error is still there it points to an issue with the Visibility Context not being used by PageRepository which could be a TYPO3 bug.

NamelessCoder avatar Jan 24 '20 11:01 NamelessCoder

Possible workaround - change:

<v:page.resources.fal table="pages" field="nav_thumbnail" uid="{item.uid}" as="images">{images.0.alternative}</v:page.resources.fal>

To:

<v:page.resources.fal table="pages" field="nav_thumbnail" record="{item}" as="images">{images.0.alternative}</v:page.resources.fal>

This should prevent querying the PageRepository to load the record (and avoids an additional SQL request so it's recommended regardless of the error).

NamelessCoder avatar Jan 24 '20 11:01 NamelessCoder

I tried the following:

  1. flushed all caches from Install Tool
  2. Hide a content element on a page (but is not important, the error comes out anyway)
  3. Visit the page on frontend (frontend_editing active)
  4. Clicked on the orange button "show hidden content"

Result: Exception is shown

  1. Go back to backend, install tool > flush all caches
  2. Go back to frontend, click on the page on the right panel of frontend_editing with the pagetree

Result: the page is reloaded, but it loses the "show active content" state (reloading disables the functionality)

I also tried adding config.no_cache=1 but without any change

erredeco avatar Jan 24 '20 11:01 erredeco

There may be two possible causes that I can see:

  1. frontend_editing sets fePreview = 0 on TSFE and this may override the Visibility Aspect (source: https://github.com/FriendsOfTYPO3/frontend_editing/blob/master/Classes/Hook/FrontendEditingInitializationHook.php#L116). Setting this value to (int) GeneralUtility::_GET('show_hidden_items') may solve it if that is the cause.
  2. PageRepository of TYPO3 does not respect TSFE->fe_user->showHiddenRecords or it overwrites the Visiblilty Aspect of the Context based on this value.

(you've got a typo in one of the two v:page.resources.fal instances, looks like "recond" was typed instead of "record").

NamelessCoder avatar Jan 24 '20 11:01 NamelessCoder

<v:page.resources.fal table="pages" field="nav_thumbnail" record="{item}" as="images">{images.0.alternative}</v:page.resources.fal>

It actually solved the problem :/

erredeco avatar Jan 24 '20 11:01 erredeco

Yep the workaround solves it by avoiding PageRepository - but other third party code may be equally affected if it tries to read records via TSFE->sys_page which appears to be misconfigured when frontend_editing overrides the Visibilty. I would report this to both TYPO3 and frontend_editing and refer to this thread for background info!

The good news is that this doesn't appear to be a problem caused by VHS ;)

NamelessCoder avatar Jan 24 '20 11:01 NamelessCoder

thanks for your assist, I will do :)

erredeco avatar Jan 24 '20 11:01 erredeco