diff --git a/src/assigners/a_tag.php b/src/assigners/a_tag.php index 0d2a6e30ee..c405fe17ad 100644 --- a/src/assigners/a_tag.php +++ b/src/assigners/a_tag.php @@ -26,7 +26,7 @@ function __construct($pid, $ltag, $tag = null, $index = null, $override = null) } /** @return self */ function fresh() { - return new Tag_Assignable($this->pid, $this->ltag); + return new Tag_Assignable($this->pid, $this->ltag, $this->_tag); } /** @param Assignable $q * @return bool */ @@ -36,6 +36,14 @@ function match($q) { && ($q->ltag ?? $this->ltag) === $this->ltag && ($q->_index ?? $this->_index) === $this->_index; } + /** @param Assignable $q + * @return bool */ + function equals($q) { + '@phan-var-force Tag_Assignable $q'; + return ($q->pid ?? $this->pid) === $this->pid + && ($q->_tag ?? $this->_tag) === $this->_tag + && ($q->_index ?? $this->_index) === $this->_index; + } static function load(AssignmentState $state) { if (!$state->mark_type("tag", ["pid", "ltag"], "Tag_Assigner::make")) { return; @@ -402,10 +410,16 @@ class Tag_Assigner extends Assigner { /** @var null|int|float * @readonly */ public $index; + /** @var bool + * @readonly */ + public $case_only; function __construct(AssignmentItem $item, AssignmentState $state) { parent::__construct($item, $state); $this->tag = $item["_tag"]; $this->index = $item->post("_index"); + $this->case_only = $item->existed() + && !$item->deleted() + && $item->before->match($item->after); } static function make(AssignmentItem $item, AssignmentState $state) { $prow = $state->prow($item["pid"]); @@ -461,7 +475,7 @@ function execute(AssignmentSet $aset) { if ($this->index === null) { $aset->stage_qe("delete from PaperTag where paperId=? and tag=?", $this->pid, $this->tag); } else { - $aset->stage_qe("insert into PaperTag set paperId=?, tag=?, tagIndex=? on duplicate key update tagIndex=?", $this->pid, $this->tag, $this->index, $this->index); + $aset->stage_qe("insert into PaperTag set paperId=?, tag=?, tagIndex=? on duplicate key update tag=?, tagIndex=?", $this->pid, $this->tag, $this->index, $this->tag, $this->index); } if ($this->index !== null && str_ends_with($this->tag, ':')) { @@ -469,10 +483,12 @@ function execute(AssignmentSet $aset) { $aset->conf->save_refresh_setting("has_colontag", 1); }); } - if ($aset->conf->tags()->is_track($this->tag)) { - $aset->register_update_rights(); + if (!$this->case_only) { + if ($aset->conf->tags()->is_track($this->tag)) { + $aset->register_update_rights(); + } + $aset->user->log_activity("Tag " . ($this->index === null ? "-" : "+") . "#{$this->tag}" . ($this->index ? "#{$this->index}" : ""), $this->pid); } - $aset->user->log_activity("Tag " . ($this->index === null ? "-" : "+") . "#{$this->tag}" . ($this->index ? "#{$this->index}" : ""), $this->pid); $aset->register_notify_tracker($this->pid); } } diff --git a/src/assignmentset.php b/src/assignmentset.php index f8bdf19921..aa8c1ba245 100644 --- a/src/assignmentset.php +++ b/src/assignmentset.php @@ -22,6 +22,12 @@ function match($q) { } return true; } + + /** @param Assignable $q + * @return bool */ + function equals($q) { + return $this->match($q); + } } class AssignmentItem implements ArrayAccess, JsonSerializable { @@ -91,7 +97,7 @@ function changed() { return $this->after && ($this->deleted ? $this->existed - : !$this->existed || !$this->after->match($this->before)); + : !$this->existed || !$this->after->equals($this->before)); } /** @param bool $pre * @param string $offset */