From 551c8a36a7d2017c74c8aaf83d674f8588f32505 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 17 Mar 2009 08:23:45 +0000 Subject: [PATCH] Fix upgrade error "counts[0] is undefined" (or "counts[1]") --- chrome/content/zotero/xpcom/schema.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/schema.js b/chrome/content/zotero/xpcom/schema.js index adc1f264b..0dd1045f7 100644 --- a/chrome/content/zotero/xpcom/schema.js +++ b/chrome/content/zotero/xpcom/schema.js @@ -1725,9 +1725,13 @@ Zotero.Schema = new function(){ continue; } - // Use most frequent var counts = Zotero.DB.query("SELECT tag, COUNT(*) AS numItems FROM tags NATURAL JOIN itemTags WHERE tag LIKE ? GROUP BY tag ORDER BY numItems DESC", l); - if (counts[0].numItems != counts[1].numItems) { + // If not associated with any items, use all lowercase + if (!counts) { + var newTag = l; + } + // Use most frequent + else if (counts[0].numItems != counts[1].numItems) { var newTag = counts[0].tag; } // Use earliest