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
- Have an asset container with files
- If a file's meta YAML does not include
last_modified (e.g. incomplete meta generation)
- Browse the asset container in the Control Panel
- 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
Bug Description
Asset::lastModified()throws aTypeErrorwhen thelast_modifiedmeta value isnull. This can happen when an asset's meta cache does not contain alast_modifiedentry (e.g. the file was uploaded without metadata being fully generated, or the meta cache is stale/incomplete).Exception
File:
src/Assets/Asset.php:604Stack Trace
Steps to Reproduce
last_modified(e.g. incomplete meta generation)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