public function deletePost(array $formData, array $blogPost = []) : bool
{
$this->db->beginTransaction();
try {
if (!empty($formData['create_redirect'])) {
$blogUrl = \implode('/', ['blog', $blogPost['blogyear'], $blogPost['blogmonth'] > 9 ? $blogPost['blogmonth'] : '0' . $blogPost['blogmonth'], $blogPost['slug']]);
try {
if (\preg_match('#^https?://#', $formData['redirect_url'])) {
$cabin = $this->getCabinNameFromURL($formData['redirect_url']);
} else {
$cabin = $this->cabin;
}
$this->db->insert('airship_custom_redirect', ['oldpath' => $blogUrl, 'newpath' => $formData['redirect_url'], 'cabin' => $cabin, 'same_cabin' => $cabin === $this->cabin]);
} catch (CabinNotFound $ex) {
$this->db->insert('airship_custom_redirect', ['oldpath' => $blogUrl, 'newpath' => $formData['redirect_url'], 'cabin' => $this->cabin, 'same_cabin' => false]);
}
}
$this->db->delete('hull_blog_post_versions', ['post' => $blogPost['postid']]);
$this->db->delete('hull_blog_post_tags', ['postid' => $blogPost['postid']]);
$this->db->delete('hull_blog_comments', ['blogpost' => $blogPost['postid']]);
$this->db->delete('hull_blog_posts', ['postid' => $blogPost['postid']]);
} catch (DBException $ex) {
$this->db->rollBack();
return false;
}
\Airship\clear_cache();
return $this->db->commit();
}