Skip to content

Fix backup cache handling when JSON decode returns null#2105

Merged
theCalcaholic merged 1 commit intonextcloud:fix/backup-cache-is-nullfrom
Dominik0101:fix-backup-cache-null
Apr 14, 2026
Merged

Fix backup cache handling when JSON decode returns null#2105
theCalcaholic merged 1 commit intonextcloud:fix/backup-cache-is-nullfrom
Dominik0101:fix-backup-cache-null

Conversation

@Dominik0101
Copy link
Copy Markdown
Contributor

@Dominik0101 Dominik0101 commented Apr 5, 2026

The WebUI crashes 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
@theCalcaholic
Copy link
Copy Markdown
Collaborator

Thanks so much, lgtm

@theCalcaholic theCalcaholic changed the base branch from master to devel April 14, 2026 09:41
@theCalcaholic
Copy link
Copy Markdown
Collaborator

theCalcaholic commented Apr 14, 2026

The pipelines don't seem to be working on a different repo, so I'll merge this into a temporary branch for testing. :)
It's a small enough change, so I don't expect anything to come up

@theCalcaholic theCalcaholic changed the base branch from devel to fix/backup-cache-is-null April 14, 2026 10:46
@theCalcaholic theCalcaholic merged commit 07a4012 into nextcloud:fix/backup-cache-is-null Apr 14, 2026
11 of 15 checks passed
@theCalcaholic
Copy link
Copy Markdown
Collaborator

Continued in #2113

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