Skip to content

Commit 6130ecf

Browse files
committed
fix(Db): Allow guest displaynames with a length of up to 255 chars
useful in federated setup Signed-off-by: Arthur Schiwon <[email protected]>
1 parent e254226 commit 6130ecf

File tree

6 files changed

+62
-5
lines changed

6 files changed

+62
-5
lines changed

composer/composer/InstalledVersions.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ class InstalledVersions
3232
*/
3333
private static $installed;
3434

35+
/**
36+
* @var bool
37+
*/
38+
private static $installedIsLocalDir;
39+
3540
/**
3641
* @var bool|null
3742
*/
@@ -309,6 +314,12 @@ public static function reload($data)
309314
{
310315
self::$installed = $data;
311316
self::$installedByVendor = array();
317+
318+
// when using reload, we disable the duplicate protection to ensure that self::$installed data is
319+
// always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not,
320+
// so we have to assume it does not, and that may result in duplicate data being returned when listing
321+
// all installed packages for example
322+
self::$installedIsLocalDir = false;
312323
}
313324

314325
/**
@@ -325,19 +336,24 @@ private static function getInstalled()
325336
$copiedLocalDir = false;
326337

327338
if (self::$canGetVendors) {
339+
$selfDir = strtr(__DIR__, '\\', '/');
328340
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
341+
$vendorDir = strtr($vendorDir, '\\', '/');
329342
if (isset(self::$installedByVendor[$vendorDir])) {
330343
$installed[] = self::$installedByVendor[$vendorDir];
331344
} elseif (is_file($vendorDir.'/composer/installed.php')) {
332345
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
333346
$required = require $vendorDir.'/composer/installed.php';
334347
self::$installedByVendor[$vendorDir] = $required;
335348
$installed[] = $required;
336-
if (strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
349+
if (self::$installed === null && $vendorDir.'/composer' === $selfDir) {
337350
self::$installed = $required;
338-
$copiedLocalDir = true;
351+
self::$installedIsLocalDir = true;
339352
}
340353
}
354+
if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) {
355+
$copiedLocalDir = true;
356+
}
341357
}
342358
}
343359

composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
'OCA\\Richdocuments\\Migration\\Version30709Date20201111104147' => $baseDir . '/../lib/Migration/Version30709Date20201111104147.php',
6262
'OCA\\Richdocuments\\Migration\\Version30717Date20210310164901' => $baseDir . '/../lib/Migration/Version30717Date20210310164901.php',
6363
'OCA\\Richdocuments\\Migration\\Version50200Date20211220212457' => $baseDir . '/../lib/Migration/Version50200Date20211220212457.php',
64+
'OCA\\Richdocuments\\Migration\\Version9000Date20250128212050' => $baseDir . '/../lib/Migration/Version9000Date20250128212050.php',
6465
'OCA\\Richdocuments\\Notification\\Notifier' => $baseDir . '/../lib/Notification/Notifier.php',
6566
'OCA\\Richdocuments\\PermissionManager' => $baseDir . '/../lib/PermissionManager.php',
6667
'OCA\\Richdocuments\\Preview\\EMF' => $baseDir . '/../lib/Preview/EMF.php',

composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class ComposerStaticInitRichdocuments
9494
'OCA\\Richdocuments\\Migration\\Version30709Date20201111104147' => __DIR__ . '/..' . '/../lib/Migration/Version30709Date20201111104147.php',
9595
'OCA\\Richdocuments\\Migration\\Version30717Date20210310164901' => __DIR__ . '/..' . '/../lib/Migration/Version30717Date20210310164901.php',
9696
'OCA\\Richdocuments\\Migration\\Version50200Date20211220212457' => __DIR__ . '/..' . '/../lib/Migration/Version50200Date20211220212457.php',
97+
'OCA\\Richdocuments\\Migration\\Version9000Date20250128212050' => __DIR__ . '/..' . '/../lib/Migration/Version9000Date20250128212050.php',
9798
'OCA\\Richdocuments\\Notification\\Notifier' => __DIR__ . '/..' . '/../lib/Notification/Notifier.php',
9899
'OCA\\Richdocuments\\PermissionManager' => __DIR__ . '/..' . '/../lib/PermissionManager.php',
99100
'OCA\\Richdocuments\\Preview\\EMF' => __DIR__ . '/..' . '/../lib/Preview/EMF.php',

composer/composer/installed.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
'name' => '__root__',
44
'pretty_version' => 'dev-main',
55
'version' => 'dev-main',
6-
'reference' => 'cfd48c8ab8986bf0b444fede00b5c3f70c0f703a',
6+
'reference' => '198650228e624d8c27f192a8174ae0710ee5c444',
77
'type' => 'library',
88
'install_path' => __DIR__ . '/../',
99
'aliases' => array(),
@@ -13,7 +13,7 @@
1313
'__root__' => array(
1414
'pretty_version' => 'dev-main',
1515
'version' => 'dev-main',
16-
'reference' => 'cfd48c8ab8986bf0b444fede00b5c3f70c0f703a',
16+
'reference' => '198650228e624d8c27f192a8174ae0710ee5c444',
1717
'type' => 'library',
1818
'install_path' => __DIR__ . '/../',
1919
'aliases' => array(),

lib/Migration/Version2060Date20200302131958.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
4444
]);
4545
$table->addColumn('guest_displayname', 'string', [
4646
'notnull' => false,
47-
'length' => 64,
47+
'length' => 255,
4848
]);
4949
$table->addColumn('fileid', 'bigint', [
5050
'notnull' => true,
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-or-later
8+
*/
9+
10+
namespace OCA\Richdocuments\Migration;
11+
12+
use Closure;
13+
use OCP\DB\ISchemaWrapper;
14+
use OCP\Migration\IOutput;
15+
use OCP\Migration\SimpleMigrationStep;
16+
17+
class Version9000Date20250128212050 extends SimpleMigrationStep {
18+
19+
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
20+
/** @var ISchemaWrapper $schema */
21+
$schema = $schemaClosure();
22+
if (!$schema->hasTable('richdocuments_wopi')) {
23+
return null;
24+
}
25+
26+
$table = $schema->getTable('richdocuments_wopi');
27+
if (!$table->hasColumn('guest_displayname')) {
28+
return null;
29+
}
30+
31+
$column = $table->getColumn('guest_displayname');
32+
if ($column->getLength() === 255) {
33+
return null;
34+
}
35+
36+
$column->setLength(255);
37+
return $schema;
38+
}
39+
}

0 commit comments

Comments
 (0)