valendesigns / option-tree

Theme Options UI Builder for WordPress. A simple way to create & save Theme Options and Meta Boxes for free or premium themes.
GNU General Public License v2.0
598 stars 180 forks source link

PHP 7.4 - Trying to access array offset on value of type bool #722

Open landbryo opened 4 years ago

landbryo commented 4 years ago

I was getting a bunch of notices that I couldn't ignore. Looked into this notice a bit and it appears to be related to some changes in PHP 7.4. It should be a relatively easy fix that I'll go ahead and look into resolving.

( ! ) Notice: Trying to access array offset on value of type bool in option-tree\includes\class-ot-settings.php on line 395

Call Stack
#   Time    Memory  Function    Location
1   0.0002  363080  {main}( )   ...\admin.php:0
2   3.4280  14123000    do_action( )    ...\admin.php:170
3   3.4281  14123272    WP_Hook->do_action( )   ...\plugin.php:478
4   3.4281  14123272    WP_Hook->apply_filters( )   ...\class-wp-hook.php:312
5   5.4509  16605920    OT_Settings->add_sections( )    ...\class-wp-hook.php:288
codemonkeynorth commented 3 years ago

Hi @landbryo

use Null Coalescing Operator ?? maybe? https://stackoverflow.com/questions/59674903/trying-to-access-array-offset-on-value-of-type-bool-in-php-7-4

thanks J

[update: sorry I see you've added a fix.. will this be deployed to the wordpress plugin repo at some point?)

landbryo commented 3 years ago

@codemonkeynorth that would be a question for @valendesigns since he was going to review and potentially merge the fix.

fellipeleao commented 2 years ago

Thanks @landbryo, I implemented your change to my code and I'm not getting the notice anymore!

crudoy commented 1 year ago

Sorry, I'm confused. What was the fix? I'm getting the same error.

landbryo commented 1 year ago

@crudoy you can view the proposed fix here, but it hasn't been merged yet, so you'd have to manually apply it.