Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Do not merge] Unique constraint for duplicate child shares #41249

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -1651,7 +1651,7 @@ def acceptance(ctx):
"federatedServerVersions": [""],
"browsers": ["chrome"],
"phpVersions": [DEFAULT_PHP_VERSION],
"databases": ["mariadb:10.2"],
"databases": ["postgres:9.2"],
"federatedPhpVersion": DEFAULT_PHP_VERSION,
"federatedServerNeeded": False,
"federatedDb": "",
Expand Down
27 changes: 27 additions & 0 deletions core/Migrations/Version20240507143125.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
namespace OC\Migrations;

use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use OCP\IDBConnection;
use OCP\Migration\ISqlMigration;

class Version20240507143125 implements ISqlMigration {
public function sql(IDBConnection $connection) {
$dbPlatform = $connection->getDatabasePlatform();
if ($dbPlatform instanceof PostgreSqlPlatform || $dbPlatform instanceof SqlitePlatform) {
return ["CREATE UNIQUE INDEX child_share_unique ON oc_share (share_with, parent)
WHERE parent IS NOT NULL AND share_type = 2"];
}

if ($dbPlatform instanceof MySqlPlatform) {
// This should be preceise enough as mysql ignores nulls in unique indexes
return [
"CREATE UNIQUE INDEX child_share_unique ON oc_share (item_source, share_with, share_type, parent);"
];
}

return [];
}
}
2 changes: 1 addition & 1 deletion lib/private/Share20/DefaultShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ public function getShareById($id, $recipientId = null) {
// and, depending on the database, the query may throw an exception
// with a message like "invalid input syntax for type integer"
// So throw ShareNotFound now.
throw new ShareNotFound();
throw new ShareNotFound("invalid id: $id");
}
$qb = $this->dbConn->getQueryBuilder();

Expand Down
323 changes: 0 additions & 323 deletions tests/lib/Repair/RepairSubSharesTest.php

This file was deleted.

Loading