Skip to content

[6.x] Fix error caused by empty globals#14098

Merged
jasonvarga merged 2 commits into6.xfrom
empty-globals
Feb 27, 2026
Merged

[6.x] Fix error caused by empty globals#14098
jasonvarga merged 2 commits into6.xfrom
empty-globals

Conversation

@duncanmcclean
Copy link
Member

@duncanmcclean duncanmcclean commented Feb 27, 2026

This pull request fixes an issue where the v5 to v6 update script doesn't account for globals with empty data.

In v5, it was possible to have empty data in globals:

# content/globals/socials.yaml
title: Socials
data:

Once the updater had run, the result would be:

# content/globals/default/socials.yaml
null

Which then throws an error:

array_key_exists(): Argument #2 ($array) must be of type array, null given

This was happening because Arr::get($contents, 'data', []) returns null when the data key exists but has a null value (the default [] is only used when the key doesn't exist). The YAML::dump(null) call then produces the literal string null.

This PR fixes it by:

  • Using Arr::get($contents, 'data') ?? [] to properly handle null values
  • Adding defensive null handling in GlobalVariablesStore so it gracefully handles YAML files containing null

Fixes #14095

@jasonvarga jasonvarga merged commit 3e91e35 into 6.x Feb 27, 2026
11 checks passed
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.

Update script doesnt account for no data in globals (5 > 6)

2 participants