forked from GithubBackups/vichan
Delete stale unreferenced ban appeals via foreign key constrain
This commit is contained in:
parent
00cc1f434d
commit
e4707ee2a8
@ -1044,10 +1044,6 @@ function mod_ban_appeals() {
|
|||||||
if (!hasPermission($config['mod']['view_ban_appeals']))
|
if (!hasPermission($config['mod']['view_ban_appeals']))
|
||||||
error($config['error']['noaccess']);
|
error($config['error']['noaccess']);
|
||||||
|
|
||||||
// Remove stale ban appeals
|
|
||||||
query("DELETE FROM ``ban_appeals`` WHERE NOT EXISTS (SELECT 1 FROM ``bans`` WHERE `ban_id` = ``bans``.`id`)")
|
|
||||||
or error(db_error());
|
|
||||||
|
|
||||||
if (isset($_POST['appeal_id']) && (isset($_POST['unban']) || isset($_POST['deny']))) {
|
if (isset($_POST['appeal_id']) && (isset($_POST['unban']) || isset($_POST['deny']))) {
|
||||||
if (!hasPermission($config['mod']['ban_appeals']))
|
if (!hasPermission($config['mod']['ban_appeals']))
|
||||||
error($config['error']['noaccess']);
|
error($config['error']['noaccess']);
|
||||||
|
@ -294,7 +294,8 @@ CREATE TABLE IF NOT EXISTS `ban_appeals` (
|
|||||||
`message` text NOT NULL,
|
`message` text NOT NULL,
|
||||||
`denied` tinyint(1) NOT NULL,
|
`denied` tinyint(1) NOT NULL,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
KEY `ban_id` (`ban_id`)
|
KEY `ban_id` (`ban_id`),
|
||||||
|
CONSTRAINT `fk_ban_id` FOREIGN KEY (`ban_id`) REFERENCES `bans`(`id`) ON DELETE CASCADE
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1 ;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1 ;
|
||||||
|
|
||||||
-- --------------------------------------------------------
|
-- --------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user