Skip to content

Incorrect type coercion in ActionContent::formatDateValues() #120

Description

@Muffinman

Package Version

v2.0.0

Laravel Version

v11.45.3

PHP Version

PHP 8.3.24

Problem description

When you have a boolean attribute value which has changed, the system incorrectly converts it into a date in the display.

> Spatie\Activitylog\Models\Activity::find(7482)->changes();
= Illuminate\Support\Collection {#7914
    all: [
      "attributes" => [
        "user_id" => 58,
        "user.email" => "test@example.com",
        "customer_id" => 71,
        "customer.name" => "Test",
        "access_all_sites" => false,
      ],
    ],
  }
Image

This is caused by the type coercion in https://github.com/rmsramos/activitylog/blob/main/src/Actions/Concerns/ActionContent.php#L340

If a boolean is passed into here it gets converted into one of the other acceptable types. In the case of a FALSE value it seems to be converted to a string, which is subsequently interpreted as a date.

PR incoming.

Expected behavior

Booleans should render true/false correctly.

Steps to reproduce

  1. Store activity log against a model with a boolean property.
  2. Set the property to FALSE.
  3. Look at the activity log view in Filament.

Reproduction repository (issue will be closed if this is not valid)

https://github.com/rmsramos/activitylog

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions