Closed Bug 377066 Opened 17 years ago Closed 17 years ago

GetAnnotationInfo always returns VALUE_TYPE_TEXT as the annotation type

Categories

(Firefox :: Bookmarks & History, defect)

defect
Not set
major

Tracking

()

RESOLVED FIXED
Firefox 3 alpha4

People

(Reporter: asaf, Assigned: dietrich)

References

Details

Attachments

(1 file, 5 obsolete files)

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...
+*/
Attached patch wip pach (obsolete) — Splinter Review
Attached patch fix v1 (obsolete) — Splinter Review
+ 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
Attachment #261815 - Attachment is obsolete: true
Attachment #261999 - Flags: review?(mano)
updates a couple of places where mozIStorage types were being used.
Attachment #261999 - Attachment is obsolete: true
Attachment #262056 - Flags: review?(mano)
Attachment #261999 - Flags: review?(mano)
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.
Attachment #262056 - Flags: review?(mano) → review-
Attached patch fix v3 (obsolete) — Splinter Review
update comment, return string type for legacy annos.
Attachment #262056 - Attachment is obsolete: true
Attachment #262066 - Flags: review?(mano)
Attached patch fix v3, sans localstore.rdf (obsolete) — Splinter Review
Attachment #262066 - Attachment is obsolete: true
Attachment #262067 - Flags: review?(mano)
Attachment #262066 - Flags: review?(mano)
Attachment #262067 - Flags: review?(mano)
Attached patch fix v4Splinter Review
The GetAnnotation* methods now throw if the annotation is the wrong type.
Attachment #262067 - Attachment is obsolete: true
Attachment #262072 - Flags: review?(mano)
Comment on attachment 262072 [details] [diff] [review]
fix v4

r=mano, thanks!
Attachment #262072 - Flags: review?(mano) → review+
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
done
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
done
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
done
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
done
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
done
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
done
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
done
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
done
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
done
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Flags: in-testsuite+
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.

Gerv
Component: Places → Bookmarks & History
QA Contact: places → bookmarks
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: