Review main Merged

95094[BUGFIX] Round simulated preview time up to full minutes

Dennis Bork CR +2 V +2 Normal +87 −3 updated 08/10/26, 13:19

Commit message

PreviewUriBuilder::getAdditionalQueryParametersForAccessRestrictedPages()
decides second-exact whether ADMCMD_simTime has to be added, while the
frontend evaluates page visibility against the 'accessTime' of the date
aspect, which has a precision of 60 seconds by design - see
PageRepository::getDefaultConstraints() and
SystemEnvironmentBuilder::initializeGlobalTimeTrackingVariables().

Due to that mismatch both branches fail for a 'starttime' carrying
seconds. With a 'starttime' of 09:13:21:

* At 09:13:45 the condition is false, no ADMCMD_simTime is emitted and
  the frontend compares 09:13:21 <= accessTime (09:13:00). The page is
  not found and the preview ends in a 404 with PAGE_NOT_FOUND.
* At 09:12:00 the condition is true and ADMCMD_simTime=09:13:21 is
  emitted, but PreviewSimulator::simulateDate() derives SIM_ACCESS_TIME
  as $queryTime - $queryTime % 60, which is 09:13:00 again and still
  below 'starttime' - a 404 as well.

The branch meant to compensate for a 'starttime' in the future can
therefore not succeed at all while the value carries seconds; the
preview only starts working once the clock passes 09:14:00. Editors hit
this without a way to see why, since 'starttime' is declared
format=datetime, whose picker neither displays nor allows editing
seconds, while its "Today" shortcut stores the live wall-clock second.

The simulated time is now rounded up to the first full minute the record
is live at. That is a no-op for every record with starttime % 60 === 0,
which is everything that works today, and no stored data is touched. The
'endtime' branch needs no adjustment: flooring endtime - 1 still
satisfies the endtime > accessTime constraint. The workspaces preview
uses the same method and benefits alike.

Functional tests are added for both failure modes, for the cases that
behave unchanged and for the 'endtime' branch, none of which had
coverage before.

This patch was created with the support of coding agents.

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Simon Schaufelberger +1
  • Verified V +2 Done
    • Benni Mack +2
    • Simon Schaufelberger +1
    • core-ci +1 CI

Issues 1

Files 2

