Time::getRequestTime is not immutable when there is no request

Created on 2 July 2023, about 1 year ago
Updated 12 September 2023, 12 months ago

Problem/Motivation

Time::getRequestTime() and Time::getRequestMicroTime() are meant to return the same value during the life of a request. That is meant to be the time the HTTP request was made to the server.

However, when there is no request object available, and no global REQUEST_TIME variable defined, which can be a case for unit tests, the code falls back to calling ::getCurrentTime(), which differs each time is called - and fails the original purpose.

Steps to reproduce

See test in the MR.

Proposed resolution

  • Add a property to Time that would be stored with a time value when no request info is available, and return that value across any subsequent calls.
  • Make the RequestStack argument to the constructor optional for those cases when a request stack is not available yet or at all.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Fixed

Version

11.0 🔥

Component
Base 

Last updated 1 minute ago

Created by

🇮🇹Italy mondrake 🇮🇹

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024