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

Commits on Dec 2, 2021

  1. fix: autoconvert strftime formats to ICU, and use IntlDateFormatter f…

    …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>
    weierophinney committed Dec 2, 2021
    Configuration menu
    Copy the full SHA
    3190046 View commit details
    Browse the repository at this point in the history

Commits on Dec 3, 2021

  1. fix: mark StrftimeToICUFormatMap internal

    Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
    weierophinney committed Dec 3, 2021
    Configuration menu
    Copy the full SHA
    cda68e9 View commit details
    Browse the repository at this point in the history
  2. refactor: remove unneeded sprintf

    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>
    weierophinney committed Dec 3, 2021
    Configuration menu
    Copy the full SHA
    e259bbd View commit details
    Browse the repository at this point in the history
  3. qa: suppress errors due to usage of @internal StrftimeToICUFormatMap …

    …in tests
    
    Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
    weierophinney committed Dec 3, 2021
    Configuration menu
    Copy the full SHA
    22c7e99 View commit details
    Browse the repository at this point in the history
  4. fix: pass DateTimeImmutable instead of calling time()

    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>
    weierophinney committed Dec 3, 2021
    Configuration menu
    Copy the full SHA
    3e47454 View commit details
    Browse the repository at this point in the history
  5. Merge pull request #75 from weierophinney/hotfix/strftime-deprecated

    Fix deprecation in request time formatting for access logs
    Ocramius authored Dec 3, 2021
    Configuration menu
    Copy the full SHA
    67de950 View commit details
    Browse the repository at this point in the history