diff options
-rw-r--r-- | .github/workflows/oci.yml | 2 | ||||
-rw-r--r-- | .github/workflows/s3-external.yml | 4 | ||||
-rw-r--r-- | .github/workflows/update-psalm-baseline.yml | 2 | ||||
-rw-r--r-- | apps/dav/lib/HookManager.php | 15 | ||||
-rw-r--r-- | apps/dav/tests/unit/DAV/HookManagerTest.php | 41 | ||||
-rw-r--r-- | apps/files/css/files.scss | 34 | ||||
-rw-r--r-- | apps/files_sharing/lib/External/Scanner.php | 2 | ||||
-rw-r--r-- | core/Application.php | 5 | ||||
-rw-r--r-- | core/Command/Db/AddMissingIndices.php | 8 | ||||
-rw-r--r-- | core/Migrations/Version13000Date20170718121200.php | 4 | ||||
-rw-r--r-- | lib/private/App/PlatformRepository.php | 4 | ||||
-rw-r--r-- | lib/private/DB/SchemaWrapper.php | 13 | ||||
-rw-r--r-- | lib/private/Installer.php | 9 | ||||
-rw-r--r-- | lib/private/Log.php | 27 | ||||
-rw-r--r-- | lib/private/legacy/OC_Util.php | 1 | ||||
-rw-r--r-- | lib/public/DB/ISchemaWrapper.php | 15 |
16 files changed, 134 insertions, 52 deletions
diff --git a/.github/workflows/oci.yml b/.github/workflows/oci.yml index 31614b8f38f..2f2ee8f570c 100644 --- a/.github/workflows/oci.yml +++ b/.github/workflows/oci.yml @@ -41,7 +41,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} - extensions: mbstring, iconv, fileinfo, intl, sqlite, pdo_sqlite, oci8 + extensions: mbstring, fileinfo, intl, sqlite, pdo_sqlite, oci8 tools: phpunit:8.5.2 coverage: none diff --git a/.github/workflows/s3-external.yml b/.github/workflows/s3-external.yml index 497de81ae2f..dedab6b0c16 100644 --- a/.github/workflows/s3-external.yml +++ b/.github/workflows/s3-external.yml @@ -45,7 +45,7 @@ jobs: with: php-version: ${{ matrix.php-versions }} tools: phpunit - extensions: mbstring, iconv, fileinfo, intl, sqlite, pdo_sqlite, zip, gd + extensions: mbstring, fileinfo, intl, sqlite, pdo_sqlite, zip, gd - name: Set up Nextcloud run: | @@ -94,7 +94,7 @@ jobs: with: php-version: ${{ matrix.php-versions }} tools: phpunit - extensions: mbstring, iconv, fileinfo, intl, sqlite, pdo_sqlite, zip, gd + extensions: mbstring, fileinfo, intl, sqlite, pdo_sqlite, zip, gd - name: Set up Nextcloud run: | diff --git a/.github/workflows/update-psalm-baseline.yml b/.github/workflows/update-psalm-baseline.yml index b5b38cd888b..9fdaeffe22c 100644 --- a/.github/workflows/update-psalm-baseline.yml +++ b/.github/workflows/update-psalm-baseline.yml @@ -18,7 +18,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: 7.4 - extensions: ctype,curl,dom,fileinfo,gd,iconv,intl,json,mbstring,openssl,pdo_sqlite,posix,sqlite,xml,zip + extensions: ctype,curl,dom,fileinfo,gd,intl,json,mbstring,openssl,pdo_sqlite,posix,sqlite,xml,zip coverage: none - name: Composer install diff --git a/apps/dav/lib/HookManager.php b/apps/dav/lib/HookManager.php index 558aad72c03..1cb6e604524 100644 --- a/apps/dav/lib/HookManager.php +++ b/apps/dav/lib/HookManager.php @@ -59,6 +59,9 @@ class HookManager { private $calendarsToDelete = []; /** @var array */ + private $subscriptionsToDelete = []; + + /** @var array */ private $addressBooksToDelete = []; /** @var EventDispatcherInterface */ @@ -112,9 +115,11 @@ class HookManager { public function preDeleteUser($params) { $uid = $params['uid']; + $userPrincipalUri = 'principals/users/' . $uid; $this->usersToDelete[$uid] = $this->userManager->get($uid); - $this->calendarsToDelete = $this->calDav->getUsersOwnCalendars('principals/users/' . $uid); - $this->addressBooksToDelete = $this->cardDav->getUsersOwnAddressBooks('principals/users/' . $uid); + $this->calendarsToDelete = $this->calDav->getUsersOwnCalendars($userPrincipalUri); + $this->subscriptionsToDelete = $this->calDav->getSubscriptionsForUser($userPrincipalUri); + $this->addressBooksToDelete = $this->cardDav->getUsersOwnAddressBooks($userPrincipalUri); } public function preUnassignedUserId($uid) { @@ -130,6 +135,12 @@ class HookManager { foreach ($this->calendarsToDelete as $calendar) { $this->calDav->deleteCalendar($calendar['id']); } + + foreach ($this->subscriptionsToDelete as $subscription) { + $this->calDav->deleteSubscription( + $subscription['id'], + ); + } $this->calDav->deleteAllSharesByUser('principals/users/' . $uid); foreach ($this->addressBooksToDelete as $addressBook) { diff --git a/apps/dav/tests/unit/DAV/HookManagerTest.php b/apps/dav/tests/unit/DAV/HookManagerTest.php index 8b8fad4d7cf..481f129ae90 100644 --- a/apps/dav/tests/unit/DAV/HookManagerTest.php +++ b/apps/dav/tests/unit/DAV/HookManagerTest.php @@ -38,6 +38,7 @@ use OCA\DAV\HookManager; use OCP\IL10N; use OCP\IUser; use OCP\IUserManager; +use PHPUnit\Framework\MockObject\MockObject; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Test\TestCase; @@ -45,7 +46,7 @@ class HookManagerTest extends TestCase { /** @var IL10N */ private $l10n; - /** @var EventDispatcherInterface | \PHPUnit\Framework\MockObject\MockObject */ + /** @var EventDispatcherInterface | MockObject */ private $eventDispatcher; protected function setUp(): void { @@ -66,17 +67,17 @@ class HookManagerTest extends TestCase { ->getMock(); $user->expects($this->once())->method('getUID')->willReturn('newUser'); - /** @var IUserManager | \PHPUnit\Framework\MockObject\MockObject $userManager */ + /** @var IUserManager | MockObject $userManager */ $userManager = $this->getMockBuilder(IUserManager::class) ->disableOriginalConstructor() ->getMock(); - /** @var SyncService | \PHPUnit\Framework\MockObject\MockObject $syncService */ + /** @var SyncService | MockObject $syncService */ $syncService = $this->getMockBuilder(SyncService::class) ->disableOriginalConstructor() ->getMock(); - /** @var CalDavBackend | \PHPUnit\Framework\MockObject\MockObject $cal */ + /** @var CalDavBackend | MockObject $cal */ $cal = $this->getMockBuilder(CalDavBackend::class) ->disableOriginalConstructor() ->getMock(); @@ -85,7 +86,7 @@ class HookManagerTest extends TestCase { 'principals/users/newUser', 'personal', ['{DAV:}displayname' => 'Personal']); - /** @var CardDavBackend | \PHPUnit\Framework\MockObject\MockObject $card */ + /** @var CardDavBackend | MockObject $card */ $card = $this->getMockBuilder(CardDavBackend::class) ->disableOriginalConstructor() ->getMock(); @@ -104,24 +105,24 @@ class HookManagerTest extends TestCase { ->getMock(); $user->expects($this->once())->method('getUID')->willReturn('newUser'); - /** @var IUserManager | \PHPUnit\Framework\MockObject\MockObject $userManager */ + /** @var IUserManager | MockObject $userManager */ $userManager = $this->getMockBuilder(IUserManager::class) ->disableOriginalConstructor() ->getMock(); - /** @var SyncService | \PHPUnit\Framework\MockObject\MockObject $syncService */ + /** @var SyncService | MockObject $syncService */ $syncService = $this->getMockBuilder(SyncService::class) ->disableOriginalConstructor() ->getMock(); - /** @var CalDavBackend | \PHPUnit\Framework\MockObject\MockObject $cal */ + /** @var CalDavBackend | MockObject $cal */ $cal = $this->getMockBuilder(CalDavBackend::class) ->disableOriginalConstructor() ->getMock(); $cal->expects($this->once())->method('getCalendarsForUserCount')->willReturn(1); $cal->expects($this->never())->method('createCalendar'); - /** @var CardDavBackend | \PHPUnit\Framework\MockObject\MockObject $card */ + /** @var CardDavBackend | MockObject $card */ $card = $this->getMockBuilder(CardDavBackend::class) ->disableOriginalConstructor() ->getMock(); @@ -138,17 +139,17 @@ class HookManagerTest extends TestCase { ->getMock(); $user->expects($this->once())->method('getUID')->willReturn('newUser'); - /** @var IUserManager | \PHPUnit\Framework\MockObject\MockObject $userManager */ + /** @var IUserManager | MockObject $userManager */ $userManager = $this->getMockBuilder(IUserManager::class) ->disableOriginalConstructor() ->getMock(); - /** @var SyncService | \PHPUnit\Framework\MockObject\MockObject $syncService */ + /** @var SyncService | MockObject $syncService */ $syncService = $this->getMockBuilder(SyncService::class) ->disableOriginalConstructor() ->getMock(); - /** @var CalDavBackend | \PHPUnit\Framework\MockObject\MockObject $cal */ + /** @var CalDavBackend | MockObject $cal */ $cal = $this->getMockBuilder(CalDavBackend::class) ->disableOriginalConstructor() ->getMock(); @@ -157,7 +158,7 @@ class HookManagerTest extends TestCase { 'principals/users/newUser', 'personal', ['{DAV:}displayname' => 'Personal']); - /** @var CardDavBackend | \PHPUnit\Framework\MockObject\MockObject $card */ + /** @var CardDavBackend | MockObject $card */ $card = $this->getMockBuilder(CardDavBackend::class) ->disableOriginalConstructor() ->getMock(); @@ -175,30 +176,34 @@ class HookManagerTest extends TestCase { ->disableOriginalConstructor() ->getMock(); - /** @var IUserManager | \PHPUnit\Framework\MockObject\MockObject $userManager */ + /** @var IUserManager | MockObject $userManager */ $userManager = $this->getMockBuilder(IUserManager::class) ->disableOriginalConstructor() ->getMock(); $userManager->expects($this->once())->method('get')->willReturn($user); - /** @var SyncService | \PHPUnit\Framework\MockObject\MockObject $syncService */ + /** @var SyncService | MockObject $syncService */ $syncService = $this->getMockBuilder(SyncService::class) ->disableOriginalConstructor() ->getMock(); $syncService->expects($this->once()) ->method('deleteUser'); - /** @var CalDavBackend | \PHPUnit\Framework\MockObject\MockObject $cal */ + /** @var CalDavBackend | MockObject $cal */ $cal = $this->getMockBuilder(CalDavBackend::class) ->disableOriginalConstructor() ->getMock(); $cal->expects($this->once())->method('getUsersOwnCalendars')->willReturn([ ['id' => 'personal'] ]); - $cal->expects($this->once())->method('deleteCalendar'); + $cal->expects($this->once())->method('getSubscriptionsForUser')->willReturn([ + ['id' => 'some-subscription'] + ]); + $cal->expects($this->once())->method('deleteCalendar')->with('personal'); + $cal->expects($this->once())->method('deleteSubscription')->with('some-subscription'); $cal->expects($this->once())->method('deleteAllSharesByUser'); - /** @var CardDavBackend | \PHPUnit\Framework\MockObject\MockObject $card */ + /** @var CardDavBackend | MockObject $card */ $card = $this->getMockBuilder(CardDavBackend::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/files/css/files.scss b/apps/files/css/files.scss index af794264083..32f8af6327a 100644 --- a/apps/files/css/files.scss +++ b/apps/files/css/files.scss @@ -420,11 +420,6 @@ table { padding: 0 20px 0 0; } } - - .uploadtext { - position: absolute; - left: 55px; - } } .hide-hidden-files #filestable #fileList tr.hidden-file, @@ -452,13 +447,22 @@ table td.filename .nametext .innernametext { /* for smaller resolutions - see mobile.css */ table td.filename .uploadtext { + position: absolute; font-weight: normal; - margin-left: 55px; - margin-top: 5px; + // checkbox width + margin-left: 50px; + left: 0; + bottom: 0; height: 20px; - padding: 10px 0; + padding: 0 4px; + // align with file name + padding-left: 1px; font-size: 11px; - opacity: .5; + // double the font size + line-height: 22px; + color: var(--color-text-maxcontrast); + text-overflow: ellipsis; + white-space: nowrap; } table td.selection { @@ -975,6 +979,18 @@ table.dragshadow td.size { } } + .uploadtext { + width: 100%; + margin: 0; + top: 0; + bottom: auto; + // checkbox align + height: 28px; + padding-top: 4px; + // checkbox margins + padding-left: calc(44px - 16px); + } + .name { height: 100%; border-radius: var(--border-radius); diff --git a/apps/files_sharing/lib/External/Scanner.php b/apps/files_sharing/lib/External/Scanner.php index 71187707ad7..483f1041c01 100644 --- a/apps/files_sharing/lib/External/Scanner.php +++ b/apps/files_sharing/lib/External/Scanner.php @@ -39,7 +39,7 @@ class Scanner extends \OC\Files\Cache\Scanner { /** {@inheritDoc} */ public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true) { if (!$this->storage->remoteIsOwnCloud()) { - return parent::scan($path, $recursive, $recursive, $lock); + return parent::scan($path, $recursive, $reuse, $lock); } $this->scanAll(); diff --git a/core/Application.php b/core/Application.php index 77cd221bb83..c127d94622f 100644 --- a/core/Application.php +++ b/core/Application.php @@ -32,6 +32,7 @@ namespace OC\Core; +use Doctrine\DBAL\Platforms\PostgreSQL94Platform; use OC\Authentication\Events\RemoteWipeFinished; use OC\Authentication\Events\RemoteWipeStarted; use OC\Authentication\Listeners\RemoteWipeActivityListener; @@ -115,6 +116,10 @@ class Application extends App { if (!$table->hasIndex('fs_size')) { $subject->addHintForMissingSubject($table->getName(), 'fs_size'); } + + if (!$table->hasIndex('fs_storage_path_prefix') && !$schema->getDatabasePlatform() instanceof PostgreSQL94Platform) { + $subject->addHintForMissingSubject($table->getName(), 'fs_storage_path_prefix'); + } } if ($schema->hasTable('twofactor_providers')) { diff --git a/core/Command/Db/AddMissingIndices.php b/core/Command/Db/AddMissingIndices.php index 824c7073bd3..518b0e638cf 100644 --- a/core/Command/Db/AddMissingIndices.php +++ b/core/Command/Db/AddMissingIndices.php @@ -33,6 +33,7 @@ declare(strict_types=1); namespace OC\Core\Command\Db; +use Doctrine\DBAL\Platforms\PostgreSQL94Platform; use OC\DB\Connection; use OC\DB\SchemaWrapper; use OCP\IDBConnection; @@ -144,6 +145,13 @@ class AddMissingIndices extends Command { $updated = true; $output->writeln('<info>Filecache table updated successfully.</info>'); } + if (!$table->hasIndex('fs_storage_path_prefix') && !$schema->getDatabasePlatform() instanceof PostgreSQL94Platform) { + $output->writeln('<info>Adding additional path index to the filecache table, this can take some time...</info>'); + $table->addIndex(['storage', 'path'], 'fs_storage_path_prefix', [], ['lengths' => [null, 64]]); + $this->connection->migrateToSchema($schema->getWrappedSchema()); + $updated = true; + $output->writeln('<info>Filecache table updated successfully.</info>'); + } } $output->writeln('<info>Check indices of the twofactor_providers table.</info>'); diff --git a/core/Migrations/Version13000Date20170718121200.php b/core/Migrations/Version13000Date20170718121200.php index b020effe5aa..393fe4f6ad6 100644 --- a/core/Migrations/Version13000Date20170718121200.php +++ b/core/Migrations/Version13000Date20170718121200.php @@ -30,6 +30,7 @@ namespace OC\Core\Migrations; +use Doctrine\DBAL\Platforms\PostgreSQL94Platform; use OCP\DB\Types; use OCP\DB\ISchemaWrapper; use OCP\IDBConnection; @@ -262,6 +263,9 @@ class Version13000Date20170718121200 extends SimpleMigrationStep { $table->addIndex(['storage', 'size', 'fileid'], 'fs_storage_size'); $table->addIndex(['mtime'], 'fs_mtime'); $table->addIndex(['size'], 'fs_size'); + if (!$schema->getDatabasePlatform() instanceof PostgreSQL94Platform) { + $table->addIndex(['storage', 'path'], 'fs_storage_path_prefix', [], ['lengths' => [null, 64]]); + } } if (!$schema->hasTable('group_user')) { diff --git a/lib/private/App/PlatformRepository.php b/lib/private/App/PlatformRepository.php index 816470e1202..5dd312582d6 100644 --- a/lib/private/App/PlatformRepository.php +++ b/lib/private/App/PlatformRepository.php @@ -67,10 +67,6 @@ class PlatformRepository { $prettyVersion = $curlVersion['version']; break; - case 'iconv': - $prettyVersion = ICONV_VERSION; - break; - case 'intl': $name = 'ICU'; if (defined('INTL_ICU_VERSION')) { diff --git a/lib/private/DB/SchemaWrapper.php b/lib/private/DB/SchemaWrapper.php index 20ae5b6faa6..9f7623bac44 100644 --- a/lib/private/DB/SchemaWrapper.php +++ b/lib/private/DB/SchemaWrapper.php @@ -24,6 +24,8 @@ namespace OC\DB; +use Doctrine\DBAL\Exception; +use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\Schema; use OCP\DB\ISchemaWrapper; @@ -130,4 +132,15 @@ class SchemaWrapper implements ISchemaWrapper { public function getTables() { return $this->schema->getTables(); } + + /** + * Gets the DatabasePlatform for the database. + * + * @return AbstractPlatform + * + * @throws Exception + */ + public function getDatabasePlatform() { + return $this->connection->getDatabasePlatform(); + } } diff --git a/lib/private/Installer.php b/lib/private/Installer.php index 65740c32c57..2d09065be5c 100644 --- a/lib/private/Installer.php +++ b/lib/private/Installer.php @@ -159,7 +159,7 @@ class Installer { } } else { $ms = new \OC\DB\MigrationService($info['id'], \OC::$server->get(Connection::class)); - $ms->migrate('latest', true); + $ms->migrate('latest', !$previousVersion); } if ($previousVersion) { OC_App::executeRepairSteps($appId, $info['repair-steps']['post-migration']); @@ -606,6 +606,8 @@ class Installer { $appPath = OC_App::getAppPath($app); \OC_App::registerAutoloading($app, $appPath); + $config = \OC::$server->getConfig(); + if (is_file("$appPath/appinfo/database.xml")) { try { OC_DB::createDbFromStructure("$appPath/appinfo/database.xml"); @@ -617,8 +619,9 @@ class Installer { ); } } else { + $previousVersion = $config->getAppValue($app, 'installed_version', false); $ms = new \OC\DB\MigrationService($app, \OC::$server->get(Connection::class)); - $ms->migrate('latest', true); + $ms->migrate('latest', !$previousVersion); } //run appinfo/install.php @@ -632,8 +635,6 @@ class Installer { OC_App::executeRepairSteps($app, $info['repair-steps']['install']); - $config = \OC::$server->getConfig(); - $config->setAppValue($app, 'installed_version', OC_App::getAppVersion($app)); if (array_key_exists('ocsid', $info)) { $config->setAppValue($app, 'ocsid', $info['ocsid']); diff --git a/lib/private/Log.php b/lib/private/Log.php index db86aa8bfe3..3c3f22293d9 100644 --- a/lib/private/Log.php +++ b/lib/private/Log.php @@ -44,6 +44,7 @@ use OCP\ILogger; use OCP\Log\IFileBased; use OCP\Log\IWriter; use OCP\Support\CrashReport\IRegistry; +use function strtr; /** * logging utilities @@ -207,13 +208,7 @@ class Log implements ILogger, IDataLogger { array_walk($context, [$this->normalizer, 'format']); $app = $context['app'] ?? 'no app in context'; - - // interpolate $message as defined in PSR-3 - $replace = []; - foreach ($context as $key => $val) { - $replace['{' . $key . '}'] = $val; - } - $message = strtr($message, $replace); + $message = $this->interpolateMessage($context, $message); try { if ($level >= $minLevel) { @@ -316,7 +311,7 @@ class Log implements ILogger, IDataLogger { $serializer = new ExceptionSerializer($this->config); $data = $serializer->serializeException($exception); - $data['CustomMessage'] = $context['message'] ?? '--'; + $data['CustomMessage'] = $this->interpolateMessage($context, $context['message'] ?? '--'); $minLevel = $this->getLogLevel($context); @@ -377,4 +372,20 @@ class Log implements ILogger, IDataLogger { } throw new \RuntimeException('Log implementation has no path'); } + + /** + * Interpolate $message as defined in PSR-3 + * + * @param array $context + * @param string $message + * + * @return string + */ + private function interpolateMessage(array $context, string $message): string { + $replace = []; + foreach ($context as $key => $val) { + $replace['{' . $key . '}'] = $val; + } + return strtr($message, $replace); + } } diff --git a/lib/private/legacy/OC_Util.php b/lib/private/legacy/OC_Util.php index 64a1083805d..9cf30bb508d 100644 --- a/lib/private/legacy/OC_Util.php +++ b/lib/private/legacy/OC_Util.php @@ -854,7 +854,6 @@ class OC_Util { 'json_encode' => 'JSON', 'gd_info' => 'GD', 'gzencode' => 'zlib', - 'iconv' => 'iconv', 'simplexml_load_string' => 'SimpleXML', 'hash' => 'HASH Message Digest Framework', 'curl_init' => 'cURL', diff --git a/lib/public/DB/ISchemaWrapper.php b/lib/public/DB/ISchemaWrapper.php index 3d58a10d2d2..85b09aee10e 100644 --- a/lib/public/DB/ISchemaWrapper.php +++ b/lib/public/DB/ISchemaWrapper.php @@ -23,6 +23,9 @@ namespace OCP\DB; +use Doctrine\DBAL\Exception; +use Doctrine\DBAL\Platforms\AbstractPlatform; + /** * Interface ISchemaWrapper * @@ -82,7 +85,7 @@ interface ISchemaWrapper { * @since 13.0.0 */ public function getTableNames(); - + /** * Gets all table names * @@ -90,4 +93,14 @@ interface ISchemaWrapper { * @since 13.0.0 */ public function getTableNamesWithoutPrefix(); + + /** + * Gets the DatabasePlatform for the database. + * + * @return AbstractPlatform + * + * @throws Exception + * @since 21.0.8 + */ + public function getDatabasePlatform(); } |