Skip to content

[Bug]: Querying for empty strings using search methods of UserConfig returns wrong results #57300

@akhil1508

Description

@akhil1508

⚠️ This issue respects the following points: ⚠️

Bug description

  • The default value for the indexed field in preferences table is set to '' in
    $table->addColumn('indexed', Types::STRING, ['notnull' => false, 'default' => '', 'length' => 64]);
  • This means if you have configvalue entries like '' you will always get wrong results as the query in
    $qb->expr()->eq($qb->func()->lower($configValueColumn), $qb->createNamedParameter(strtolower($value)))
    checks for indexed = '' on top of checking for configvalue field
  • 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 NULL default instead?

Steps to reproduce

  1. Set a preference using occ user:setting username1 some-app some-key ''
  2. Set a preference using occ user:setting username2 some-app some-key some-value
  3. Use IUserConfig::searchUsersByValueString('some-app', 'some-key', '');
  4. It will return both results

Expected behavior

  • The method should return only one result
  • The sensible default for the indexed field should be NULL as 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    0. Needs triagePending check for reproducibility or if it fits our roadmap31-feedbackbug

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions