Skip to content

Commit

Permalink
PHP 8.1 usort fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Nomafin committed Jan 23, 2023
1 parent ce2c5ba commit c1f5fe6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/Search/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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 '';
}

Expand Down

0 comments on commit c1f5fe6

Please sign in to comment.