Skip to content

Fix backup cache handling when JSON decode returns null#2105

Open
Dominik0101 wants to merge 1 commit intonextcloud:masterfrom
Dominik0101:fix-backup-cache-null
Open

Fix backup cache handling when JSON decode returns null#2105
Dominik0101 wants to merge 1 commit intonextcloud:masterfrom
Dominik0101:fix-backup-cache-null

Conversation

@Dominik0101
Copy link
Copy Markdown

The backups page can crash when the cache file contains invalid or empty JSON.

This happens because json_decode($cache_str, true) may return null.
The previous implementation used or [ ], which does not assign the fallback array as intended due to PHP operator precedence.

This patch ensures that $cache is always initialized as an array:

  • If json_decode returns a valid array, it is used
  • Otherwise, $cache falls back to an empty array

This prevents runtime errors when accessing the cache.

Signed-off-by: Dominik_Kessler <dominikkessler103@gmail.com>
@Dominik0101 Dominik0101 force-pushed the fix-backup-cache-null branch from 91323d4 to 1b1154a Compare April 5, 2026 12:48
@Dominik0101
Copy link
Copy Markdown
Author

The issue can be reproduced by opening the backups section in the NextcloudPi admin panel.

If the cache file contains invalid or empty JSON, the page fails with:
"Something went wrong. Try refreshing the page"

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.

1 participant