Skip to content

Commit

Permalink
Obey col length of 255 to insert and search in accounts_data
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
  • Loading branch information
blizzz committed Nov 26, 2021
1 parent d384edc commit 998144f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/private/Accounts/AccountManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,10 @@ protected function getUser(IUser $user, bool $insertIfNotExists = true): array {
}

public function searchUsers(string $property, array $values): array {
// the value col is limited to 255 bytes. It is used for searches only.
$values = array_map(function (string $value) {
return Util::shortenMultibyteString($value, 255);
}, $values);
$chunks = array_chunk($values, 500);
$query = $this->connection->getQueryBuilder();
$query->select('*')
Expand Down Expand Up @@ -625,8 +629,11 @@ protected function writeUserDataProperties(IQueryBuilder $query, array $data): v
continue;
}

// the value col is limited to 255 bytes. It is used for searches only.
$value = $property['value'] ? Util::shortenMultibyteString($property['value'], 255) : '';

$query->setParameter('name', $property['name'])
->setParameter('value', $property['value'] ?? '');
->setParameter('value', $value);
$query->executeStatement();
}
}
Expand Down

0 comments on commit 998144f

Please sign in to comment.