Closed
Bug 898337
Opened 11 years ago
Closed 11 years ago
Contacts API does not allow to search by name field
Categories
(Core Graveyard :: DOM: Contacts, defect)
Tracking
(blocking-b2g:1.3+, firefox28 fixed)
Tracking | Status | |
---|---|---|
firefox28 | --- | fixed |
People
(Reporter: jmcf, Assigned: julienw)
References
Details
(Whiteboard: [u=commsapps-user c=contacts p=1 s=v1.2-features-sprint-4])
Attachments
(3 files, 11 obsolete files)
10.96 KB,
patch
|
julienw
:
review+
|
Details | Diff | Splinter Review |
71.46 KB,
patch
|
julienw
:
review+
|
Details | Diff | Splinter Review |
13.68 KB,
patch
|
Details | Diff | Splinter Review |
The Contacts API find function is not working when trying to find by name. an error is raised with error code 'unknown error' Test case: var reqName = navigator.mozContacts.find({ filterValue: aContact.name[0].trim(), filterBy: ['name'], filterOp: 'equals' } We need this function working in order to match reliably and consistently SIM duplicate contacts.
Reporter | ||
Updated•11 years ago
|
blocking-b2g: --- → koi?
Updated•11 years ago
|
Whiteboard: [u=commsapps-user c=contacts p=0]
Assignee | ||
Comment 1•11 years ago
|
||
It's strange because it works well in the Sms app.
Comment 2•11 years ago
|
||
Yes we currently don't support it. Should be easy to add.
Assignee | ||
Comment 4•11 years ago
|
||
Thanks a lot Joe, I couldn't find this bug again ! Francisco, Jose, my understanding was that you didn't need this after all, bug 904623 would cover your needs. Therefore should we close this bug ?
Flags: needinfo?(jmcf)
Flags: needinfo?(francisco.jordano)
Assignee | ||
Updated•11 years ago
|
Component: General → DOM: Device Interfaces
Product: Boot2Gecko → Core
Comment 5•11 years ago
|
||
(In reply to Julien Wajsberg [:julienw] from comment #4) > Francisco, Jose, my understanding was that you didn't need this after all, > bug 904623 would cover your needs. > > Therefore should we close this bug ? The documentation suggests this should work: https://developer.mozilla.org/en-US/docs/WebAPI/Contacts#Finding_a_contact Also, while our apps may not use it, it does seem like something a 3rd party app might try to reasonably use. Isn't think something we should fix or at least leave the bug open?
Assignee | ||
Comment 6•11 years ago
|
||
Problem is that, if I understood correctly, the "name" is not really the name of the contact, rather it's more an identifier, as it's used. But maybe that property has been abused and we should index it like the other, I'm not against it.
Comment 7•11 years ago
|
||
Hi Julien, this is a different problem than bug 904623, in that bug we need to get the contacts from a list of ids. Unfortunately name is a field used, we do have givenName and familyName, but the name is used as well, for example in the title of the contact when we go for the detailed view. This field is used in several cases when we don't have given and family names, for example, importing from SIM. Despite of that this change is for doing the matching and dedup functionality work better. Thanks!
Flags: needinfo?(francisco.jordano)
Assignee | ||
Comment 8•11 years ago
|
||
thanks Francisco, it seems I misunderstood :)
Flags: needinfo?(jmcf)
Assignee | ||
Updated•11 years ago
|
Assignee: nobody → felash
Summary: Contacts API does not allow to find by name field → Contacts API does not allow to search by name field
Assignee | ||
Updated•11 years ago
|
Whiteboard: [u=commsapps-user c=contacts p=0] → [u=commsapps-user c=contacts p=1 s=v1.2-features-sprint-4]
Assignee | ||
Comment 9•11 years ago
|
||
WIP patch, not yet tested asking feedback only especially I do some not-so-unrelated changes here (ex: the debug function), and I don't know if I should rather do this in another bug and patch or if it's ok to do small not-so-unrelated changes in patches too. Also, I don't see where you ensure the various properties are arrays. Can you tell me where it's done ? Or maybe it isn't... but that could be dangerous, right ?
Attachment #798581 -
Flags: feedback?(anygregor)
Assignee | ||
Comment 10•11 years ago
|
||
I'd like to have WebIDL before landing this, because this will ensure we have arrays as input.
Depends on: 850430
Comment 11•11 years ago
|
||
Comment on attachment 798581 [details] [diff] [review] wip patch v1 Review of attachment 798581 [details] [diff] [review]: ----------------------------------------------------------------- We need more tests but it looks good to me! ::: dom/contacts/fallback/ContactDB.jsm @@ +417,4 @@ > "givenNameLowerCase", "telLowerCase", "category", "email", > "emailLowerCase"]; > for (var i = 0; i < names.length; i++) { > + if (whiteList.indexOf(names[i]) < 0) { no need to change this. @@ +580,5 @@ > + if (name && typeof name === 'string') { > + value.search.name.push(name.toLowerCase()); > + } > + }); > + cursor.update(value); We could be smarter to only update the cursor if we actually push a name. @@ +717,5 @@ > contact.search[field].push(value.toLowerCase()); > } > } else { > let val = aContact.properties[field][i]; > + if (val && typeof val == "string") { We already check this in the beginning of the loop.
Attachment #798581 -
Flags: feedback?(anygregor) → feedback+
Assignee | ||
Comment 12•11 years ago
|
||
Can't schedule a try because it's closes because of bug 914821, will try again tomorrow I guess.
Attachment #798581 -
Attachment is obsolete: true
Attachment #802591 -
Flags: review?(anygregor)
Comment 13•11 years ago
|
||
Comment on attachment 802591 [details] [diff] [review] patch v1 Review of attachment 802591 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/contacts/fallback/ContactDB.jsm @@ +207,5 @@ > > // Properties indexes > objectStore.createIndex("familyName", "properties.familyName", { multiEntry: true }); > objectStore.createIndex("givenName", "properties.givenName", { multiEntry: true }); > + objectStore.createIndex("name", "properties.name", { multiEntry: true }); I assume this is just leftover from an older version of the patch? You should only add the indexes on your new upgrade function. @@ +212,4 @@ > > objectStore.createIndex("familyNameLowerCase", "search.familyName", { multiEntry: true }); > objectStore.createIndex("givenNameLowerCase", "search.givenName", { multiEntry: true }); > + objectStore.createIndex("nameLowerCase", "search.name", { multiEntry: true }); Ditto. @@ +404,5 @@ > if (!objectStore) { > objectStore = aTransaction.objectStore(STORE_NAME); > } > let names = objectStore.indexNames; > + let whiteList = ["tel", "familyName", "givenName", "familyNameLowerCase", Nice, I've been meaning to fix this forever and never get around to it :) @@ +568,5 @@ > + if (cursor) { > + let value = cursor.value; > + value.search.name = []; > + value.properties.name.forEach(function addNameIndex(name) { > + if (name && typeof name === 'string') { |name| should only contain valid strings, did you run into |null| here when testing?
Assignee | ||
Comment 14•11 years ago
|
||
Comment on attachment 802591 [details] [diff] [review] patch v1 will handle comments before asking for a new review
Attachment #802591 -
Flags: review?(anygregor)
Assignee | ||
Comment 15•11 years ago
|
||
(In reply to Gregor Wagner [:gwagner] from comment #11) > Comment on attachment 798581 [details] [diff] [review] > wip patch v1 > > Review of attachment 798581 [details] [diff] [review]: > ----------------------------------------------------------------- > > We need more tests but it looks good to me! > > ::: dom/contacts/fallback/ContactDB.jsm > @@ +417,4 @@ > > "givenNameLowerCase", "telLowerCase", "category", "email", > > "emailLowerCase"]; > > for (var i = 0; i < names.length; i++) { > > + if (whiteList.indexOf(names[i]) < 0) { > > no need to change this. Discussed with Reuben over this, and we think the current code makes it difficult to read. I can move this to another patch if you want though. > > @@ +580,5 @@ > > + if (name && typeof name === 'string') { > > + value.search.name.push(name.toLowerCase()); > > + } > > + }); > > + cursor.update(value); > > We could be smarter to only update the cursor if we actually push a name. I'm still adding an empty array for value.search if there is nothing in value.properties.name. Should I keep it as null in that case ? I thought it was better to do this because we're doing exactly this in makeImport. > > @@ +717,5 @@ > > contact.search[field].push(value.toLowerCase()); > > } > > } else { > > let val = aContact.properties[field][i]; > > + if (val && typeof val == "string") { > > We already check this in the beginning of the loop. removed. (In reply to Reuben Morais [:reuben] from comment #13) > Comment on attachment 802591 [details] [diff] [review] > patch v1 > > Review of attachment 802591 [details] [diff] [review]: > ----------------------------------------------------------------- > > ::: dom/contacts/fallback/ContactDB.jsm > @@ +207,5 @@ > > > > // Properties indexes > > objectStore.createIndex("familyName", "properties.familyName", { multiEntry: true }); > > objectStore.createIndex("givenName", "properties.givenName", { multiEntry: true }); > > + objectStore.createIndex("name", "properties.name", { multiEntry: true }); > > I assume this is just leftover from an older version of the patch? You > should only add the indexes on your new upgrade function. Right, removed > @@ +212,4 @@ > > > > objectStore.createIndex("familyNameLowerCase", "search.familyName", { multiEntry: true }); > > objectStore.createIndex("givenNameLowerCase", "search.givenName", { multiEntry: true }); > > + objectStore.createIndex("nameLowerCase", "search.name", { multiEntry: true }); > > Ditto. Removed. > > @@ +404,5 @@ > > if (!objectStore) { > > objectStore = aTransaction.objectStore(STORE_NAME); > > } > > let names = objectStore.indexNames; > > + let whiteList = ["tel", "familyName", "givenName", "familyNameLowerCase", > > Nice, I've been meaning to fix this forever and never get around to it :) \o/ > @@ +568,5 @@ > > + if (cursor) { > > + let value = cursor.value; > > + value.search.name = []; > > + value.properties.name.forEach(function addNameIndex(name) { > > + if (name && typeof name === 'string') { > > |name| should only contain valid strings, did you run into |null| here when > testing? I was thinking: we're in the upgrade path, and we absolutly don't want that it breaks. So better be too safe here. Should I still remove it ?
Assignee | ||
Comment 16•11 years ago
|
||
try is https://tbpl.mozilla.org/?tree=Try&rev=59ef100a6b32 The new patch applies after WebIDL patches from bug 850430. I looked at the android code and it seems to me that the android code already allows searching on "name". I don't know if the mochitests run on the android code. Waiting for the try result before asking another review.
Attachment #802591 -
Attachment is obsolete: true
Assignee | ||
Comment 17•11 years ago
|
||
So, this try does not look so good, because some of the contact test files are timing out. But I really don't know what happens here, so I'd love to have some help here :)
Flags: needinfo?(reuben.bmo)
Flags: needinfo?(anygregor)
Comment 18•11 years ago
|
||
I fixed the Android failures, but bug 915697 is preventing me from looking into the emulator failures.
Flags: needinfo?(reuben.bmo)
Comment 19•11 years ago
|
||
(In reply to Julien Wajsberg [:julienw] from comment #17) > So, this try does not look so good, because some of the contact test files > are timing out. But I really don't know what happens here, so I'd love to > have some help here :) I noticed that the tests run pretty slow in debug mode and might trigger the max test run time. We should try to split them up into more files.
Flags: needinfo?(anygregor)
Assignee | ||
Comment 20•11 years ago
|
||
Reuben> do you mean you fixed the Android failures right now, or that you fixed them in another bug ? Gregoe> thanks, I'll split them :)
Assignee | ||
Comment 22•11 years ago
|
||
Next step is me splitting the mochitests so that they don't time out in TBPL. However I don't think this bug should be a blocker. Francisco, do you think the same ?
Flags: needinfo?(felash) → needinfo?(francisco.jordano)
Comment 23•11 years ago
|
||
(In reply to Julien Wajsberg [:julienw] from comment #22) > Next step is me splitting the mochitests so that they don't time out in TBPL. > > However I don't think this bug should be a blocker. > > Francisco, do you think the same ? Yep not a blocker and not a regression. We shipped earlier versions without it.
Comment 24•11 years ago
|
||
Hi, Just adding that this issue is blocking a blocker for v1.2 (bug 917674, notice that handle duplicate contacts is a new feature for v1.2) so this issue should remain as a blocker.
Comment 25•11 years ago
|
||
(In reply to Gregor Wagner [:gwagner] from comment #23) > > Yep not a blocker and not a regression. We shipped earlier versions without > it. IMHO, this is blocking a blocker. We ship before without this feature, but now we have version 1.2 (that is not shipped), that needs this feature for the contacts dedup committed feature (see bug 917674 ). I understand, as we were talking in Oslo, to not to add extra things to the API, but this is needed for a feature that we compromised to deliver, and without it, we can see several inconsistencies. Cheers, F.
Updated•11 years ago
|
Flags: needinfo?(francisco.jordano)
Assignee | ||
Comment 26•11 years ago
|
||
Oki, that's exactly what I wanted to know, whether you managed to work around. Will do my best to move this forward quickly then.
Assignee | ||
Comment 27•11 years ago
|
||
Francisco, Gregor told me that bug 850430 won't likely be uplifted to koi. I _really_ don't want todo the work twice here, as I based my patch on the work in bug 850430. Therefore, is it ok to shift bug 917674 to 1.3 (ie: do it as soon as possible in master/central, but let it ride the train) ?
Flags: needinfo?(francisco.jordano)
Comment 28•11 years ago
|
||
Hi Julien, I totally understand your point, but if we don't fix the search by name, unfortunately a whole new feature, like contacts dedup, will be broken mainly cause we won't be able to dedup contacts imported from sim card. Reasking Jose, that has more insights about the dedup to see if we could workaround this or not. Cheers, F.
Flags: needinfo?(francisco.jordano) → needinfo?(jmcf)
Assignee | ||
Comment 29•11 years ago
|
||
No it's ok, if you need to work around, it's not better than doing another patch here. Will do but I'll need to think a lot about DB versions...
Flags: needinfo?(jmcf)
Comment 30•11 years ago
|
||
Thanks Julien :)
Reporter | ||
Comment 31•11 years ago
|
||
(In reply to Julien Wajsberg [:julienw] from comment #29) > No it's ok, if you need to work around, it's not better than doing another > patch here. > > Will do but I'll need to think a lot about DB versions... thanks Julien!
Updated•11 years ago
|
Component: DOM: Device Interfaces → DOM: Contacts
Comment 32•11 years ago
|
||
Hi Julien, Could you please inform us under which milestone this bug will be taken?, it is just to align bug 917674 with it. Thanks!
Flags: needinfo?(felash)
Assignee | ||
Comment 33•11 years ago
|
||
I really intend to finish this patch today. The code is ready, but I want to add more tests, because I changed how the migration works, and I'm not so confident about this.
Flags: needinfo?(felash)
Comment 34•11 years ago
|
||
(In reply to Julien Wajsberg [:julienw] from comment #33) > I really intend to finish this patch today. > > The code is ready, but I want to add more tests, because I changed how the > migration works, and I'm not so confident about this. Many thanks for your quick reply, Bug 917674 already updated accordingly.
Assignee | ||
Comment 36•11 years ago
|
||
Splitting the big tests in smaller files.
Assignee | ||
Updated•11 years ago
|
Attachment #823022 -
Attachment description: patch v3 → 1. add name index, patch v3
Assignee | ||
Comment 37•11 years ago
|
||
Try is https://tbpl.mozilla.org/?tree=Try&rev=6aabd0945fb8
Assignee | ||
Comment 38•11 years ago
|
||
On the aurora patch, I'll include all upgrade paths that landed before this and are not on aurora (this means: the WebIDL patch's upgrade path). This was suggested by Ben Turner, instead of doing a complex upgrade mechanism I implemented previously. I'll do an aurora patch tomorrow.
Assignee | ||
Comment 39•11 years ago
|
||
patch for aurora. It includes all upgrade paths from the WebIDL patch. We should probably either wait for bug 929652 and include its changes too, or make bug 929652 koi+.
Assignee | ||
Comment 40•11 years ago
|
||
Don't know if this patch is useful. Maybe useful so that tests uplifts are easier.
Assignee | ||
Comment 41•11 years ago
|
||
new central try for the b2g build only: https://tbpl.mozilla.org/?tree=Try&rev=45b284868b57 try for aurora: https://tbpl.mozilla.org/?tree=Try&rev=b69ef6fb6b52
Assignee | ||
Comment 43•11 years ago
|
||
Comment on attachment 823022 [details] [diff] [review] 1. add name index, patch v3 Gregor, please redirect to Reuben if you think he's a better fit.
Attachment #823022 -
Flags: review?(anygregor)
Assignee | ||
Updated•11 years ago
|
Attachment #823023 -
Flags: review?(anygregor)
Assignee | ||
Comment 44•11 years ago
|
||
ok, now I know my try line was wrong for the b2g mochitests. specific b2g try for central: https://tbpl.mozilla.org/?tree=Try&rev=b772fefd77a0 specific b2g try for aurora: https://tbpl.mozilla.org/?tree=Try&rev=3ab5e104acf0
Assignee | ||
Comment 45•11 years ago
|
||
New try is https://tbpl.mozilla.org/?tree=Try&rev=6aa43f463cb5 With working tests now...
Attachment #823424 -
Attachment is obsolete: true
Comment 46•11 years ago
|
||
Comment on attachment 823022 [details] [diff] [review] 1. add name index, patch v3 Review of attachment 823022 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/contacts/fallback/ContactDB.jsm @@ +638,5 @@ > + let cursor = event.target.result; > + if (cursor) { > + let value = cursor.value; > + value.search.name = []; > + value.properties.name.forEach(function addNameIndex(name) { |value.properties.name| can be null, you need to check for that. @@ +639,5 @@ > + if (cursor) { > + let value = cursor.value; > + value.search.name = []; > + value.properties.name.forEach(function addNameIndex(name) { > + if (name && typeof name === 'string') { Why are you checking this? Did you run into falsy values or something that isn't a string when testing?
Assignee | ||
Comment 47•11 years ago
|
||
(In reply to Reuben Morais [:reuben] from comment #46) > Comment on attachment 823022 [details] [diff] [review] > 1. add name index, patch v3 > > Review of attachment 823022 [details] [diff] [review]: > ----------------------------------------------------------------- > > ::: dom/contacts/fallback/ContactDB.jsm > @@ +638,5 @@ > > + let cursor = event.target.result; > > + if (cursor) { > > + let value = cursor.value; > > + value.search.name = []; > > + value.properties.name.forEach(function addNameIndex(name) { > > |value.properties.name| can be null, you need to check for that. Right, will do. > > @@ +639,5 @@ > > + if (cursor) { > > + let value = cursor.value; > > + value.search.name = []; > > + value.properties.name.forEach(function addNameIndex(name) { > > + if (name && typeof name === 'string') { > > Why are you checking this? Did you run into falsy values or something that > isn't a string when testing? Heh, you already told me that in the first review ;) I answered: I was thinking: we're in the upgrade path, and we absolutly don't want that it breaks. So better be too safe here. But you're right, I can remove it, especially after bug 929652.
Comment 48•11 years ago
|
||
(In reply to Julien Wajsberg [:julienw] from comment #47) > > @@ +639,5 @@ > > > + if (cursor) { > > > + let value = cursor.value; > > > + value.search.name = []; > > > + value.properties.name.forEach(function addNameIndex(name) { > > > + if (name && typeof name === 'string') { > > > > Why are you checking this? Did you run into falsy values or something that > > isn't a string when testing? > > Heh, you already told me that in the first review ;) I answered: I was > thinking: we're in the upgrade path, and we absolutly don't want that it > breaks. So better be too safe here. But you're right, I can remove it, > especially after bug 929652. Hah, my bad. I'm starting to think I suffered some minor brain damage from landing WebIDL Contacts and dealing with the aftermatch ;)
Updated•11 years ago
|
Attachment #823023 -
Flags: review?(anygregor) → review+
Comment 49•11 years ago
|
||
Comment on attachment 823022 [details] [diff] [review] 1. add name index, patch v3 Review of attachment 823022 [details] [diff] [review]: ----------------------------------------------------------------- Additional Comments to Reubens review. ::: dom/contacts/tests/test_contacts_basics.html @@ +581,5 @@ > + checkContacts(createResult1, findResult1); > + next(); > + }; > + req.onerror = onFailure; > + }, We should also test a search with the lowercase name property. So that we test the 'search' field. ::: dom/contacts/tests/test_contacts_upgrade.html @@ +82,5 @@ > let contact2 = dbContact2.properties; > > checkStrArray(contact1.name, contact2.name, "Same name"); > checkStrArray(contact1.honorificPrefix, contact2.honorificPrefix, "Same honorificPrefix"); > + checkStrArray(contact1.name, contact2.name, "Same name index"); Isn't that the same as 2 lines above?
Attachment #823022 -
Flags: review?(anygregor) → review+
Comment 50•11 years ago
|
||
Hi, Due that bug 917674 has been deferred to v1.3 (bug 917674 comment 5), it is not necessary to uplift this one to v1.2 branch so re-nom to v1.3?. Please re-nom as koi+ if for any other reason you think it should block v1.2. Thanks
blocking-b2g: koi+ → 1.3?
Assignee | ||
Comment 51•11 years ago
|
||
\o/ no uplift makes my life a lot easier !
Comment 52•11 years ago
|
||
\o/ happiness for everyone then :)
Assignee | ||
Comment 53•11 years ago
|
||
carrying r=gwagner,reuben rebased on top of bug 929652
Attachment #824756 -
Flags: review+
Assignee | ||
Updated•11 years ago
|
Attachment #823022 -
Attachment is obsolete: true
Assignee | ||
Comment 54•11 years ago
|
||
carrying r=gwagner,reuben only updated the commit log
Attachment #823023 -
Attachment is obsolete: true
Attachment #823417 -
Attachment is obsolete: true
Attachment #823887 -
Attachment is obsolete: true
Attachment #824757 -
Flags: review+
Assignee | ||
Comment 55•11 years ago
|
||
New try is https://tbpl.mozilla.org/?tree=Try&rev=6261215cd6d6
Assignee | ||
Comment 56•11 years ago
|
||
bug 929652 makes important sanitization we relies on.
Depends on: 929652
Assignee | ||
Comment 58•11 years ago
|
||
Rebased on latest central, carrying r=reuben,gwagner
Attachment #824756 -
Attachment is obsolete: true
Attachment #825286 -
Flags: review+
Assignee | ||
Comment 59•11 years ago
|
||
rebased, retaining r=gwagner,reuben I took care to keep the changes from bug 932763 and bug 929435
Attachment #824757 -
Attachment is obsolete: true
Attachment #825287 -
Flags: review+
Assignee | ||
Comment 60•11 years ago
|
||
For posterity, my WIP patch to handle migration between branches. The logic was to add an objectstore to keep the Firefox OS version. If the version changes, then we know we must do more migration than what the db version is saying. An object keeps the step index for the first migration to do, and then we execute all the next ones. This means all migrations can be executed several times, and therefore needs to be idempotent. Luckily we don't need to do this right now, but maybe we'll have to do this at one point, thus I wanted to share this code somewhere.
Assignee | ||
Comment 61•11 years ago
|
||
bug 929652 is r+, so asking checkin-needed here too. Please land after bug 929652, thanks!
Keywords: checkin-needed
Comment 62•11 years ago
|
||
https://hg.mozilla.org/integration/b2g-inbound/rev/1752a5d1fd7a https://hg.mozilla.org/integration/b2g-inbound/rev/5cc3612b6c04
Flags: in-testsuite+
Keywords: checkin-needed
Comment 63•11 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/1752a5d1fd7a https://hg.mozilla.org/mozilla-central/rev/5cc3612b6c04
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla28
Updated•11 years ago
|
status-firefox28:
--- → fixed
Updated•6 years ago
|
Product: Core → Core Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•