Skip to content

Commit

Permalink
Don't save tags on deleted issues - fixes #240
Browse files Browse the repository at this point in the history
  • Loading branch information
Alanaktion committed Sep 8, 2016
1 parent 52eb072 commit 3dba106
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions app/model/issue.php
Expand Up @@ -380,18 +380,18 @@ public function save($notify = true) {
*/
function saveTags() {
$tag = new \Model\Issue\Tag;
$issue_id = $this->id;
$str = $this->description;
$count = preg_match_all("/(?<=[^a-z\\/&]#|^#)[a-z][a-z0-9_-]*[a-z0-9]+(?=[^a-z\\/]|$)/i", $str, $matches);
if($issue_id) {
$tag->deleteByIssueId($issue_id);
}
if ($count) {
foreach ($matches[0] as $match) {
$tag->reset();
$tag->tag = preg_replace("/[_-]+/", "-", ltrim($match, "#"));
$tag->issue_id = $issue_id;
$tag->save();
if ($this->id) {
$tag->deleteByIssueId($this->id);
}
if (!$this->deleted_date) {
$count = preg_match_all("/(?<=[^a-z\\/&]#|^#)[a-z][a-z0-9_-]*[a-z0-9]+(?=[^a-z\\/]|$)/i", $this->description, $matches);
if ($count) {
foreach ($matches[0] as $match) {
$tag->reset();
$tag->tag = preg_replace("/[_-]+/", "-", ltrim($match, "#"));
$tag->issue_id = $this->id;
$tag->save();
}
}
}
return $this;
Expand Down

0 comments on commit 3dba106

Please sign in to comment.