diff --git a/lib/Library.php b/lib/Library.php index 34d53338..a9614b51 100644 --- a/lib/Library.php +++ b/lib/Library.php @@ -168,12 +168,9 @@ class Library{ } /** - * @param string $query - * @param string $status - * @param ArtworkSortType $sort * @return array|int> */ - public static function FilterArtwork(string $query = null, string $status = null, ArtworkSortType $sort = null, int $submitterUserId = null, int $page = 1, int $perPage = ARTWORK_PER_PAGE): array{ + public static function FilterArtwork(?string $query = null, ?string $status = null, ?ArtworkSortType $sort = null, ?int $submitterUserId = null, int $page = 1, int $perPage = ARTWORK_PER_PAGE): array{ // Returns an array of: // ['artworks'] => array, // ['artworksCount'] => int @@ -229,7 +226,12 @@ class Library{ } // Remove diacritics and non-alphanumeric characters, but preserve apostrophes - $query = trim(preg_replace('|[^a-zA-Z0-9\'’ ]|ius', ' ', Formatter::RemoveDiacritics($query ?? ''))); + if($query !== null && $query != ''){ + $query = trim(preg_replace('|[^a-zA-Z0-9\'’ ]|ius', ' ', Formatter::RemoveDiacritics($query))); + } + else{ + $query = ''; + } // We use replace() below because if there's multiple contributors separated by an underscore, // the underscore won't count as word boundary and we won't get a match.