{"id":19012725,"date":"2026-09-06T10:45:32","date_gmt":"2026-09-06T10:45:32","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/php-warning-undefined-array-key-enabled-after-update-to-4-0-13\/"},"modified":"2026-09-06T10:45:32","modified_gmt":"2026-09-06T10:45:32","slug":"php-warning-undefined-array-key-enabled-after-update-to-4-0-13","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/php-warning-undefined-array-key-enabled-after-update-to-4-0-13\/","title":{"rendered":"PHP Warning: Undefined array key &#8220;enabled&#8221; after update to 4.0.13"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>PHP Warning: Undefined array key &#8220;enabled&#8221; after update to 4.0.13<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After updating Payment Plugins for Stripe WooCommerce to version 4.0.13, the following PHP warning started appearing repeatedly:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PHP Warning: Undefined array key \"enabled\" in\n\/wp-content\/plugins\/woo-stripe-payment\/includes\/class-wc-stripe-product-gateway-option.php on line 113<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The issue is in <code>WC_Stripe_Product_Gateway_Option::get_option()<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public function get_option( $key, $default = null ) {\n    if ( ! isset( $this-&gt;settings&#091; $key ] ) &amp;&amp; null != $default ) {\n        $this-&gt;settings&#091; $key ] = $default;\n    }\n\n    return $this-&gt;settings&#091; $key ];\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>enabled()<\/code> calls:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>return $this-&gt;get_option( 'enabled', false );<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Because the comparison in <code>get_option()<\/code> is non-strict (<code>null != $default<\/code>), it evaluates to false when <code>$default<\/code> is boolean <code>false<\/code>. Therefore, if the <code>enabled<\/code> key is missing, the default value is not assigned and the subsequent array access triggers the PHP warning.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I tested the following fix successfully:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public function get_option( $key, $default = null ) {\n    if ( ! isset( $this-&gt;settings&#091; $key ] ) &amp;&amp; null !== $default ) {\n        $this-&gt;settings&#091; $key ] = $default;\n    }\n\n    return $this-&gt;settings&#091; $key ] ?? $default;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This changes the comparison to strict (<code>!==<\/code>) and also safely returns the supplied default if the key is absent.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Could you please include this fix in the next release?<\/p>\n","protected":false},"template":"","class_list":["post-19012725","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/19012725","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/19012725\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=19012725"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}