[Bug]: Querying for empty strings using search methods of UserConfig returns wrong results
Open
Nobody has claimed this yet.
0. Needs triage
31-feedback
bug
- Dominant language
- PHP
- Stars
- 36.9k
- Forks
- 5.2k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 713
Description
⚠️ This issue respects the following points: ⚠️
- This is a bug, not a question or a configuration/webserver/proxy issue.
- This issue is not already reported on Github OR Nextcloud Community Forum (I've searched it).
- Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
- I agree to follow Nextcloud's Code of Conduct.
Bug description
- The default value for the
indexedfield inpreferencestable is set to''in https://github.com/nextcloud/server/blob/b33fdaf0858e48a29d732c49407cbe6a9d0420d7/core/Migrations/Version31000Date20240814184402.php#L41 - This means if you have
configvalueentries like''you will always get wrong results as the query in https://github.com/nextcloud/server/blob/b33fdaf0858e48a29d732c49407cbe6a9d0420d7/lib/private/Config/UserConfig.php#L516 checks forindexed = ''on top of checking forconfigvaluefield - The workaround for this would be to set the flag value to avoid indexed queries for all these rows
- But shouldn't there be a more sensible
NULLdefault instead?
Steps to reproduce
- Set a preference using
occ user:setting username1 some-app some-key '' - Set a preference using
occ user:setting username2 some-app some-key some-value - Use
IUserConfig::searchUsersByValueString('some-app', 'some-key', ''); - It will return both results
Expected behavior
- The method should return only one result
- The sensible default for the
indexedfield should beNULLas it is a NULLABLE field
Nextcloud Server version
31
Operating system
Debian/Ubuntu
PHP engine version
PHP 8.3
Web server
Nginx
Database engine version
MariaDB
Is this bug present after an update or on a fresh install?
None
Are you using the Nextcloud Server Encryption module?
None
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
Additional info
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with core/Migrations/Version31000Date20240814184402.php and lib/private/Config/UserConfig.php, especially the indexed default and search query referenced in the issue. Reproduce with the two occ user:setting commands, then call IUserConfig::searchUsersByValueString for an empty value. Done means the empty-value search returns only the matching user and the indexed default is addressed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mariadb, php
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100