Skip to content

Conversation

@simonerd
Copy link
Contributor

In one of our customer projects that we finally were allowed to update to v5 we encountered an error when saving certain entries:

Carbon\Carbon::createFromTimestamp(): Argument #1 ($timestamp) must be of type string|int|float, null given, called in /var/www/html/vendor/statamic/cms/src/Data/TracksLastModified.php on line 15

On closer inspection it turned out that the affected entries have updated_at: null in their data. I currently can't quite figure out why that is the case, but this causes a problem in TracksLastModified::lastModified():

public function lastModified()
{
    return $this->has('updated_at')
        ? Carbon::createFromTimestamp($this->get('updated_at'), config('app.timezone'))
        : $this->fileLastModified();
}

The entry has updated_at, but it is null, causing the Carbon error.

This PR simply changes the lastModified() function (and lastModifiedBy() too, for good measure) to not just check if the key is there, but also if its truthy.

@jasonvarga jasonvarga merged commit 40d34b1 into statamic:5.x Nov 19, 2025
25 checks passed
@simonerd simonerd deleted the fix-tracks-last-modified branch November 20, 2025 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants