From c1f5fe6f31b81e96fd4904acea6882e5ac6bccd7 Mon Sep 17 00:00:00 2001 From: Miika Arponen Date: Mon, 23 Jan 2023 17:08:20 +0200 Subject: [PATCH] PHP 8.1 usort fix --- CHANGELOG.md | 6 ++++++ src/Search/QueryBuilder.php | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bec2d4..2565d61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [1.16.1] - 2023-01-23 + +### Changed +- User query functionality to work with the changes of WordPress 5.9. +- PHP 8.1 fixes for usort functions + ## [1.16.0] - 2022-05-17 ### Added diff --git a/src/Search/QueryBuilder.php b/src/Search/QueryBuilder.php index bb06cee..89ccad9 100644 --- a/src/Search/QueryBuilder.php +++ b/src/Search/QueryBuilder.php @@ -205,7 +205,7 @@ public function get_query() : array { // All minuses to the end of the line. usort( $return, function( $a, $b ) { - return ( substr( $a, 0, 1 ) === '-' ); + return ( substr( $a, 0, 1 ) === '-' ) ? 1 : 0; }); return array_merge( @@ -733,7 +733,7 @@ protected function create_meta_query( array $query, string $operator = 'AND' ) : $prefix = $wpdb->base_prefix; // This is the place to convert the checks of whether the user belongs to a blog or not into RediPress style. - if ( preg_match( "/^${prefix}(\d+?)_?capabilities$/", $clause['key'], $matches ) && $clause['compare'] === 'EXISTS' ) { + if ( preg_match( "/^{$prefix}(\d+?)_?capabilities$/", $clause['key'], $matches ) && $clause['compare'] === 'EXISTS' ) { $query = $this->create_meta_query([ [ 'key' => 'blogs', @@ -847,7 +847,7 @@ protected function create_meta_clause( array $clause ) : ?string { $prefix = $wpdb->base_prefix; // Filter out capability queries as they are handled differently - if ( preg_match( "/^${prefix}(\d+?)_?capabilities$/", $clause['key'] ) ) { + if ( preg_match( "/^{$prefix}(\d+?)_?capabilities$/", $clause['key'] ) ) { return ''; }