PHP Fatal error with Moderation plugin (split function)

I tried to save settings on my Network site and got a PHP fatal error, because of the split function in /wp-content/plugins/moderation/moderation.php:265

The split function was deprecated in PHP 5.3.0 and no longer existing in PHP 7.0 (which is what I’m running with). Haven’t taken a look at the code itself yet, just wanted to mention it before forgetting about it :wink:

  • Hiranthi
    • Recruit

    I am indeed using PHP 7, I also mentioned that (and that the split-function is deprecated in PHP 5.3 and removed in PHP7) when I opened this topic :wink:

    Anyways, just changing the split functions in the plugin to preg_split should do the trick :slight_smile:

  • Panos
    • SLS

    Hey there guys!

    Thanks for reporting this Hiranthi , and thanks for sharing your solution :slight_smile:

    However since you are using preg_split, the n will not work and it is possible the Report Post Reasons, Report Comment Reasons, Report Blog Reasons and Remove Notes not to be saved.

    So if you will be using preg_split you will also need to replace n to #n#, for example line 265 should change from:

    $moderation_report_post_reasons = split( "n", stripslashes( $_POST['moderation_report_post_reasons'] ) );

    to

    $moderation_report_post_reasons = preg_split( "#n#", stripslashes( $_POST['moderation_report_post_reasons'] ) );

    I would better suggest though to use explode since there is no regular expression to check, which is simpler to use and faster. Same line should be changed to :

    $moderation_report_post_reasons = explode( "n", stripslashes( $_POST['moderation_report_post_reasons'] ) );

    Thanks again!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.