Last Comment Bug 377066 - GetAnnotationInfo always returns VALUE_TYPE_TEXT as the annotation type
: GetAnnotationInfo always returns VALUE_TYPE_TEXT as the annotation type
Product: Firefox
Classification: Client Software
Component: Bookmarks & History (show other bugs)
: unspecified
: All All
: -- major (vote)
: Firefox 3 alpha4
Assigned To: Dietrich Ayala (:dietrich)
: Marco Bonardo [::mak]
Depends on:
Blocks: 370099
  Show dependency treegraph
Reported: 2007-04-10 13:18 PDT by Mano (::mano, needinfo? for any questions; not reading general bugmail)
Modified: 2009-11-26 06:09 PST (History)
2 users (show)
jwalden+bmo: in‑testsuite+
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

wip pach (21.03 KB, patch)
2007-04-17 10:35 PDT, Dietrich Ayala (:dietrich)
no flags Details | Diff | Splinter Review
fix v1 (29.23 KB, patch)
2007-04-18 12:39 PDT, Dietrich Ayala (:dietrich)
no flags Details | Diff | Splinter Review
fix v2 (updates a couple of consumers) (32.27 KB, patch)
2007-04-18 17:01 PDT, Dietrich Ayala (:dietrich)
asaf: review-
Details | Diff | Splinter Review
fix v3 (41.63 KB, patch)
2007-04-18 18:12 PDT, Dietrich Ayala (:dietrich)
no flags Details | Diff | Splinter Review
fix v3, sans localstore.rdf (32.19 KB, patch)
2007-04-18 18:14 PDT, Dietrich Ayala (:dietrich)
no flags Details | Diff | Splinter Review
fix v4 (36.31 KB, patch)
2007-04-18 20:17 PDT, Dietrich Ayala (:dietrich)
asaf: review+
Details | Diff | Splinter Review

Description Mano (::mano, needinfo? for any questions; not reading general bugmail) 2007-04-10 13:18:36 PDT
GetAnnotationInfo always returns VALUE_TYPE_TEXT as the annotation type.

From bug 376851
+* XXX: You may think the two methods below are reliable.
+* They simply check the type of the content field, which is always
+* VALUE_TYPE_TEXT, How come you're wondering? The field is created as
+* LONGVARCHAR, that's how. See InitTables().
+* The fix would be to add yet another field to the annos table and save the
+* type there. This isn't a good use of dietrich's time but we don't really
+* have a choice here...
Comment 1 Dietrich Ayala (:dietrich) 2007-04-17 10:35:43 PDT
Created attachment 261815 [details] [diff] [review]
wip pach
Comment 2 Dietrich Ayala (:dietrich) 2007-04-18 12:39:41 PDT
Created attachment 261999 [details] [diff] [review]
fix v1

+ write db upgrade
+ add type handling to set/get anno methods
+ add type handling to getannoinfo(), handle pre-type annos
+ update callers to use annosvc types instead of mozstorage types
+ add tests for types

+ test upgrade from v2-> v3
+ test downgrade from v3 -> v2
+ test sidegrade from v3-bookmarks to v3-no-bookmarks
+ test sidegrade from v3-no-bookmarks to v3-bookmarks
Comment 3 Dietrich Ayala (:dietrich) 2007-04-18 17:01:43 PDT
Created attachment 262056 [details] [diff] [review]
fix v2 (updates a couple of consumers)

updates a couple of places where mozIStorage types were being used.
Comment 4 Mano (::mano, needinfo? for any questions; not reading general bugmail) 2007-04-18 17:22:09 PDT
Comment on attachment 262056 [details] [diff] [review]
fix v2 (updates a couple of consumers)

