Repository: ampache/ampache (language: php)

Issue:
Subsonic API: "empty" search3 query not properly supported
## Description

### Describe the bug

[Symfonium](https://symfonium.app/) uses the Subsonic search3 API early in its Sync process. The [query parameter is non-option](http://www.subsonic.org/pages/api.jsp#search3) so the developer has chosen to use an empty query (i.e., "") instead. This returns nothing because the current code interprets `"something"` as an equals-title clause, and very few titles are empty strings.

### To reproduce

`curl https://<server.com>/rest/search3.view?query=""<&base parameters>``

### Expected behavior

The `searchResult3` response is not empty.

## Environment

* Ampache version: 5.5.5-release
* Web server + version: N/A
* Server operating system: N/A
* Client operating system: Android N/A

### Client type

* SubSonic

Symfonium 3.0.0a


Discussion / hints:

Fix patch:
diff --git a/src/Module/Api/Subsonic_Api.php b/src/Module/Api/Subsonic_Api.php
index a008e445c2..78c8ea5e9d 100644
--- a/src/Module/Api/Subsonic_Api.php
+++ b/src/Module/Api/Subsonic_Api.php
@@ -1056,7 +1056,11 @@ public static function search2($input, $elementName = "searchResult2")
         $query    = $original;
         if (substr($original, 0, 1) == '"' && (substr($original, -1) == '"')) {
             $query    = substr($original, 1, -1);
-            $operator = 4; // equals
+            // query is non-optional, but some clients send empty queries to fetch
+            // all items. Fall back on default contains in such cases.
+            if (strlen($query) > 0) {
+                $operator = 4; // equals
+            }
         }
         if (substr($original, 0, 1) == '"' && substr($original, -2, 2) == '"*') {
             $query    = substr($original, 1, -2);


Test patch: