Issue Bug Closed

#82528SYS_LASTCHANGED value not being correctly set if RESTORE_REGISTER is used

Presedo Roberto 09/21/17, 09:48 updated 12/02/25, 14:36

Description

Each time TYPO3 renders a content element, it stores its timestamp value in SYS_LASTCHANGED in the REGISTER, keeping it warm until the end of the page rendering process
-> in \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::lastChanged

and then saving then value in the DB.
-> in \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::setSysLastChanged

If you use RESTORE_REGISTER cObject in your TS, it will reset the Register, setting it back to the previous values
-> in \TYPO3\CMS\Frontend\ContentObject\RestoreRegisterContentObject::render

So if RESTORE_REGISTER is used in a TYPOSCRIPT, the registered SYS_LASTCHANGED value is reset before being stored in the DB, so SYS_LASTCHANGED updates are may never be saved in DB.

SYS_LASTCHANGED temp value should not be set in Register in order to avoid it being reset.

Reviews 1

Files 3

History 2127

Show 2 earlier messages
  1. Guillaume Germain commented and changed target version <span data-processor="relativetime" data-value="2020-01-22T18:13:41+00:00" > 01/22/20, 18:13 </span>

    This bug also exists in TYPO3 9.5.13.

    There is a problem with the Introduction Package because the “bootstrap_package” extension uses “RESTORE_REGISTER” in lib.dynamicContent.

  2. Guillaume Germain commented and changed category <span data-processor="relativetime" data-value="2020-01-22T18:16:48+00:00" > 01/22/20, 18:16 </span>

    It concerns the TypoScriptFrontendController class.

  3. Petra Neumann commented <span data-processor="relativetime" data-value="2020-10-30T16:24:04+00:00" > 10/30/20, 16:24 </span>

    The problem still exists in TYPO3 v10.

    If any RESTORE_REGISTER is called, the temp value for SYS_LASTCHANGED is gone. Since ext:fluid_styled_content suggests using RESTORE_REGISTER for inserting content in the page template based on FLUIDTEMPLATE (see lib.dynamicContent), a lot of site-package extensions make use of it (like the bootstrap package). So in many TYPO3 installations SYS_LASTCHANGED is only updated for changes of the page properties but not the page content. This might be a problem, since the ContentObjectRenderer.php reads “The SYS_LASTCHANGED timestamp can be used by various caching/indexing applications to determine if the page has new content.” – which will not work as intended then. Also, some sites use SYS_LASTCHANGED to show a “Last Updated on …”, even though it is not intended for that originally – this also fails with the value not being written correctly.

  4. Reindl Bernd commented and changed attached RestoreRegisterContentObject.php <span data-processor="relativetime" data-value="2021-05-28T07:03:23+00:00" > 05/28/21, 07:03 </span>

    If ‘SYS_LASTCHANGED’ is stored outside the $register variable, it’s no longer available via ‘data = register:SYS_LASTCHANGED’ in TypoScript.

    Quick solution:


    public function render($conf = []) {
    $SYS_LASTCHANGED = isset($GLOBALS['TSFE']->register['SYS_LASTCHANGED']) ? $GLOBALS['TSFE']->register['SYS_LASTCHANGED'] : false;
    $GLOBALS['TSFE']->register = array_pop($GLOBALS['TSFE']->registerStack);
    if($SYS_LASTCHANGED !== false)
    $GLOBALS['TSFE']->register['SYS_LASTCHANGED'] = $SYS_LASTCHANGED;
    return '';
    }

    So ‘SYS_LASTCHANGED’ is still available in register but is not restored when RESTORE_REGISTER is called.

  5. Daniel Gohlke commented and changed TYPO3 Version 8 10 <span data-processor="relativetime" data-value="2021-05-31T11:54:19+00:00" > 05/31/21, 11:54 </span>

    We have been able to successfully test this change in a current TYPO3 v10.4.

  6. Anonymous commented <span data-processor="relativetime" data-value="2021-09-02T10:39:45+00:00" > 09/02/21, 10:39 </span>

    Daniel Lorenz wrote in #note-8:
    > We have been able to successfully test this change in a current TYPO3 v10.4.

    We have the same problem. Especially with indexed_search which does not recognize changes to the page content.

    Quickfix successfully tested under 10.4

  7. Sebastian Schmal commented and changed TYPO3 Version 10 11 PHP Version 7.0 7.4 <span data-processor="relativetime" data-value="2022-01-18T21:28:07+00:00" > 01/18/22, 21:28 </span>

    same problem with the ext:seo (TYPO3 11.x)

    typo3\sysext\seo\Classes\XmlSitemap\PagesXmlSitemapDataProvider.php

    ‘lastMod’ => (int)($page[‘SYS_LASTCHANGED’] ?: $page[‘tstamp’]),

    but the field “SYS_LASTCHANGED” have a old timestamp in the DB.

    the field “tstamp” is right, but the ext:seo take the SYS_LASTCHANGED

    Yes, it update the page, like this https://forge.typo3.org/issues/90827#note-1 (only updated in the frontend), but why?

  8. Oliver Pfaff commented and changed attached BUGFIX_core_bug__forge_typo3_org_issues_82528.patch <span data-processor="relativetime" data-value="2024-03-15T15:24:01+00:00" > 03/15/24, 15:24 </span>

    This seems still a thing. Here a new Patchfile for TYPO3 11, it uses the same solution from Reindl Bernd but avoids the usage of the $GLOBALS like the implementation in V11

    Probably the bug is still inside v12 as well, i didn’t test this. RestoreRegisterContentObject in v12 is the same as in v11 but maybe a different or better solution was found.

  9. Marc Hirdes commented <span data-processor="relativetime" data-value="2024-06-17T12:53:17+00:00" > 06/17/24, 12:53 </span>

    The patch works as it should. Is it possible to update the core?

  10. Florian Windisch commented and changed attached BUGFIX_core_bug__forge_typo3_org_issues_82528_v11_5_39.patch <span data-processor="relativetime" data-value="2024-09-02T08:27:15+00:00" > 09/02/24, 08:27 </span>

    Oliver Pfaff wrote in #note-12:
    > This seems still a thing. Here a new Patchfile for TYPO3 11, it uses the same solution from Reindl Bernd but avoids the usage of the $GLOBALS like the implementation in V11
    >
    > Probably the bug is still inside v12 as well, i didn’t test this. RestoreRegisterContentObject in v12 is the same as in v11 but maybe a different or better solution was found.

    We just recently did a composer update on our v11 systems and the patch couldn’t apply.
    cms-frontend updated to v11.5.39 and in that version RestorRegisterContentObject.php got changed.
    On line 33 they added a null coalesce operator for the array_pop.

    public function render($conf = [])
    {
        $frontendController = $this->getTypoScriptFrontendController();
        $frontendController->register = array_pop($frontendController->registerStack) ?? [];
        return '';
    }

    Attached is a new patch file that supports v11.5.39, from what i can tell this should also apply to v12.4.18 and above.

  11. Marya Hachimi commented <span data-processor="relativetime" data-value="2024-09-27T17:28:03+00:00" > 09/27/24, 17:28 </span>

    Hello, this bug also occurs in TYPO3 versions 11.5.39 and 12.4.20. Has the patch been considered by the team? If not yet, is there a merge request addressing it? Do you plan to fix it soon?
    Thank you!

  12. Simon Child commented and changed TYPO3 Version 11 12 PHP Version 7.4 8.1 <span data-processor="relativetime" data-value="2024-10-19T13:37:40+00:00" > 10/19/24, 13:37 </span>

    I’m experiencing this bug still present on an Introduction package / bootstrap_package / TYPO3 website

    • TYPO3 12.4.22
    • bootstrap_package 15.0.0

    The xml sitemap does not update when page content is updated.

    After applying the patch from https://forge.typo3.org/issues/82528#note-14 the sitemap does update

  13. Eric Harrer commented <span data-processor="relativetime" data-value="2025-08-10T21:27:50+00:00" > 08/10/25, 21:27 </span>

    I can confirm this for TYPO3 12.4.34. In TYPO3 13.4.15 this problem no longer occurs. The test setup consisted of my own sitepackage, which has the same structure in both version 12 and 13 with regard to the use of RESTORE_REGISTER in TypoScript.

  14. Christian Kuhn commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2025-10-07T10:25:09+00:00" > 10/07/25, 10:25 </span>

    Applied in changeset commit:575bd35ecc7d266a9f973413b61031d0f88b1961.