• Resolved Nick

    (@nickchomey)


    I get an error when changing which plugins are to be blocked. It is related to line 3 of bspu_plugin_select.php

    It says that join() wants to receive an array, but it receives strings. The problem goes away if I change

    $blocked_plugins = @join('###',$_POST['block_plugin_updates']);

    to

    $blocked_plugins = @join(['###',$_POST['block_plugin_updates']]);

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Nick

    (@nickchomey)

    Upon digging deeper, that’s not it at all. The problem occurred when I was going from >0 to 0 blocked plugins.

    Anyway, I’ve made some changes to the code – I don’t see any need to use the join(), explode(), and “###” at all. You can just store the $_POST[‘block_plugin_updates’] array in the option to begin with.

    I’ll share a link to a modified repo when I’m done tidying up

    Thread Starter Nick

    (@nickchomey)

    Ah, whatever. Easier to just replace that line with the following than to create a repo and then you merge all the changes.

    $blocked_plugins = @join('###',isset($_POST['block_plugin_updates']) ? $_POST['block_plugin_updates'] : array());

    The issue is when you submit with all boxes unchecked – it doesn’t pass an array, which means that the join() has nothing to join. So, this change just checks if it is set, and if not, it joins an empty array.

    But, it would be cleaner if you just got rid of all of the ###, join, explode etc… and simply stored the array in the options table. It would look like this, which is standard practice (you’ll see that wp_options is full of such serialized arrays)

    a:2:{i:0;s:66:"block-specific-plugin-updates-bk/block-specific-plugin-updates.php";i:1;s:23:"gutenberg/gutenberg.php";}

    • This reply was modified 2 years ago by Nick.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Error, probably due to php 8.1’ is closed to new replies.