#110362Preview URI misses ADMCMD_simTime when starttime lies within the current minute
Description
Prerequisites
A page whose starttime lies inside the current minute, a few seconds in the past. In practice this happens routinely: when an editor clears the “Publish date” field and opens the picker, it preselects the current time including the running seconds, while the field itself only displays Y-m-d H:i.
Verified on 13.4.31, unchanged on branch 13.4 and on main. PHP 8.4, MariaDB.
Steps to reproduce
- Create a page with some content.
- Set its
starttimeto a timestamp a few seconds in the past, inside the current minute:UPDATE pages SET starttime = UNIX_TIMESTAMP() - 2 WHERE uid = 123; - Open the frontend preview of that page within the same minute — docheader “View webpage”, or Save + Preview from the record editing view.
Actual result
404 with the message “The requested page does not exist!” and failure reason PageAccessFailureReasons::PAGE_NOT_FOUND. The generated preview URI contains no ADMCMD_simTime parameter. Requesting the very same URL again after the minute boundary has passed succeeds.
Expected result
The page is previewable regardless of where inside the current minute its starttime lies.
Root cause
Producer and consumer of one and the same decision use different time bases.
PreviewUriBuilder::getAdditionalQueryParametersForAccessRestrictedPages() decides second-precise:
if ($access['starttime'] > $GLOBALS['EXEC_TIME']) {
if ($access['endtime'] < $GLOBALS['EXEC_TIME'] && $access['endtime'] !== 0) {
For a starttime a few seconds in the past this evaluates to false, so no ADMCMD_simTime is added.
The frontend visibility constraint in PageRepository::getDefaultConstraints() compares minute-floored: it builds starttime <= getPropertyFromAspect('date', 'accessTime', 0), and DateTimeAspect::get('accessTime') returns $timestamp - ($timestamp % 60), matching ACCESS_TIME = EXEC_TIME - EXEC_TIME % 60 in SystemEnvironmentBuilder.
For any starttime between floor(now, 60) and now — a window 0 to 59 seconds wide — the URI builder omits exactly the parameter the frontend requires. PageRepository::getPage($id, true) then returns an empty array, and PageInformationFactory::setPageAndRootline() raises PAGE_NOT_FOUND.
The processing of the parameter is consistent and not at fault. PreviewSimulator::simulateDate() does:
$GLOBALS['SIM_EXEC_TIME'] = $queryTime;
$GLOBALS['SIM_ACCESS_TIME'] = $queryTime - $queryTime % 60;
$this->context->setAspect('date', new DateTimeAspect(DateTimeFactory::createFromTimestamp($queryTime)));
So whenever the parameter is present, accessTime = floor(starttime) is less than or equal to starttime and the page is found. The defect is confined to the decision whether to add it.
A third time base is involved nearby: PreviewSimulator::checkIfPageIsHidden() evaluates starttime and endtime against $GLOBALS['SIM_EXEC_TIME'] (second precision). That is why hidden-page preview is correctly enabled for such a page — includeHiddenPages is set — while the visibility query still rejects it. The resulting 404 is therefore easily misdiagnosed as a hidden-page, permission or cookie problem.
Intended behaviour
That time-restricted pages are meant to be previewable by logged-in backend users is documented in the core itself:
PreviewSimulatorclass docblock: “used when simulating / previewing pages or content through query params when previewing access or time restricted content via for example backend preview links”PreviewSimulator::simulateDate()docblock: “When previewing a time restricted page from the backend, the parameter ADMCMD_simTime it added containing a timestamp with the time to preview. … it is only relevant for logged in backend users”PreviewUriBuilder, at the very condition in question: “simulate access time to ensure PageRepository will find the page and in turn PageRouter will generate a URL for it”
The mechanism is independent of EXT:adminpanel — PreviewSimulator resides in cms-frontend and PreviewUriBuilder in cms-backend, neither referencing cms-adminpanel. Confirmed in an installation without EXT:adminpanel, where previewing pages with a future start date works reliably. The intended path is therefore time simulation via the preview link, not an exemption from the visibility check — which is why the missing parameter, and not the check itself, is reported here.
Suggested fix
In both branches of getAdditionalQueryParametersForAccessRestrictedPages(), compare against the date aspect’s accessTime instead of $GLOBALS['EXEC_TIME'], so that the producer of the decision uses the consumer’s granularity.
Delimitation to existing issues
This is not about a starttime in the future and not about timezone conversion. Those cases work correctly today — the parameter is added and the preview succeeds:
- #85726 — timezone handling of
ADMCMD_simTime(server timezone vs. UTC), fixed in v8; the code no longer exists in that form - #92987 — docheader preview showed the root page for future start dates, resolved in 11.5.25
- #92944 — preview links broken for pages with start or end date outside the current date, closed
- #100008 — preview URLs wrong in most places for pages with
starttimeorendtime, closed
Related design context from #100008: PreviewUriBuilder was given a backend-specific VisibilityAspect(true, false, false, true) — including includeScheduledRecords — so that time-restricted pages remain resolvable during URI generation. ADMCMD_simTime is the frontend counterpart of that intent, and it is precisely this counterpart that is missing in the sub-minute window.
Additional notes
Observed in a production installation: a page saved with starttime = 09:13:21 returned a 404 for a preview request at 09:13:26 and rendered normally from 09:14:00 onwards. Reproduced against the unmodified record by evaluating PageRepository::getPage($uid, true) with accessTime = 09:13:00 (empty result) versus 09:14:00 (record found).
Independent of admin vs. non-admin backend users, of workspaces, of fe_group restrictions and of the page’s hidden state. Regular frontend visitors are affected by the same window, but for them the behaviour is consistent — they carry no ADMCMD_simTime and the page is simply not published yet. The defect is limited to the preview, which is supposed to compensate for exactly this.
Reviews 3
History 48
-
Garvin Hicking commented <span data-processor="relativetime" data-value="2026-08-03T14:19:08+00:00" > 08/03/26, 14:19 </span>
Yes, please push this contribution as a patch to gerrit so we can see the CI tests run on it. Please check if functional or unit patches need adoption, and ensure the code path changes are covered by tests. Please mention the patch was created with support of coding agents. Thanks for your effort!
-
Gerrit Code Review pushed patch set 1 for main to change 95094 status
NewUnder Review <span data-processor="relativetime" data-value="2026-08-04T05:49:21+00:00" > 08/04/26, 05:49 </span> -
Gerrit Code Review pushed patch set 2 for main to change 95094 <span data-processor="relativetime" data-value="2026-08-04T10:14:29+00:00" > 08/04/26, 10:14 </span>
-
Gerrit Code Review pushed patch set 1 for 14.3 to change 95203 <span data-processor="relativetime" data-value="2026-08-10T13:20:11+00:00" > 08/10/26, 13:20 </span>
-
Gerrit Code Review pushed patch set 1 for 13.4 to change 95204 <span data-processor="relativetime" data-value="2026-08-10T13:20:19+00:00" > 08/10/26, 13:20 </span>
-
Dennis Bork commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2026-08-10T13:25:10+00:00" > 08/10/26, 13:25 </span>Applied in changeset commit:afb9acb62d9fc33d6b682d924da6bc7fe64b57c5.
-
Benni Mack changed status
ResolvedClosed <span data-processor="relativetime" data-value="2026-08-11T08:51:57+00:00" > 08/11/26, 08:51 </span>
A follow-up from the discussion in #110363: the root cause here also produces a second failure mode that the title doesn’t cover. Whenever `starttime % 60 !== 0`, the preview is broken in both branches, not only when the `starttime` lies within the current minute.
The reason is that `PreviewUriBuilder` compares second-exact while the frontend evaluates against `DateTimeAspect::accessTime`, which is floored to 60 s by design (`PageRepository::getDefaultConstraints()`):
With `starttime = 09:13:21`:
- At 09:13:45 the condition is false, so no `ADMCMD_simTime` is emitted at all. The frontend compares `09:13:21 <= accessTime (09:13:00)` → page not found → 404. This is the case in the title.
- At 09:12:00 the condition is true and `ADMCMD_simTime = 09:13:21` is emitted — but `PreviewSimulator::simulateDate()` sets `SIM_ACCESS_TIME = $queryTime – $queryTime % 60`, i.e. 09:13:00, which is again below `starttime` → still 404.
So the branch that exists specifically to compensate for a future `starttime` cannot succeed for any `starttime` carrying seconds; the preview only starts working once the clock passes 09:14:00. Since `type=datetime` with `format=datetime` stores seconds that the picker never shows (see #110363), editors hit this without any way to see why.
Rounding the simulated time up to the first minute boundary at which the record is actually live fixes both cases. Note that the minute-floored current time is already available as `$GLOBALS[‘ACCESS_TIME’]`, set right next to `EXEC_TIME` in `SystemEnvironmentBuilder::initializeGlobalTimeTrackingVariables()`:
This is a behavioural no-op for every record with `seconds = 0`, i.e. everything that works correctly today: the rounding leaves the value untouched, and comparing against `ACCESS_TIME` instead of `EXEC_TIME` only differs within the minute that is currently broken. Nothing in stored data changes.
The `endtime` branch below needs no adjustment — flooring `endtime – 1` still lands above the `endtime > accessTime` constraint.
Happy to push this to Gerrit if the approach looks right to you.