aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2022-03-29 17:01:41 +0200
committerCôme Chilliet (Rebase PR Action) <come-nc@users.noreply.github.com>2022-03-30 14:43:09 +0000
commitd07208bd2cc10e09b4e8136c90c71bd331c1d80e (patch)
tree7b13ffe4cbcf95e692d57c08c68ca6158fad40c0
parent6c7ba01dfedaf90855c8a5f3915cbc7a07c1a70b (diff)
downloadnextcloud-server-d07208bd2cc10e09b4e8136c90c71bd331c1d80e.tar.gz
nextcloud-server-d07208bd2cc10e09b4e8136c90c71bd331c1d80e.zip
Use the new octetLength function to filter lines to migrate
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
-rw-r--r--apps/user_ldap/lib/Migration/Version1141Date20220323143801.php12
1 files changed, 4 insertions, 8 deletions
diff --git a/apps/user_ldap/lib/Migration/Version1141Date20220323143801.php b/apps/user_ldap/lib/Migration/Version1141Date20220323143801.php
index 84663466bd7..be496d9215e 100644
--- a/apps/user_ldap/lib/Migration/Version1141Date20220323143801.php
+++ b/apps/user_ldap/lib/Migration/Version1141Date20220323143801.php
@@ -48,19 +48,15 @@ class Version1141Date20220323143801 extends SimpleMigrationStep {
*/
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
foreach (['ldap_user_mapping', 'ldap_group_mapping'] as $tableName) {
- $dnsTooLong = [];
- $lengthExpr = $this->dbc->getDatabasePlatform()->getLengthExpression('ldap_dn');
-
$qb = $this->dbc->getQueryBuilder();
$qb->select('ldap_dn')
->from($tableName)
- ->where($qb->expr()->gt($qb->createFunction($lengthExpr), '255', IQueryBuilder::PARAM_INT));
+ ->where($qb->expr()->gt($qb->func()->octetLength('ldap_dn'), '4000', IQueryBuilder::PARAM_INT));
+ $dnsTooLong = [];
$result = $qb->executeQuery();
- while(($dn = $result->fetchOne()) !== false) {
- if(mb_strlen($dn) > 4000) {
- $dnsTooLong[] = $dn;
- }
+ while (($dn = $result->fetchOne()) !== false) {
+ $dnsTooLong[] = $dn;
}
$result->closeCursor();
$this->shortenDNs($dnsTooLong, $tableName);