diff options
author | Julien Veyssier <julien-nc@posteo.net> | 2023-06-05 11:28:22 +0200 |
---|---|---|
committer | Andy Scherzinger <info@andy-scherzinger.de> | 2023-07-10 21:13:20 +0200 |
commit | 3a45af2e27107333df8e2afb106920a5fa35f243 (patch) | |
tree | e0d25e07e62ade344e542439598a255a2a87ef7a /lib/private | |
parent | 47a19f2217fc9d0b2937d2512106ea71e5848709 (diff) | |
download | nextcloud-server-3a45af2e27107333df8e2afb106920a5fa35f243.tar.gz nextcloud-server-3a45af2e27107333df8e2afb106920a5fa35f243.zip |
shorten oauth2 client names before resizing the column
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Repair/Owncloud/MigrateOauthTables.php | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/private/Repair/Owncloud/MigrateOauthTables.php b/lib/private/Repair/Owncloud/MigrateOauthTables.php index 0b54793ebe2..5bf0816d8de 100644 --- a/lib/private/Repair/Owncloud/MigrateOauthTables.php +++ b/lib/private/Repair/Owncloud/MigrateOauthTables.php @@ -77,6 +77,27 @@ class MigrateOauthTables implements IRepairStep { $schema = new SchemaWrapper($this->db); $table = $schema->getTable('oauth2_clients'); if ($table->getColumn('name')->getLength() !== 64) { + // shorten existing values before resizing the column + $qb = $this->db->getQueryBuilder(); + $qb->update('oauth2_clients') + ->set('name', $qb->createParameter('shortenedName')) + ->where($qb->expr()->eq('id', $qb->createParameter('theId'))); + + $qbSelect = $this->db->getQueryBuilder(); + $qbSelect->select('id', 'name') + ->from('oauth2_clients'); + + $result = $qbSelect->executeQuery(); + while ($row = $result->fetch()) { + $id = $row['id']; + $shortenedName = mb_substr($row['name'], 0, 64); + $qb->setParameter('theId', $id, IQueryBuilder::PARAM_INT); + $qb->setParameter('shortenedName', $shortenedName, IQueryBuilder::PARAM_STR); + $qb->executeStatement(); + } + $result->closeCursor(); + + // safely set the new column length $table->getColumn('name')->setLength(64); } if ($table->hasColumn('allow_subdomains')) { |