Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use the new octetLength function to filter lines to migrate
Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Mar 30, 2022
commit d07208bd2cc10e09b4e8136c90c71bd331c1d80e
12 changes: 4 additions & 8 deletions apps/user_ldap/lib/Migration/Version1141Date20220323143801.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,15 @@ public function __construct(IDBConnection $dbc) {
*/
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);
Expand Down