soflyy / oxygen-bugs-and-features

Bug Reports & Feature Requests for Oxygen
https://oxygenbuilder.com/
314 stars 29 forks source link

Oxy 4.7.1 PHP Warning 'Undefined array key "type"' when evaluating Condition in Builder #3450

Open maltmann-muc opened 11 months ago

maltmann-muc commented 11 months ago

Environment: PHP 8.1, WP 6.4.1, Oxy 4.7.1 Situation: In Builder for templates/posts containing Conditions, set to AND (default) and "Show/Hide Based on Condition"

File and Function: /wp-content/plugins/oxygen/component-framework/component-init.php global_conditions_result()

Warning and Call Stack:

Warning:  Undefined array key "type" in /.../wp-content/plugins/oxygen/component-framework/includes/conditions.php on line 269
Stack trace:
  1. {main}() /.../index.php:0
  2. require() /.../index.php:17
  3. require_once() /.../wp-blog-header.php:19
  4. include() /.../wp-includes/template-loader.php:106  
  5. OxygenConditions->global_conditions_result($conditionsData = ['conditions' => [0 => [...]]]) /.../wp-content/plugins/oxygen/component-framework/components/layouts/ifelse.php:22

Description: Builder evaluates Condition if set to "Show/Hide Based on Condition". Depending on type (AND/OR) the $conditionsData does or does not contain an array key "type":
 AND : No "type" key, OR: type => "1"

Bildschirmfoto 2023-11-18 um 17 59 45

Solution: Change $or = $conditionsData['type'] == "1"?true:false; To $or = ($conditionsData['type']??'') == "1"?true:false;

maltmann-muc commented 11 months ago

Oxy 4.8 RC 1: Issue is already solved.