Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

Simple formatter broken with non-array value extra array key in PHP > 8 #38

Closed
misterabdul opened this issue Jul 22, 2022 · 3 comments
Closed
Assignees
Labels
Bug Something isn't working
Milestone

Comments

@misterabdul
Copy link
Contributor

Bug Report

Q A
Version(s) 2.15.1

Summary

Simple formatter broken with non-array value extra array key when using PHP version 8++.

How to reproduce

        $date   = new DateTime('2012-08-28T18:15:00Z');
        $fields = [
            'timestamp'    => $date,
            'message'      => 'foo',
            'priority'     => 42,
            'priorityName' => 'bar',
            'extra'        => null,
        ];
        $formatter = new Simple();
        echo $formatter->format($fields);
        // Throws error: TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given

        $date   = new DateTime('2012-08-28T18:15:00Z');
        $fields = [
            'timestamp'    => $date,
            'message'      => 'foo',
            'priority'     => 42,
            'priorityName' => 'bar',
            'extra'        => '',
        ];
        $formatter = new Simple();

        echo $formatter->format($fields);
        // Throws error: TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given

Expected behavior

        $date   = new DateTime('2012-08-28T18:15:00Z');
        $fields = [
            'timestamp'    => $date,
            'message'      => 'foo',
            'priority'     => 42,
            'priorityName' => 'bar',
            'extra'        => null,
        ];
        $formatter = new Simple();
        echo $formatter->format($fields);
        // Output: 2012-08-28T18:15:00+00:00 bar (42): foo

        $date   = new DateTime('2012-08-28T18:15:00Z');
        $fields = [
            'timestamp'    => $date,
            'message'      => 'foo',
            'priority'     => 42,
            'priorityName' => 'bar',
            'extra'        => '',
        ];

        $formatter = new Simple();
        echo $formatter->format($fields);
        // Output: 2012-08-28T18:15:00+00:00 bar (42): foo
@misterabdul misterabdul added the Bug Something isn't working label Jul 22, 2022
@laminas-bot
Copy link
Contributor

This package is considered feature-complete, and is now in security-only maintenance mode, following a decision by the Technical Steering Committee.
If you have a security issue, please follow our security reporting guidelines.
If you wish to take on the role of maintainer, please nominate yourself

If you are looking for an actively maintained package alternative, we recommend:

@Ocramius Ocramius reopened this Jul 22, 2022
@Ocramius
Copy link
Member

Reopened, since this is a bugfix

@Ocramius Ocramius added this to the 2.15.2 milestone Jul 22, 2022
Ocramius pushed a commit to Ocramius/laminas-log that referenced this issue Jul 22, 2022
Ocramius added a commit that referenced this issue Jul 22, 2022
@Ocramius Ocramius self-assigned this Jul 22, 2022
@Ocramius
Copy link
Member

Handled in 178b850

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants