Fix error when purging tags that have already been erased

This commit is contained in:
Dan Stillman 2008-10-24 23:03:53 +00:00
parent 56eb416e3e
commit 4f2bcb15d5
2 changed files with 7 additions and 9 deletions

View file

@ -443,7 +443,7 @@ Zotero.Tag.prototype.serialize = function () {
/** /**
* Remove tag from all linked items * Remove tag from all linked items
* *
* Tags.erase() should be used externally instead of this * Tags.erase() should be used instead of tag.erase() for deleting multiple tags
* *
* Actual deletion of tag occurs in Zotero.Tags.purge() * Actual deletion of tag occurs in Zotero.Tags.purge()
*/ */
@ -484,6 +484,9 @@ Zotero.Tag.prototype.erase = function () {
itemTags.push(itemID + '-' + this.id); itemTags.push(itemID + '-' + this.id);
} }
this.unload(this.id);
Zotero.Notifier.trigger('remove', 'item-tag', itemTags); Zotero.Notifier.trigger('remove', 'item-tag', itemTags);
// Send notification of linked items // Send notification of linked items

View file

@ -315,19 +315,13 @@ Zotero.Tags = new function() {
function erase(ids) { function erase(ids) {
ids = Zotero.flattenArguments(ids); ids = Zotero.flattenArguments(ids);
var erasedTags = {};
Zotero.DB.beginTransaction(); Zotero.DB.beginTransaction();
for each(var id in ids) { for each(var id in ids) {
var tag = this.get(id); var tag = this.get(id);
if (tag) { if (tag) {
erasedTags[id] = tag.serialize();
tag.erase(); tag.erase();
} }
} }
this.unload(ids);
Zotero.DB.commitTransaction(); Zotero.DB.commitTransaction();
} }
@ -364,9 +358,10 @@ Zotero.Tags = new function() {
for each(var tagID in toDelete) { for each(var tagID in toDelete) {
var tag = Zotero.Tags.get(tagID); var tag = Zotero.Tags.get(tagID);
Zotero.debug(tag); if (tag) {
notifierData[tagID] = { old: tag.serialize() } notifierData[tagID] = { old: tag.serialize() }
} }
}
this.unload(toDelete); this.unload(toDelete);