My plugin showing “Are you sure you want to do this” on screen with a “Argument #2 is not an array in load.php’

It appears that the issue is related to my uses of this code:

$_POST = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING) ;
$_GET = filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING) ;

I had placed this at the top of the plugin (outside of the plugin’s class); I used it to sanitize any GET and POST values.

When you do any action (like a Post or Page Publish, or a plugin deactivate) that results in a $_POST, the wp_magic_quotes() function in load.php gets called (via the check_admin_referer() function, called on all $_POSTs on all pages, including a Publish and a plugin deactivate POST):

// code fragment from wp_magic_quote() in load.php
// Force REQUEST to be GET + POST.
$_REQUEST = array_merge( $_GET, $_POST );

My filter_input_array code (which I use to sanitize $_GETs and $_POSTs) was causing the second parameter in the array_merge() to not be an array, which caused this error to show up in the wp-admin folder error log:

    "PHP Warning: array_merge(): Argument #2 is not an array 
in /[specific file location redacted]/wp-includes/load.php 
on line 664'

By moving the filter_input_array statements (first code block above) inside the check for the Submit button on the plugin settings form, the error went away. Apparently, my filter_input_array statements conflicted with the wp_magic_quotes use of the $_POST parameters.

Moving my filter_input_array statements inside the ‘check for the plugin settings page button submit’ appears to have fixed the problem.