cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-11975) Search on Contacts ‘id’ field with JavaScript number type crashes in iOS
Date Wed, 12 Oct 2016 11:33:20 GMT

    [ https://issues.apache.org/jira/browse/CB-11975?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15568462#comment-15568462
] 

ASF GitHub Bot commented on CB-11975:
-------------------------------------

GitHub user matrosov-nikita opened a pull request:

    https://github.com/apache/cordova-plugin-contacts/pull/139

    CB-11975 iOS: Search on contacts' id with number type

    <!--
    Please make sure the checklist boxes are all checked before submitting the PR. The checklist
    is intended as a quick reference, for complete details please see our Contributor Guidelines:
    
    http://cordova.apache.org/contribute/contribute_guidelines.html
    
    Thanks!
    -->
    
    ### Platforms affected
    iOS
    
    ### What does this PR do?
    There was crash when user passed id of numeric type. This PR makes possible to search
for contact by id either string or numeric type as well as on Android platform.
    
    ### What testing has been done on this change?
    Auto test
    
    ### Checklist
    - [x] [Reported an issue](http://cordova.apache.org/contribute/issues.html) in the JIRA
database
    - [x] Commit message follows the format: "CB-3232: (android) Fix bug with resolving file
paths", where CB-xxxx is the JIRA ID & "android" is the platform affected.
    - [x] Added automated test coverage as appropriate for this change.
    


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/matrosov-nikita/cordova-plugin-contacts CB-11975

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/cordova-plugin-contacts/pull/139.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #139
    
----
commit 89038e72d7783b6b94315e5da472022362139953
Author: Nikita Matrosov <matrosov.nikita94@gmail.com>
Date:   2016-10-10T09:02:17Z

    CB-11975 iOS: Search on contacts' id with number type
    
    There was crash when user passed id of numeric type

----


> Search on Contacts ‘id’ field with JavaScript number type crashes in iOS
> ------------------------------------------------------------------------
>
>                 Key: CB-11975
>                 URL: https://issues.apache.org/jira/browse/CB-11975
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin Contacts
>            Reporter: Andrew Forrest
>            Assignee: Nikita Matrosov
>            Priority: Critical
>              Labels: iOS, ios, reproduced, triaged
>
> I was trying to retrieve a specific contact by id in my Ionic/Cordova app, so used the
following code:
> {code:javascript}
> return Contacts.find(
> 	['id'],
> 	{filter: contactId, multiple: true})
> {code}
> However, this crashes the iOS app at runtime with:
> {noformat}
> 2016-10-07 17:33:12.331 MyApp[10998:1880417] -[__NSCFNumber isEqualToString:]: unrecognized
selector sent to instance 0xb000000000000053
> 2016-10-07 17:33:12.337 MyApp[10998:1880417] *** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '-[__NSCFNumber isEqualToString:]: unrecognized selector
sent to instance 0xb000000000000053'
> *** First throw call stack:
> (
> 	0   CoreFoundation                      0x000000010b0f334b __exceptionPreprocess + 171
> 	1   libobjc.A.dylib                     0x000000010ab2b21e objc_exception_throw + 48
> 	2   CoreFoundation                      0x000000010b162f34 -[NSObject(NSObject) doesNotRecognizeSelector:]
+ 132
> 	3   CoreFoundation                      0x000000010b078c15 ___forwarding___ + 1013
> 	4   CoreFoundation                      0x000000010b078798 _CF_forwarding_prep_0 + 120
> 	5   MyApp                               0x00000001097217b7 __22-[CDVContacts search:]_block_invoke_2
+ 983
> 	6   MyApp                               0x0000000109723760 __42-[CDVAddressBookHelper
createAddressBook:]_block_invoke_2 + 368
> 	7   libdispatch.dylib                   0x000000010e4450cd _dispatch_client_callout
+ 8
> 	8   libdispatch.dylib                   0x000000010e4275e5 _dispatch_barrier_sync_f_slow_invoke
+ 617
> 	9   libdispatch.dylib                   0x000000010e4450cd _dispatch_client_callout
+ 8
> 	10  libdispatch.dylib                   0x000000010e4258d6 _dispatch_main_queue_callback_4CF
+ 406
> 	11  CoreFoundation                      0x000000010b0b74f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
+ 9
> 	12  CoreFoundation                      0x000000010b07cf8d __CFRunLoopRun + 2205
> 	13  CoreFoundation                      0x000000010b07c494 CFRunLoopRunSpecific + 420
> 	14  GraphicsServices                    0x00000001107aea6f GSEventRunModal + 161
> 	15  UIKit                               0x000000010be0df34 UIApplicationMain + 159
> 	16  MyApp                               0x000000010962e531 main + 65
> 	17  libdyld.dylib                       0x000000010e49168d start + 1
> )
> libc++abi.dylib: terminating with uncaught exception of type NSException
> (lldb) 
> {noformat}
> Seems to only fail when {{contactId}} is a JavaScript number. Converting it to a string
before searching ({{contactId+""}}) works fine.
> Fault originally occurred because Contact {{id}} field in iOS is an integer… and it
looks like I’m getting a JavaScript number value out of the Contacts API. Was storing this
integer in SQLite (which preserves the data type), getting an integer back out, and passing
it back into the {{Contacts.find()}} API.
> Suggest:
>  * Contacts {{id}} field is supposed to return a string, so it should return a string
on iOS
>  * {{Contacts.find()}} should coerce its arguments to correct types before calling native
code.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Mime
View raw message