Use a combined unique index
This commit is contained in:
parent
425440ec24
commit
b2dadf0f92
|
@ -470,7 +470,7 @@ CREATE TABLE IF NOT EXISTS `delayed-post` (
|
||||||
`uid` mediumint unsigned COMMENT 'Owner User id',
|
`uid` mediumint unsigned COMMENT 'Owner User id',
|
||||||
`delayed` datetime COMMENT 'delay time',
|
`delayed` datetime COMMENT 'delay time',
|
||||||
PRIMARY KEY(`id`),
|
PRIMARY KEY(`id`),
|
||||||
UNIQUE INDEX `uri` (`uri`(190)),
|
UNIQUE INDEX `uid_uri` (`uid`,`uri`(190)),
|
||||||
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
|
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
|
||||||
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be posted at a later time';
|
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be posted at a later time';
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ class Delayed
|
||||||
*/
|
*/
|
||||||
public static function add(string $delayed, array $item, int $notify = 0, array $taglist = [], array $attachments = [])
|
public static function add(string $delayed, array $item, int $notify = 0, array $taglist = [], array $attachments = [])
|
||||||
{
|
{
|
||||||
if (empty($item['uri']) || empty($item['uid']) || self::exists($item['uri'])) {
|
if (empty($item['uri']) || empty($item['uid']) || self::exists($item['uri'], $item['uid'])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,9 +59,9 @@ class Delayed
|
||||||
*
|
*
|
||||||
* @return bool delete success
|
* @return bool delete success
|
||||||
*/
|
*/
|
||||||
private static function delete(string $uri)
|
private static function delete(string $uri, int $uid)
|
||||||
{
|
{
|
||||||
return DBA::delete('delayed-post', ['uri' => $uri]);
|
return DBA::delete('delayed-post', ['uri' => $uri, 'uid' => $uid]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,9 +71,9 @@ class Delayed
|
||||||
*
|
*
|
||||||
* @return bool "true" if an entry with that URI exists
|
* @return bool "true" if an entry with that URI exists
|
||||||
*/
|
*/
|
||||||
public static function exists(string $uri)
|
public static function exists(string $uri, int $uid)
|
||||||
{
|
{
|
||||||
return DBA::exists('delayed-post', ['uri' => $uri]);
|
return DBA::exists('delayed-post', ['uri' => $uri, 'uid' => $uid]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -93,7 +93,7 @@ class Delayed
|
||||||
|
|
||||||
// It should always contain an URI since this is needed to create a delayed post entry
|
// It should always contain an URI since this is needed to create a delayed post entry
|
||||||
if (!empty($item['uri'])) {
|
if (!empty($item['uri'])) {
|
||||||
$result = self::delete($item['uri']);
|
$result = self::delete($item['uri'], $item['uid']);
|
||||||
Logger::notice('Delayed post entry deleted', ['result' => $result, 'uri' => $item['uri']]);
|
Logger::notice('Delayed post entry deleted', ['result' => $result, 'uri' => $item['uri']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -615,7 +615,7 @@ class Feed
|
||||||
}
|
}
|
||||||
|
|
||||||
$condition = ['uid' => $item['uid'], 'uri' => $item['uri']];
|
$condition = ['uid' => $item['uid'], 'uri' => $item['uri']];
|
||||||
if (!Item::exists($condition) && !Post\Delayed::exists($item["uri"])) {
|
if (!Item::exists($condition) && !Post\Delayed::exists($item["uri"], $item['uid'])) {
|
||||||
$postings[] = ['item' => $item, 'notify' => $notify,
|
$postings[] = ['item' => $item, 'notify' => $notify,
|
||||||
'taglist' => $taglist, 'attachments' => $attachments];
|
'taglist' => $taglist, 'attachments' => $attachments];
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -537,7 +537,7 @@ return [
|
||||||
],
|
],
|
||||||
"indexes" => [
|
"indexes" => [
|
||||||
"PRIMARY" => ["id"],
|
"PRIMARY" => ["id"],
|
||||||
"uri" => ["UNIQUE", "uri(190)"],
|
"uid_uri" => ["UNIQUE", "uid", "uri(190)"],
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"diaspora-interaction" => [
|
"diaspora-interaction" => [
|
||||||
|
|
Loading…
Reference in New Issue
Block a user