• Resolved marcusquinn

    (@surferking)


    The error message you’re seeing is related to a change in PHP 8.0. The usort() function no longer accepts a comparison function that returns a boolean value. Instead, it expects a comparison function that returns an integer less than, equal to, or greater than zero. It appears the “Simple Feature Requests” plugin you’re using hasn’t updated this part of their code to be compatible with PHP 8.0. Here’s a quick fix.

    Please note that directly editing plugin files is generally not recommended, as your changes will be lost when the plugin updates.

    However, in this case, you might not have any other option if the plugin authors haven’t provided an update that fixes the problem.

    In the file wp-content/plugins/simple-feature-requests/inc/vendor/wp-settings-framework/wp-settings-framework.php, find the line where usort() is used (it’s line 296 according to your error message).

    The code is probably similar to this:

    <br>phpusort( $this->settings, function( $a, $b ) { return $a['priority'] < $b['priority'];} );<br>

    Change it to this:

    <br>phpusort( $this->settings, function( $a, $b ) { return $a['priority'] <=> $b['priority'];} );<br>

    This changes the comparison from a less than operation to a “spaceship” operation (<=>), which directly provides the -1, 0, or 1 result expected by usort().

    Remember to backup your files before making changes. Also, you should notify the plugin author about this issue and ask them to provide an update.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Here’s the fix for “Deprecated usort()” in php8 (from GPT-4)’ is closed to new replies.