Skip to content

“Attempt to assign property "newmessage6089" on null” because of a corrupted repository? #83

@alexislefebvre

Description

@alexislefebvre

Our error log showed this:

Attempt to assign property "newmessage6089" on null

I'm pretty sure that the error comes from these lines:

// First token for this key
$storageInstance->{$key} = [$value];

And

$file = file_get_contents($this->storage);
return json_decode($file);

It looks like json_decode returned null because the file wasn't a valid JSON (sadly we didn't saved the file because we were in a rush to fix the issue).

The code may check that the content is a valid JSON before returning it:

$file = file_get_contents($this->storage);

try {
    return json_decode($file, null, 16, JSON_THROW_ON_ERROR);
} catch (\JsonException $e) {
    return([]);
}

It would start on a fresh repository, I think it's the safest option.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions