[Bug]: Unified search returns HTTP 500 on PHP 8 when the `cursor` parameter is empty ("Unsupported operand types: string + int")
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 66/100
Piste de recherche
Les cinq points de plantage sont listés dans le tableau : apps/files/lib/Search/FilesSearchProvider.php (vers la ligne 143), apps/dav/lib/Search/ContactsSearchProvider.php, apps/dav/lib/Search/EventsSearchProvider.php, apps/dav/lib/Search/TasksSearchProvider.php et apps/systemtags/lib/Search/TagSearchProvider.php. Commence par reproduire l'erreur 500 avec un cursor vide sur l'endpoint de recherche des fournisseurs, puis repère où chaque fournisseur calcule le curseur suivant à partir de getCursor(). C'est terminé lorsqu'un curseur vide renvoie 200 sur chaque fournisseur et qu'un mainteneur a choisi entre le cast par fournisseur ou la normalisation dans SearchQuery::getCursor().
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
⚠️ This issue respects the following points: ⚠️
- This is not a troubleshooting question, general support matter, or webserver/proxy problem, but likely a bug (if unsure, ask the Community Help Forum).
- This issue is not already reported on Github OR solved at the Community Help Forum (I've searched!).
- I'm using a maintained major version of Nextcloud Server and tested against the latest patch level. (Supported major versions and current patch levels).
- I agree to follow Nextcloud's Code of Conduct.
- I've tried my best to provide clear reproduction steps that someone unfamiliar with this bug could use to reproduce it.
Bug description
Unified search is completely broken on PHP 8: every search request returns HTTP 500 and the UI shows "No matches found" even when matching files exist.
Every search provider computes the next cursor as:
$query->getCursor() + <int>
When the web frontend sends an empty cursor query parameter (which it does on the first search), getCursor() returns an empty string. On PHP 8, '' + int throws a TypeError instead of coercing to 0 as PHP 7 did. The provider crashes, the OCS endpoint returns 500, and the frontend - which receives an error rather than an empty result set - renders "No matches found".
This affects five providers across three apps, so file, contacts, calendar, tasks and tag search all break at once. Because unified search queries every provider, a single failing one is enough to make the whole search look empty.
| File | Line | Code |
|---|---|---|
apps/files/lib/Search/FilesSearchProvider.php |
143 | $query->getCursor() + $query->getLimit() |
apps/dav/lib/Search/ContactsSearchProvider.php |
130 | $query->getCursor() + count($formattedResults) |
apps/dav/lib/Search/EventsSearchProvider.php |
207 | $query->getCursor() + count($uniqueResults) |
apps/dav/lib/Search/TasksSearchProvider.php |
139 | $query->getCursor() + count($searchResults) |
apps/systemtags/lib/Search/TagSearchProvider.php |
149 | $query->getCursor() + $query->getLimit() |
Steps to reproduce
- Run Nextcloud 35.x on PHP 8 (reproduced on PHP 8.5.4).
- Log in to the web UI and open the Files app.
- Type into the unified search bar any term matching an existing file.
- The dropdown shows "No matches found" even though the file exists.
- The browser console shows:
unified-search: Unexpected AxiosError "Request failed with status code 500".
The failure can be isolated with direct requests. The empty cursor is the only variable that changes between 200 and 500:
# 200, returns results:
/ocs/v2.php/search/providers/files/search?term=<term>&from=%2Fapps%2Ffiles%2Ffiles
# 200, returns results:
/ocs/v2.php/search/providers/files/search?term=<term>&from=%2Fapps%2Ffiles%2Ffiles&cursor=0
# 500:
/ocs/v2.php/search/providers/files/search?term=<term>&from=%2Fapps%2Ffiles%2Ffiles&cursor=
Expected behavior
An empty cursor should be treated as "no cursor" (i.e. 0) and the search should return results normally, as it did on PHP 7.
Actual behaviour: the provider throws, the endpoint returns HTTP 500, and the UI reports no matches.
Nextcloud Server version
35
Operating system
Debian/Ubuntu
PHP engine version
PHP 8.5
Web server
Apache (supported)
Database engine version
MariaDB
Is this bug present after an update or on a fresh install?
Upgraded to a MAJOR version (ex. 31 to 32)
Are you using the Nextcloud Server Encryption module?
Encryption is Disabled
What user-backends are you using?
- Default user-backend (database)
- LDAP/ Active Directory
- SSO - SAML
- Other
Configuration report
List of activated Apps
Nextcloud Signing status
Nextcloud Logs
Exception: Unsupported operand types: string + int in file
'/var/www/html/apps/dav/lib/Search/EventsSearchProvider.php' line 207
URL: /ocs/v2.php/search/providers/calendar/search?term=<term>&from=%2Fapps%2Ffiles%2Ffiles&cursor=
The same exception is raised by each affected provider at the line listed in the description.
Additional info
Suggested fix
Cast the cursor before the addition, so an empty value becomes 0:
(int)$query->getCursor() + $query->getLimit()
Applying that one-line change to the five files listed above restores unified search completely. Verified locally: all nine registered providers return HTTP 200 afterwards, including with &cursor= empty.
A more central alternative would be to normalise the value in SearchQuery::getCursor() itself, or when the OCS controller parses the request, so providers never receive an empty string.
Notes
- The regression is invisible on PHP 7, where
'' + intevaluates to the integer with only a notice. It only surfaces once the server runs PHP 8, which makes it easy to miss and hard for users to attribute: the search simply looks like it finds nothing. - Reproduced on 35.0.2 and again on 35.0.3. The 35.0.3 update overwrote a local patch and the bug returned, so the affected code is unchanged between those releases.
App versions of the affected apps
- files: 3.0.0
- dav: 2.0.1
- systemtags: 2.0.0
- Langage dominant
- PHP
- Étoiles
- 37.5k
- Forks
- 5.4k
- Merge moyen
- 1 j 14 h
- PR mergées (30 j)
- 648
Préparer son environnement
Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de nextcloud/server
-
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
Les mainteneurs répondent en général sous 1 jour
-
Contacts import aborts with TypeError when vCards have no UID (TextImporter structure)Peut-être pris @SebastianKrupinski l’a pris il y a 4 jours. Ouvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
nextcloud/server#66486 · 2 commentaires · 2 réactions · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
-
Unified search: screen reader hears "No matching results" on mobile even when there are resultsPeut-être pris @lazerg l’a pris il y a 8 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
34-feedback needs info
Difficulté 2/5 1-3 heures Accessibilité débutants 77/100
nextcloud/server#66249 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
[Bug]: DAV Forbidden/InvalidPath responses break on "&" in the message (DOMDocument::createElementNS(): unterminated entity reference)Peut-être pris @th-joerger l’a pris il y a 12 jours. Ouverte0. Needs triage 35-feedback bug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de nextcloud/server
Issues similaires
-
Difficulté 2/5 Moins d'une heure Accessibilité débutants 82/100
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 1/5 Moins d'une heure Accessibilité débutants 72/100
wpgenius/stackfolio#22 ·
-
Import-loop editor checks fail on non-English sites: selectors assume English wp-admin labelsOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
Automattic/static-site-importer#3024 ·
Les mainteneurs répondent en général sous 1 jour
-
[6.0]: Uncaught TypeError: can't access property "value", event.chart.scales.x.ticks[4] is undefinedOuverteBug
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
phpmyadmin/phpmyadmin#20626 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour