Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fall back to boolean instead of null #332

Merged
merged 1 commit into from
Aug 7, 2024
Merged

Fall back to boolean instead of null #332

merged 1 commit into from
Aug 7, 2024

Conversation

dnwjn
Copy link
Contributor

@dnwjn dnwjn commented Aug 7, 2024

Hi!

This change fixes the following error we receive when navigating to the CP /navigation/<nav_name>:

Statamic\Support\Str::bool(): Argument #1 ($value) must be of type bool, null given, called in /<redacted>/storage/framework/views/f7f7a695478ceb1af2141e5f7389a1b0.php on line 21 (View: /<redacted>/vendor/statamic/cms/resources/views/navigation/show.blade.php)

This started happening after updating Composer dependencies, limited to patch and minor versions. The change in this PR is a possible fix, but that depends on if the default is considered false. Otherwise another option could be:

// vendor/statamic/cms/src/Structures/Nav.php

public function canSelectAcrossSites($canSelect = null)
{
    return $this
        ->fluentlyGetOrSet('canSelectAcrossSites')
+        ->setter(function ($canSelect) {
+            return (bool) $canSelect;
+        })
        ->args(func_get_args());
}

Let me know what you think!

@ryanmitchell
Copy link
Contributor

Im happy with this, thanks!

@ryanmitchell ryanmitchell merged commit 8c73ba9 into statamic:master Aug 7, 2024
11 checks passed
@dnwjn dnwjn deleted the patch-1 branch August 8, 2024 08:38
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