> >@@ -480,17 +491,27 @@ nsAnnotationService::GetAnnotationInfo(n
>   if (NS_FAILED(rv))
>     return rv;
>   mozStorageStatementScoper resetter(mDBGetAnnotationFromURI);
>   *aFlags = mDBGetAnnotationFromURI->AsInt32(kAnnoIndex_Flags);
>   *aExpiration = mDBGetAnnotationFromURI->AsInt32(kAnnoIndex_Expiration);
>   rv = mDBGetAnnotationFromURI->GetUTF8String(kAnnoIndex_MimeType, aMimeType);
>   NS_ENSURE_SUCCESS(rv, rv);
>-  rv = mDBGetAnnotationFromURI->GetTypeOfIndex(kAnnoIndex_Content, aStorageType);
>+  PRInt32 type = mDBGetAnnotationFromURI->AsInt32(kAnnoIndex_Type);
>+  if (type == 0) {
>+    // For annotations created before explicit typing, return the mozStorage
>+    // type const.
>+    // Note: The anno service type consts match these as close as possible.
>+    // The difference is that int64 values will report int32.
>+    rv = mDBGetAnnotationFromURI->GetTypeOfIndex(kAnnoIndex_Content, aStorageType);

Again, this is wrong, it would always return VALUE_TYPE_TEXT.

I would bother making the various GetAnnotationAsTypeFoo methods throw if the annotation is not of type Foo.
Comment 5 Dietrich Ayala (:dietrich) 2007-04-18 18:12:24 PDT
Created attachment 262066 [details] [diff] [review]
fix v3

update comment, return string type for legacy annos.
Comment 6 Dietrich Ayala (:dietrich) 2007-04-18 18:14:29 PDT
Created attachment 262067 [details] [diff] [review]
fix v3, sans localstore.rdf
Comment 7 Dietrich Ayala (:dietrich) 2007-04-18 20:17:10 PDT
Created attachment 262072 [details] [diff] [review]
fix v4

The GetAnnotation* methods now throw if the annotation is the wrong type.
Comment 8 Mano (::mano, needinfo? for any questions; not reading general bugmail) 2007-04-19 16:31:15 PDT
Comment on attachment 262072 [details] [diff] [review]
fix v4

r=mano, thanks!
Comment 9 Dietrich Ayala (:dietrich) 2007-04-22 14:52:32 PDT
Checking in browser/components/places/content/bookmarkProperties.js;
/cvsroot/mozilla/browser/components/places/content/bookmarkProperties.js,v  <--  bookmarkProperties.js
new revision: 1.42; previous revision: 1.41
Checking in browser/components/places/content/controller.js;
/cvsroot/mozilla/browser/components/places/content/controller.js,v  <--  controller.js
new revision: 1.143; previous revision: 1.142
Checking in browser/components/places/content/utils.js;
/cvsroot/mozilla/browser/components/places/content/utils.js,v  <--  utils.js
new revision: 1.31; previous revision: 1.30
Checking in toolkit/components/places/public/nsIAnnotationService.idl;
/cvsroot/mozilla/toolkit/components/places/public/nsIAnnotationService.idl,v  <--  nsIAnnotationService.idl
new revision: 1.11; previous revision: 1.10
Checking in toolkit/components/places/src/nsAnnotationService.cpp;
/cvsroot/mozilla/toolkit/components/places/src/nsAnnotationService.cpp,v  <--  nsAnnotationService.cpp
new revision: 1.17; previous revision: 1.16
Checking in toolkit/components/places/src/nsAnnotationService.h;
/cvsroot/mozilla/toolkit/components/places/src/nsAnnotationService.h,v  <--  nsAnnotationService.h
new revision: 1.9; previous revision: 1.8
Checking in toolkit/components/places/src/nsNavHistory.cpp;
/cvsroot/mozilla/toolkit/components/places/src/nsNavHistory.cpp,v  <--  nsNavHistory.cpp
new revision: 1.116; previous revision: 1.115
Checking in toolkit/components/places/src/nsNavHistory.h;
/cvsroot/mozilla/toolkit/components/places/src/nsNavHistory.h,v  <--  nsNavHistory.h
new revision: 1.74; previous revision: 1.73
Checking in toolkit/components/places/tests/unit/test_annotations.js;
/cvsroot/mozilla/toolkit/components/places/tests/unit/test_annotations.js,v  <--  test_annotations.js
new revision: 1.2; previous revision: 1.1
Comment 10 Gervase Markham [:gerv] 2009-11-26 06:09:24 PST
Bug 451915 - move Firefox/Places bugs to Firefox/Bookmarks and History. Remove all bugspam from this move by filtering for the string "places-to-b-and-h".

In Thunderbird 3.0b, you do that as follows:
Tools | Message Filters
Make sure the correct account is selected. Click "New"
Conditions: Body   contains   places-to-b-and-h
Change the action to "Delete Message".
Select "Manually Run" from the dropdown at the top.
Click OK.

Select the filter in the list, make sure "Inbox" is selected at the bottom, and click "Run Now". This should delete all the bugspam. You can then delete the filter.


Note You need to log in before you can comment on or make changes to this bug.