Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge release 3.5.1 into 3.6.x #76

Merged
merged 6 commits into from
Dec 3, 2021
Merged

Conversation

github-actions[bot]
Copy link

@github-actions github-actions bot commented Dec 3, 2021

Release Notes for 3.5.1

3.5.x bugfix release (patch)

3.5.1

  • Total issues resolved: 0
  • Total pull requests resolved: 1
  • Total contributors: 1

Bug

weierophinney and others added 6 commits December 2, 2021 15:28
…or access log request representations

AccessLogFormatter calls on AccesLogDataMap to format a number of strings, including request times; these are generally used in cookies and/or header values.
Previously, we used `strftime()` to format date/time values.
However, this is deprecated starting in PHP 8.1, with the recommendation of using `IntlDateFormatter` for purposes of formatting date/time strings in a locale-specific way.
Because I'm unclear on whether the formats will always come from internal classes, or if they might come from external sources (e.g., cookie values), I've created a new final class, `Mezzio\Swoole\StrftimeToICUFormatMap` for mapping strftime formats to the ICU equivalents.
I've added some basic tests for the class, which include demonstrating that the formats we use internally all get translated correctly.
I've also added a test case for `AccessLogDataMap::getRequestTime()` to demonstrate that it generates the same values.

Targeting the 3.5 series, as this is technically a bug in our PHP 8.1 support.

Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
Since an ICU format can contain additional characters, we can wrap the returned format in the `[]` characters via concatenation instead.

Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
…in tests

Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
The StrftimeToICUFormatMap case for `%s` was calling `return time()`, which (a) was the incorrect type (a string should be returned), and (b) could lead to a mismatch between the request time and what is reported in the logs.

StrftimeToICUFormatMap::mapStrftimeToICU now accepts a second argument, a DateTimeInterface $requestTime, and this is used when `%s` is in the format.
AccessLogDataMap::getRequestTime creates a DateTimeImmutable instance from the server $request_time_float property and passes that value to StrftimeToICUFormatMap.

Creation of the callback for preg_replace_callback has been moved to another method, based on issues reported by Psalm; the callback now has full typehinting as well.

Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
Fix deprecation in request time formatting for access logs
@Ocramius Ocramius self-assigned this Dec 3, 2021
@Ocramius Ocramius added the Bug Something isn't working label Dec 3, 2021
@Ocramius Ocramius added this to the 3.6.0 milestone Dec 3, 2021
@Ocramius Ocramius merged commit b157b2c into 3.6.x Dec 3, 2021
@Ocramius Ocramius deleted the 3.5.x-merge-up-into-3.6.x_ndzBkaTi branch December 3, 2021 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants