{"id":16717775,"date":"2023-05-07T16:38:58","date_gmt":"2023-05-07T16:38:58","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/error-when-using-wp-cli-5\/"},"modified":"2023-05-07T16:38:58","modified_gmt":"2023-05-07T16:38:58","slug":"error-when-using-wp-cli-5","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/error-when-using-wp-cli-5\/","title":{"rendered":"Error when using WP-CLI"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>PHP Warning:  Trying to access array offset on value of type null in \/chroot\/home\/USER\/DOMAIN\/html\/wp-content\/plugins\/cryptx\/include\/functions.php on line 428<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Ran into this error when using WP-CLI. When using WP-CLI not all globals are available, if you could just put in a check that the variable exists that should do it. It&#8217;s in this part:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n *  add ID to exclude list\n *\/\nfunction rw_cryptx_insert_post($pID) {\n    global $cryptX_var, $post;\n    $rev = wp_is_post_revision($pID);\n    if($rev) $pID = $rev;\n    $b = explode(\",\", $cryptX_var&#091;'excludedIDs']); \/\/ LINE 428\n    if($b&#091;0] == '') unset($b&#091;0]);\n    foreach($b as $x=&gt;$y) {\n        if($y == $pID) {\n            unset($b&#091;$x]);\n            break;\n        }\n    }\n    if (isset($_POST&#091;'cryptxoff'])) $b&#091;] = $pID;\n    $b = array_unique($b);\n    sort($b);\n    $cryptX_var&#091;'excludedIDs'] = implode(\",\", $b);\n    update_option( 'cryptX', $cryptX_var);\n    $cryptX_var = rw_loadDefaults(); \/\/ reread Options\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">CryptX 3.3.3.2 \/ WordPress 6.2 \/ PHP 8.0.28<\/p>\n","protected":false},"template":"","class_list":["post-16717775","topic","type-topic","status-publish","hentry","topic-tag-wp-cli"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/16717775","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\/16717775\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=16717775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}