Review log 1113

  1. Dennis Bork uploaded patch set 1 08/04/26, 05:49

  2. Dennis Bork commented on patch set 1 08/04/26, 05:58

    One deviation from the approach in my comment above, worth stating explicitly: the patch keeps @$GLOBALS['EXEC_TIME']@ instead of switching to @$GLOBALS['ACCESS_TIME']@. Once the simulated time is rounded up to a multiple of 60, the two comparisons are provably equivalent — for any minute-aligned @R@, @R > floor(now, 60)@ holds exactly when @R > now@ holds. Only the rounding is load-bearing, so the change in @Classes/@ stays at 13 lines. The @endtime@ branch is untouched, as announced.
  3. core-ci voted on patch set 1 V +1 08/04/26, 05:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/105922

  4. Simon Schaufelberger updated the commit message in patch set 2 V +1 08/04/26, 10:14

  5. Simon Schaufelberger voted on patch set 2 CR +1 V +1 08/04/26, 10:15

  6. core-ci voted on patch set 2 V +1 08/04/26, 10:22 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/105935

  7. Garvin Hicking commented on patch set 2 08/04/26, 12:52

    PreviewUriBuilder.php:570

    Just a note: For instances that set the TCA type of starttime to include seconds in the UI (which is possible) this should not prevent them from performing publishing based on a second. This code here only affects the PreviewUri building, where I'd argue a full-second-based publishing is "just fine".
  8. Dennis Bork commented on patch set 2 08/05/26, 05:42

    PreviewUriBuilder.php:570 Reply

    Agreed, and that is exactly the intent - no publishing capability is affected by this. The 60 second granularity is not introduced here: frontend visibility is evaluated against the 'accessTime' of the date aspect, which is EXEC_TIME - EXEC_TIME % 60 (see SystemEnvironmentBuilder::initializeGlobalTimeTrackingVariables() and DateTimeAspect, "60 seconds precision"). A record with a 'starttime' of 09:13:21 therefore goes live at 09:14:00 in the frontend, whether or not the instance exposes seconds in the TCA - the stored second simply has no effect on when the page becomes reachable. Rounding the simulated time up to that very moment is what makes the preview agree with the frontend again. An instance configured with seconds keeps precisely the publishing behaviour it has today; it only stops getting a 404 for records it cannot preview at all right now, since both branches fail while the value carries seconds. Rounding down would be the harmful direction and is a no-op anyway, as PreviewSimulator::simulateDate() floors the value again. Nothing changes for 'starttime' % 60 === 0, and no stored data is touched.
  9. Benni Mack commented on patch set 2 CR -1 08/06/26, 21:22

    I'll -1 this for the time being. There was a reason for the "% 60" back in 1998, the difference between ACCESS_TIME and EXEC_TIME and I think I need to clarify and look this up again. Hope that's OK. Thank you for fixing this issue.
  10. Dennis Bork commented on patch set 2 08/10/26, 10:56

    Reply

    No objection to taking the time - here is what the history says, in case it saves you the lookup. ACCESS_TIME / SIM_ACCESS_TIME are not from 1998, they were introduced on 2008-02-02 with commit fd5a82be21 by Martin Kutschker. The ChangeLog entry of that very commit names the reason: * #7351: Introduce $ACCESS_TIME/$SIM_ACCESS_TIME to improve Mysql query cache usage It added to t3lib/config_default.php: $ACCESS_TIME = $EXEC_TIME - ($EXEC_TIME % 60); // $ACCESS_TIME is a common time in minutes for access control $SIM_ACCESS_TIME = $ACCESS_TIME; // if $SIM_EXEC_TIME is changed this value must be set accordingly - both comments survive verbatim in SystemEnvironmentBuilder::initializeGlobalTimeTrackingVariables() today - and it switched the 'starttime'/'endtime' constraints in t3lib_pageSelect::init()/enableFields(), t3lib_BEfunc, t3lib_tstemplate and tslib_menu from SIM_EXEC_TIME to SIM_ACCESS_TIME. So the "% 60" is a query cache optimisation: a second-exact timestamp in the WHERE clause makes every statement string unique, so the MySQL query cache never hits, while a minute-aligned one keeps it stable for 60 seconds. It was never about access control semantics, and the accepted price was a publishing latency of up to 59 seconds. (Whether that rationale still carries - the MySQL query cache is gone as of MySQL 8.0 - is a separate question. This patch does not touch the granularity in either direction.) That history also explains the mismatch this patch is about. The preview parameters originate in BEfunc::ADMCMD_previewCmds(), which predates the commit above and compared second-exact from the start: if ($pageinfo['starttime']>time()) { $simTime = '&ADMCMD_simTime='.$pageinfo['starttime']; } which was consistent as long as the frontend evaluated against SIM_EXEC_TIME as well - the 2003 t3lib_pageSelect::init() did exactly that. The 2008 commit changed the consuming side only; the preview URI generation kept comparing against the raw execution time and still does today in PreviewUriBuilder::getAdditionalQueryParametersForAccessRestrictedPages(). The patch therefore does not introduce the minute granularity, it makes the producing side aware of the granularity the consuming side has had for 18 years. On EXEC_TIME vs ACCESS_TIME in the changed condition: the patch deliberately keeps EXEC_TIME. Once the simulated value is rounded up to a multiple of 60, the two are provably equivalent - for a minute-aligned R, "R > floor(now, 60)" holds exactly when "R > now" - so switching would be diff noise without any behavioural difference. Happy to wait for your lookup, and happy to answer whatever else comes out of it.
  11. Benni Mack commented on patch set 2 CR +1 08/10/26, 13:19

    Reply

    yeah, I actually wanted to check the whole DBMS part (which is indeed obsolete now). Not related to this change!
  12. Benni Mack voted on patch set 2 CR +2 V +2 08/10/26, 13:19

  13. Benni Mack merged patch set 3 08/10/26, 13:19