Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 6 additions & 6 deletions .github/workflows/phpunit-32bits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ name: PHPUnit 32bits
on:
pull_request:
paths:
- 'version.php'
- '.github/workflows/phpunit-32bits.yml'
- 'tests/phpunit-autotest.xml'
- "version.php"
- ".github/workflows/phpunit-32bits.yml"
- "tests/phpunit-autotest.xml"
- "lib/private/Snowflake/*"
workflow_dispatch:
schedule:
- cron: "15 1 * * 1-6"
Expand All @@ -30,7 +31,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: ['8.2', '8.3', '8.4']
php-versions: ["8.2", "8.3", "8.4"]

steps:
- name: Checkout server
Expand All @@ -51,8 +52,7 @@ jobs:
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, imagick, intl, json, libxml, mbstring, openssl, pcntl, posix, redis, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite, apcu, ldap
coverage: none
ini-file: development
ini-values:
apc.enabled=on, apc.enable_cli=on, disable_functions= # https://github.com/shivammathur/setup-php/discussions/573
ini-values: apc.enabled=on, apc.enable_cli=on, disable_functions= # https://github.com/shivammathur/setup-php/discussions/573
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down
1 change: 1 addition & 0 deletions apps/settings/lib/SetupChecks/PhpModules.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class PhpModules implements ISetupCheck {
'zlib',
];
protected const RECOMMENDED_MODULES = [
'apcu',
'exif',
'gmp',
'intl',
Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
}
},
"autoload": {
"exclude-from-classmap": ["**/bamarni/composer-bin-plugin/**"],
"exclude-from-classmap": [
"**/bamarni/composer-bin-plugin/**"
],
"files": [
"lib/public/Log/functions.php"
],
Expand All @@ -25,6 +27,7 @@
},
"require": {
"php": "^8.2",
"ext-apcu": "*",
"ext-ctype": "*",
"ext-curl": "*",
"ext-dom": "*",
Expand Down
3 changes: 3 additions & 0 deletions core/BackgroundJobs/MovePreviewJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use OCP\IAppConfig;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Snowflake\IGenerator;
use Override;
use Psr\Log\LoggerInterface;

Expand All @@ -44,6 +45,7 @@ public function __construct(
private readonly IMimeTypeDetector $mimeTypeDetector,
private readonly IMimeTypeLoader $mimeTypeLoader,
private readonly LoggerInterface $logger,
private readonly IGenerator $generator,
IAppDataFactory $appDataFactory,
) {
parent::__construct($time);
Expand Down Expand Up @@ -136,6 +138,7 @@ private function processPreviews(int $fileId, bool $flatPath): void {
$path = $fileId . '/' . $previewFile->getName();
/** @var SimpleFile $previewFile */
$preview = Preview::fromPath($path, $this->mimeTypeDetector);
$preview->setId($this->generator->nextId());
if (!$preview) {
$this->logger->error('Unable to import old preview at path.');
continue;
Expand Down
48 changes: 48 additions & 0 deletions core/Command/SnowflakeDecodeId.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OC\Core\Command;

use OC\Snowflake\Decoder;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class SnowflakeDecodeId extends Base {
protected function configure(): void {
parent::configure();

$this
->setName('decode-snowflake')
->setDescription('Decode Snowflake IDs used by Nextcloud')
->addArgument('snowflake-id', InputArgument::REQUIRED, 'Nextcloud Snowflake ID to decode');
}

protected function execute(InputInterface $input, OutputInterface $output): int {
$snowflakeId = $input->getArgument('snowflake-id');
$data = (new Decoder)->decode($snowflakeId);

$rows = [
['Snowflake ID', $snowflakeId],
['Seconds', $data['seconds']],
['Milliseconds', $data['milliseconds']],
['Created from CLI', $data['isCli'] ? 'yes' : 'no'],
['Server ID', $data['serverId']],
['Sequence ID', $data['sequenceId']],
['Creation timestamp', $data['createdAt']->format('U.v')],
['Creation date', $data['createdAt']->format('Y-m-d H:i:s.v')],
];

$table = new Table($output);
$table->setRows($rows);
$table->render();

return Base::SUCCESS;
}
}
44 changes: 44 additions & 0 deletions core/Migrations/Version33000Date20251023110529.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OC\Core\Migrations;

use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\Attributes\ModifyColumn;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

/**
* Migrate away from auto-increment
*/
#[ModifyColumn(table: 'preview_locations', name: 'id', description: 'Remove auto-increment')]
#[ModifyColumn(table: 'previews', name: 'id', description: 'Remove auto-increment')]
#[ModifyColumn(table: 'preview_versions', name: 'id', description: 'Remove auto-increment')]
class Version33000Date20251023110529 extends SimpleMigrationStep {
/**
* @param Closure(): ISchemaWrapper $schemaClosure The `\Closure` returns a `ISchemaWrapper`
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
$schema = $schemaClosure();

if ($schema->hasTable('preview_locations')) {
$schema->dropAutoincrementColumn('preview_locations', 'id');
}

if ($schema->hasTable('preview_versions')) {
$schema->dropAutoincrementColumn('preview_versions', 'id');
}

if ($schema->hasTable('previews')) {
$schema->dropAutoincrementColumn('previews', 'id');
}

return $schema;
}
}
86 changes: 86 additions & 0 deletions core/Migrations/Version33000Date20251023120529.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OC\Core\Migrations;

use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\IDBConnection;
use OCP\Migration\Attributes\AddIndex;
use OCP\Migration\Attributes\IndexType;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

/**
* Use unique index for preview_locations
*/
#[AddIndex(table: 'preview_locations', type: IndexType::UNIQUE)]
class Version33000Date20251023120529 extends SimpleMigrationStep {
public function __construct(
private readonly IDBConnection $connection,
) {
}

/**
* @param Closure(): ISchemaWrapper $schemaClosure The `\Closure` returns a `ISchemaWrapper`
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();

if ($schema->hasTable('preview_locations')) {
$table = $schema->getTable('preview_locations');
$table->addUniqueIndex(['bucket_name', 'object_store_name'], 'unique_bucket_store');
}

return $schema;
}

public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
// This shouldn't run on a production instance, only daily
$qb = $this->connection->getQueryBuilder();
$qb->select('*')
->from('preview_locations');
$result = $qb->executeQuery();

$set = [];

while ($row = $result->fetch()) {
// Iterate over all the rows with duplicated rows
$id = $row['id'];

if (isset($set[$row['bucket_name'] . '_' . $row['object_store_name']])) {
// duplicate
$authoritativeId = $set[$row['bucket_name'] . '_' . $row['object_store_name']];
$qb = $this->connection->getQueryBuilder();
$qb->select('id')
->from('preview_locations')
->where($qb->expr()->eq('bucket_name', $qb->createNamedParameter($row['bucket_name'])))
->andWhere($qb->expr()->eq('object_store_name', $qb->createNamedParameter($row['object_store_name'])))
->andWhere($qb->expr()->neq('id', $qb->createNamedParameter($authoritativeId)));

$result = $qb->executeQuery();
while ($row = $result->fetch()) {
// Update previews entries to the now de-duplicated id
$qb = $this->connection->getQueryBuilder();
$qb->update('previews')
->set('location_id', $qb->createNamedParameter($id))
->where($qb->expr()->eq('id', $qb->createNamedParameter($row['id'])));
$qb->executeStatement();

$qb = $this->connection->getQueryBuilder();
$qb->delete('preview_locations')
->where($qb->expr()->eq('id', $qb->createNamedParameter($row['id'])));
$qb->executeStatement();
}
break;
}
$set[$row['bucket_name'] . '_' . $row['object_store_name']] = $row['id'];
}
}
}
2 changes: 2 additions & 0 deletions core/register_command.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
use OC\Core\Command\Security\ListCertificates;
use OC\Core\Command\Security\RemoveCertificate;
use OC\Core\Command\SetupChecks;
use OC\Core\Command\SnowflakeDecodeId;
use OC\Core\Command\Status;
use OC\Core\Command\SystemTag\Edit;
use OC\Core\Command\TaskProcessing\EnabledCommand;
Expand Down Expand Up @@ -246,6 +247,7 @@
$application->add(Server::get(BruteforceAttempts::class));
$application->add(Server::get(BruteforceResetAttempts::class));
$application->add(Server::get(SetupChecks::class));
$application->add(Server::get(SnowflakeDecodeId::class));
$application->add(Server::get(Get::class));

$application->add(Server::get(GetCommand::class));
Expand Down
7 changes: 7 additions & 0 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,8 @@
'OCP\\Share_Backend' => $baseDir . '/lib/public/Share_Backend.php',
'OCP\\Share_Backend_Collection' => $baseDir . '/lib/public/Share_Backend_Collection.php',
'OCP\\Share_Backend_File_Dependent' => $baseDir . '/lib/public/Share_Backend_File_Dependent.php',
'OCP\\Snowflake\\IDecoder' => $baseDir . '/lib/public/Snowflake/IDecoder.php',
'OCP\\Snowflake\\IGenerator' => $baseDir . '/lib/public/Snowflake/IGenerator.php',
'OCP\\SpeechToText\\Events\\AbstractTranscriptionEvent' => $baseDir . '/lib/public/SpeechToText/Events/AbstractTranscriptionEvent.php',
'OCP\\SpeechToText\\Events\\TranscriptionFailedEvent' => $baseDir . '/lib/public/SpeechToText/Events/TranscriptionFailedEvent.php',
'OCP\\SpeechToText\\Events\\TranscriptionSuccessfulEvent' => $baseDir . '/lib/public/SpeechToText/Events/TranscriptionSuccessfulEvent.php',
Expand Down Expand Up @@ -1352,6 +1354,7 @@
'OC\\Core\\Command\\Security\\ListCertificates' => $baseDir . '/core/Command/Security/ListCertificates.php',
'OC\\Core\\Command\\Security\\RemoveCertificate' => $baseDir . '/core/Command/Security/RemoveCertificate.php',
'OC\\Core\\Command\\SetupChecks' => $baseDir . '/core/Command/SetupChecks.php',
'OC\\Core\\Command\\SnowflakeDecodeId' => $baseDir . '/core/Command/SnowflakeDecodeId.php',
'OC\\Core\\Command\\Status' => $baseDir . '/core/Command/Status.php',
'OC\\Core\\Command\\SystemTag\\Add' => $baseDir . '/core/Command/SystemTag/Add.php',
'OC\\Core\\Command\\SystemTag\\Delete' => $baseDir . '/core/Command/SystemTag/Delete.php',
Expand Down Expand Up @@ -1527,6 +1530,8 @@
'OC\\Core\\Migrations\\Version32000Date20250731062008' => $baseDir . '/core/Migrations/Version32000Date20250731062008.php',
'OC\\Core\\Migrations\\Version32000Date20250806110519' => $baseDir . '/core/Migrations/Version32000Date20250806110519.php',
'OC\\Core\\Migrations\\Version33000Date20250819110529' => $baseDir . '/core/Migrations/Version33000Date20250819110529.php',
'OC\\Core\\Migrations\\Version33000Date20251023110529' => $baseDir . '/core/Migrations/Version33000Date20251023110529.php',
'OC\\Core\\Migrations\\Version33000Date20251023120529' => $baseDir . '/core/Migrations/Version33000Date20251023120529.php',
'OC\\Core\\Notification\\CoreNotifier' => $baseDir . '/core/Notification/CoreNotifier.php',
'OC\\Core\\ResponseDefinitions' => $baseDir . '/core/ResponseDefinitions.php',
'OC\\Core\\Service\\CronService' => $baseDir . '/core/Service/CronService.php',
Expand Down Expand Up @@ -2103,6 +2108,8 @@
'OC\\Share\\Constants' => $baseDir . '/lib/private/Share/Constants.php',
'OC\\Share\\Helper' => $baseDir . '/lib/private/Share/Helper.php',
'OC\\Share\\Share' => $baseDir . '/lib/private/Share/Share.php',
'OC\\Snowflake\\Decoder' => $baseDir . '/lib/private/Snowflake/Decoder.php',
'OC\\Snowflake\\Generator' => $baseDir . '/lib/private/Snowflake/Generator.php',
'OC\\SpeechToText\\SpeechToTextManager' => $baseDir . '/lib/private/SpeechToText/SpeechToTextManager.php',
'OC\\SpeechToText\\TranscriptionJob' => $baseDir . '/lib/private/SpeechToText/TranscriptionJob.php',
'OC\\StreamImage' => $baseDir . '/lib/private/StreamImage.php',
Expand Down
7 changes: 7 additions & 0 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,8 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OCP\\Share_Backend' => __DIR__ . '/../../..' . '/lib/public/Share_Backend.php',
'OCP\\Share_Backend_Collection' => __DIR__ . '/../../..' . '/lib/public/Share_Backend_Collection.php',
'OCP\\Share_Backend_File_Dependent' => __DIR__ . '/../../..' . '/lib/public/Share_Backend_File_Dependent.php',
'OCP\\Snowflake\\IDecoder' => __DIR__ . '/../../..' . '/lib/public/Snowflake/IDecoder.php',
'OCP\\Snowflake\\IGenerator' => __DIR__ . '/../../..' . '/lib/public/Snowflake/IGenerator.php',
'OCP\\SpeechToText\\Events\\AbstractTranscriptionEvent' => __DIR__ . '/../../..' . '/lib/public/SpeechToText/Events/AbstractTranscriptionEvent.php',
'OCP\\SpeechToText\\Events\\TranscriptionFailedEvent' => __DIR__ . '/../../..' . '/lib/public/SpeechToText/Events/TranscriptionFailedEvent.php',
'OCP\\SpeechToText\\Events\\TranscriptionSuccessfulEvent' => __DIR__ . '/../../..' . '/lib/public/SpeechToText/Events/TranscriptionSuccessfulEvent.php',
Expand Down Expand Up @@ -1393,6 +1395,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OC\\Core\\Command\\Security\\ListCertificates' => __DIR__ . '/../../..' . '/core/Command/Security/ListCertificates.php',
'OC\\Core\\Command\\Security\\RemoveCertificate' => __DIR__ . '/../../..' . '/core/Command/Security/RemoveCertificate.php',
'OC\\Core\\Command\\SetupChecks' => __DIR__ . '/../../..' . '/core/Command/SetupChecks.php',
'OC\\Core\\Command\\SnowflakeDecodeId' => __DIR__ . '/../../..' . '/core/Command/SnowflakeDecodeId.php',
'OC\\Core\\Command\\Status' => __DIR__ . '/../../..' . '/core/Command/Status.php',
'OC\\Core\\Command\\SystemTag\\Add' => __DIR__ . '/../../..' . '/core/Command/SystemTag/Add.php',
'OC\\Core\\Command\\SystemTag\\Delete' => __DIR__ . '/../../..' . '/core/Command/SystemTag/Delete.php',
Expand Down Expand Up @@ -1568,6 +1571,8 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OC\\Core\\Migrations\\Version32000Date20250731062008' => __DIR__ . '/../../..' . '/core/Migrations/Version32000Date20250731062008.php',
'OC\\Core\\Migrations\\Version32000Date20250806110519' => __DIR__ . '/../../..' . '/core/Migrations/Version32000Date20250806110519.php',
'OC\\Core\\Migrations\\Version33000Date20250819110529' => __DIR__ . '/../../..' . '/core/Migrations/Version33000Date20250819110529.php',
'OC\\Core\\Migrations\\Version33000Date20251023110529' => __DIR__ . '/../../..' . '/core/Migrations/Version33000Date20251023110529.php',
'OC\\Core\\Migrations\\Version33000Date20251023120529' => __DIR__ . '/../../..' . '/core/Migrations/Version33000Date20251023120529.php',
'OC\\Core\\Notification\\CoreNotifier' => __DIR__ . '/../../..' . '/core/Notification/CoreNotifier.php',
'OC\\Core\\ResponseDefinitions' => __DIR__ . '/../../..' . '/core/ResponseDefinitions.php',
'OC\\Core\\Service\\CronService' => __DIR__ . '/../../..' . '/core/Service/CronService.php',
Expand Down Expand Up @@ -2144,6 +2149,8 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OC\\Share\\Constants' => __DIR__ . '/../../..' . '/lib/private/Share/Constants.php',
'OC\\Share\\Helper' => __DIR__ . '/../../..' . '/lib/private/Share/Helper.php',
'OC\\Share\\Share' => __DIR__ . '/../../..' . '/lib/private/Share/Share.php',
'OC\\Snowflake\\Decoder' => __DIR__ . '/../../..' . '/lib/private/Snowflake/Decoder.php',
'OC\\Snowflake\\Generator' => __DIR__ . '/../../..' . '/lib/private/Snowflake/Generator.php',
'OC\\SpeechToText\\SpeechToTextManager' => __DIR__ . '/../../..' . '/lib/private/SpeechToText/SpeechToTextManager.php',
'OC\\SpeechToText\\TranscriptionJob' => __DIR__ . '/../../..' . '/lib/private/SpeechToText/TranscriptionJob.php',
'OC\\StreamImage' => __DIR__ . '/../../..' . '/lib/private/StreamImage.php',
Expand Down
4 changes: 2 additions & 2 deletions lib/composer/composer/platform_check.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

$issues = array();

if (!(PHP_VERSION_ID >= 80100)) {
$issues[] = 'Your Composer dependencies require a PHP version ">= 8.1.0". You are running ' . PHP_VERSION . '.';
if (!(PHP_VERSION_ID >= 80200)) {
$issues[] = 'Your Composer dependencies require a PHP version ">= 8.2.0". You are running ' . PHP_VERSION . '.';
}

if ($issues) {
Expand Down
2 changes: 1 addition & 1 deletion lib/private/AppFramework/Http/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ private function executeController(Controller $controller, string $methodName):
try {
$response = \call_user_func_array([$controller, $methodName], $arguments);
} catch (\TypeError $e) {
// Only intercept TypeErrors occuring on the first line, meaning that the invocation of the controller method failed.
// Only intercept TypeErrors occurring on the first line, meaning that the invocation of the controller method failed.
// Any other TypeError happens inside the controller method logic and should be logged as normal.
if ($e->getFile() === $this->reflector->getFile() && $e->getLine() === $this->reflector->getStartLine()) {
$this->logger->debug('Failed to call controller method: ' . $e->getMessage(), ['exception' => $e]);
Expand Down
Loading
Loading