Skip to content

TypeError in Asset::lastModified() when last_modified meta is null #14529

@v-Woody

Description

@v-Woody

Bug Description

Asset::lastModified() throws a TypeError when the last_modified meta value is null. This can happen when an asset's meta cache does not contain a last_modified entry (e.g. the file was uploaded without metadata being fully generated, or the meta cache is stale/incomplete).

Exception

TypeError: Carbon\Carbon::createFromTimestamp(): Argument #1 ($timestamp) must be of type string|int|float, null given

File: src/Assets/Asset.php:604

Stack Trace

Carbon\Carbon::createFromTimestamp() at vendor/nesbot/carbon/src/Carbon/Traits/Timestamp.php:30
Statamic\Assets\Asset->lastModified() at vendor/statamic/cms/src/Assets/Asset.php:604

Steps to Reproduce

  1. Have an asset container with files
  2. If a file's meta YAML does not include last_modified (e.g. incomplete meta generation)
  3. Browse the asset container in the Control Panel
  4. The CP returns a 500 error

Expected Behavior

lastModified() should gracefully handle a null value and fall back to a sensible default (e.g. epoch 0) instead of throwing a TypeError.

Environment

  • Statamic: v6.14.0
  • PHP: 8.5
  • Laravel: 13

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions