Search code examples
phpcachingtypo3extbaserealurl

Typo3 realurl issue - view not updating


I created a very simple typo3 extension with just one model and one controller.

These are the only actions in the controller:

/**
 * action list
 *
 * @return void
 */
public function listAction()
{
    $projects = $this->projectRepository->findAll();
    $this->view->assign('projects', $projects);
}

/**
 * action show
 *
 * @param \Typo3\Productoverview\Domain\Model\Project $project
 * @return void
 */
public function showAction(\Typo3\Productoverview\Domain\Model\Project $project)
{
    $this->view->assign('project', $project);
}


Then I created a folder and added a plugin element:

enter image description here

Afterwards I placed the plugin itself on the front page and included the folder.

With RealURL configuration I managed to shorten the show action URL:

<?php
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']= array (
  'local.typo3' => array (
    'init' => array (
      'enableCHashCache' => 1,
      'appendMissingSlash' => 'ifNotFile, redirect',
      'adminJumpToBackend' => 1,
      'enableUrlDecodeCache' => 1,
      'enableUrlEncodeCache' => 1,
      'emptyUrlReturnValue' => '/',
    ),
    'postVarSets' => array (
      '_DEFAULT' => array (
        'project' => array (
          array (
            'GETvar' => 'tx_productoverview_projects[action]',
          ),
          array (
            'GETvar' => 'tx_productoverview_projects[project]',
          ),
        ),
      ),
    ),

    ...


What is the problem?
If I click now on the link of one list element on the front page, it changes the URL in the browser bar, but does not redirect me. I need to refresh the page with Control + F5 to get to the project view or to get then again back to the front page (even if I change the URL in the browser manually).

enter image description here

I am working with Typo3 7.6.10 and realurl 2.0.15.


Update

If I use the cHash in the realurl_conf.php it works properly:

      array (
        'GETvar' => 'cHash',
      ),

How to work without cHash? I mean 'enableCHashCache' is activated..


Update 2

One possible solution is to disable the caching for the list action, but I'm not sure if this is the way to go:

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'ET.' . $_EXTKEY,
'Projects',
array(
    'Project' => 'list, show',

),
// non-cacheable actions
array(
    'Project' => 'list',

)
);

Solution

  • Known issue - explained on https://github.com/dmitryd/typo3-realurl/issues/244

    TL;DR: fix cHash inclusion in every link on your site. Not the configuration but where the link gets generated, in every place links get generated!