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

is_array check on null in updateCache method in bedrock-autoloader.php not compatible with php 7.4 #509

Closed
4 tasks done
sanderdv opened this issue Apr 24, 2020 · 1 comment

Comments

@sanderdv
Copy link

Description

This issue happens when using php 7.4 (as roots/trellis 1.4.0 does). In /web/app/mu-plugins/bedrock-autoloader.php on line 176 in the updateCache method of the Autoloader class. There is a check if $this->cache['plugins'] is an array by using is_array. However, $this->cache['plugins'] can be null at that point. As of php 7.4 is_array will no longer return null when the given variable is null, but throws a notice for invalid array access.

I was able to fix it by first checking if $this->cache is an array, like this:
$rebuild = !(is_array($this->cache) && is_array($this->cache['plugins']));

Steps to reproduce

  1. Use Bedrock in combination with php 7.4 (roots/trellis 1.4.0 for example).
  2. Make sure you can see php notices.
  3. Add a mu-plugin in the mu-plugin folder.
  4. See the notices appear when opening the site.

Expected behavior:
No php exceptions or notices when using bedrock and php 7.4

Actual behavior:
A php notice when using bedrock and php 7.4

Versions

Bedrock 1.13.2
Trellis 1.4.0
OSX 10.14.6

@Log1x Log1x closed this as completed in d6b8dd4 Apr 24, 2020
Log1x added a commit that referenced this issue Apr 24, 2020
fix(mu-plugins): Fix invalid array access notice on 7.4 (Fixes #509)
@Log1x
Copy link
Member

Log1x commented Apr 24, 2020

Thanks!

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

No branches or pull requests

2 participants