]> source.dussan.org Git - nextcloud-server.git/commitdiff
Use the new octetLength function to filter lines to migrate
authorCôme Chilliet <come.chilliet@nextcloud.com>
Tue, 29 Mar 2022 15:01:41 +0000 (17:01 +0200)
committerCôme Chilliet (Rebase PR Action) <come-nc@users.noreply.github.com>
Wed, 30 Mar 2022 14:43:09 +0000 (14:43 +0000)
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
apps/user_ldap/lib/Migration/Version1141Date20220323143801.php

index 84663466bd7f58a249f2087923cc7b035e183c5b..be496d9215e3559f05b443535460d05563bcba5a 100644 (file)
@@ -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);