You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by "bruno rovagnati (JIRA)" <ji...@apache.org> on 2008/06/18 03:42:45 UTC

[jira] Created: (SHINDIG-392) bug in idSpec.php that doesnt allow array() of user ids

bug in idSpec.php that doesnt allow array() of user ids
-------------------------------------------------------

                 Key: SHINDIG-392
                 URL: https://issues.apache.org/jira/browse/SHINDIG-392
             Project: Shindig
          Issue Type: Bug
          Components: Common Components (PHP)
            Reporter: bruno rovagnati
         Attachments: idSpec_USER_ID.patch

if an array of id (or a single id) is sent for a IdSpec, php will rejected as invalid

ps: this applies to JSON wired stuff

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Re: [jira] Commented: (SHINDIG-392) bug in idSpec.php that doesnt allow array() of user ids

Posted by Karsten Beyer <ma...@kbeyer.net>.
Hi,

i also use this test:

http://opensocial-resources.googlecode.com/svn/tests/trunk/compliancetests.xml
If there is a '!' in front of the empty() in the first else if statement,
the "fetch people"(P2) fails. (it is not shown at all)

I am quite sure that i had a error message about it yesterday, i am however
not able to reproduce this error message today :(

Best Regards

karsten beyer

On Thu, Jun 19, 2008 at 8:27 PM, bruno rovagnati (JIRA) <ji...@apache.org>
wrote:

>
>    [
> https://issues.apache.org/jira/browse/SHINDIG-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12606493#action_12606493]
>
> bruno rovagnati commented on SHINDIG-392:
> -----------------------------------------
>
> Hi Karsten
>
> can u please send some js examples to see how u do a call?
>
> for example
>            var idSpec = new opensocial.IdSpec();
>            idSpec.setField('USER_ID', [friend]);
>            opensocial.requestSendMessage(idSpec, message, function(){});
> creates this JSON
>    Request [..."idSpec":{"fields_":{"USER_ID":["177001"]}},..]
> and this php
> idspec: Array\n(\n    [fields_] => Array\n        (\n            [USER_ID]
> => Array\n                (\n                    [0] =>
> 177001\n                )\n\n        )\n\n)\n
>
> as far as i see, not good.
>
> this call
>            opensocial.requestSendMessage({'USER_ID' : [friend]}, message,
> function(){});
> creates this Json
>    [... "idSpec":{"USER_ID":["177001"]},...]
> and this php
>   idspec: Array\n(\n    [USER_ID] => Array\n        (\n            [0] =>
> 177001\n        )\n\n)\n
>
> looks a little bit better.
>
> and finally the code is now working for the case:
>
>            opensocial.requestSendMessage([friend], message, function(){});
> json:
>   [...,"idSpec":["177001"],...]
> php
> idspec: Array\n(\n    [0] => 177001\n)\n
>
> ropu
>
> ps: i just checked
>
> http://opensocial-resources.googlecode.com/svn/tests/trunk/compliancetests.xmlwith
> actual SVN code an and 11/11 went ok.
>
>
>
>
>
> On Thu, Jun 19, 2008 at 1:17 AM, Karsten Beyer (JIRA) <ji...@apache.org>
>
>
>
> --
> .-. --- .--. ..-
> R o p u
>
>
> > bug in idSpec.php that doesnt allow array() of user ids
> > -------------------------------------------------------
> >
> >                 Key: SHINDIG-392
> >                 URL: https://issues.apache.org/jira/browse/SHINDIG-392
> >             Project: Shindig
> >          Issue Type: Bug
> >          Components: Common Components (PHP)
> >            Reporter: bruno rovagnati
> >            Assignee: Chris Chabot
> >         Attachments: idSpec_USER_ID.patch
> >
> >
> > if an array of id (or a single id) is sent for a IdSpec, php will
> rejected as invalid
> > ps: this applies to JSON wired stuff
>
> --
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>
>

[jira] Commented: (SHINDIG-392) bug in idSpec.php that doesnt allow array() of user ids

Posted by "Karsten Beyer (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHINDIG-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12606287#action_12606287 ] 

Karsten Beyer commented on SHINDIG-392:
---------------------------------------

if (! empty($jsonIdSpec) && in_array((string)$jsonIdSpec, idSpec::$types)) {
    $idSpecEnum = (string)$jsonIdSpec;
} elseif (!empty($jsonIdSpec)) {
    $idSpecEnum = 'USER_IDS';
} else {
  throw new Exception("The json request had a bad idSpec");
}
return new IdSpec($jsonIdSpec, $idSpecEnum);

i think that the !empty in the first elseif statement is wrong. First of all it makes no sense as now only an empty IdSpec leads to the exception, while an arbitrary string will be converted to USER_IDS (arbitrary = not in the types array). 

Aside from that it makes the compliance test fail...

Removing the "!" makes it work as it should.

> bug in idSpec.php that doesnt allow array() of user ids
> -------------------------------------------------------
>
>                 Key: SHINDIG-392
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-392
>             Project: Shindig
>          Issue Type: Bug
>          Components: Common Components (PHP)
>            Reporter: bruno rovagnati
>            Assignee: Chris Chabot
>         Attachments: idSpec_USER_ID.patch
>
>
> if an array of id (or a single id) is sent for a IdSpec, php will rejected as invalid
> ps: this applies to JSON wired stuff

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SHINDIG-392) bug in idSpec.php that doesnt allow array() of user ids

Posted by "Chris Chabot (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHINDIG-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12606748#action_12606748 ] 

Chris Chabot commented on SHINDIG-392:
--------------------------------------

Ok so based on the comment on shindig-dev, there's actually no problem with this? If so please give me a case in which it doesn't do what it should be doing :-)

At first glance the code bruno contributed makes sense, if the idSpec is not a predefined type (owner, viewer, etc), then you can assume it is a list of ID's ([1,3,4]) so the logic "If is not a predefined type, and not empty, then its a list of id's" sounds fine to me.



> bug in idSpec.php that doesnt allow array() of user ids
> -------------------------------------------------------
>
>                 Key: SHINDIG-392
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-392
>             Project: Shindig
>          Issue Type: Bug
>          Components: Common Components (PHP)
>            Reporter: bruno rovagnati
>            Assignee: Chris Chabot
>         Attachments: idSpec_USER_ID.patch
>
>
> if an array of id (or a single id) is sent for a IdSpec, php will rejected as invalid
> ps: this applies to JSON wired stuff

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (SHINDIG-392) bug in idSpec.php that doesnt allow array() of user ids

Posted by "bruno rovagnati (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SHINDIG-392?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

bruno rovagnati updated SHINDIG-392:
------------------------------------

    Attachment: idSpec_USER_ID.patch

patch to fix that

> bug in idSpec.php that doesnt allow array() of user ids
> -------------------------------------------------------
>
>                 Key: SHINDIG-392
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-392
>             Project: Shindig
>          Issue Type: Bug
>          Components: Common Components (PHP)
>            Reporter: bruno rovagnati
>         Attachments: idSpec_USER_ID.patch
>
>
> if an array of id (or a single id) is sent for a IdSpec, php will rejected as invalid
> ps: this applies to JSON wired stuff

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SHINDIG-392) bug in idSpec.php that doesnt allow array() of user ids

Posted by "bruno rovagnati (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHINDIG-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12606493#action_12606493 ] 

bruno rovagnati commented on SHINDIG-392:
-----------------------------------------

Hi Karsten

can u please send some js examples to see how u do a call?

for example
            var idSpec = new opensocial.IdSpec();
            idSpec.setField('USER_ID', [friend]);
            opensocial.requestSendMessage(idSpec, message, function(){});
creates this JSON
    Request [..."idSpec":{"fields_":{"USER_ID":["177001"]}},..]
and this php
idspec: Array\n(\n    [fields_] => Array\n        (\n            [USER_ID]
=> Array\n                (\n                    [0] =>
177001\n                )\n\n        )\n\n)\n

as far as i see, not good.

this call
            opensocial.requestSendMessage({'USER_ID' : [friend]}, message,
function(){});
creates this Json
    [... "idSpec":{"USER_ID":["177001"]},...]
and this php
   idspec: Array\n(\n    [USER_ID] => Array\n        (\n            [0] =>
177001\n        )\n\n)\n

looks a little bit better.

and finally the code is now working for the case:

            opensocial.requestSendMessage([friend], message, function(){});
json:
   [...,"idSpec":["177001"],...]
php
idspec: Array\n(\n    [0] => 177001\n)\n

ropu

ps: i just checked
http://opensocial-resources.googlecode.com/svn/tests/trunk/compliancetests.xmlwith
actual SVN code an and 11/11 went ok.





On Thu, Jun 19, 2008 at 1:17 AM, Karsten Beyer (JIRA) <ji...@apache.org>



-- 
.-. --- .--. ..-
R o p u


> bug in idSpec.php that doesnt allow array() of user ids
> -------------------------------------------------------
>
>                 Key: SHINDIG-392
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-392
>             Project: Shindig
>          Issue Type: Bug
>          Components: Common Components (PHP)
>            Reporter: bruno rovagnati
>            Assignee: Chris Chabot
>         Attachments: idSpec_USER_ID.patch
>
>
> if an array of id (or a single id) is sent for a IdSpec, php will rejected as invalid
> ps: this applies to JSON wired stuff

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SHINDIG-392) bug in idSpec.php that doesnt allow array() of user ids

Posted by "Karsten Beyer (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHINDIG-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12606768#action_12606768 ] 

Karsten Beyer commented on SHINDIG-392:
---------------------------------------

hmm. Now i understand the intention behind it, but anyway, take this request from the compliancetest:

	[{"type":"FETCH_PEOPLE","idSpec":true,"profileDetail":["id","name","thumbnailUrl"],"sortOrder":"topFriends","filter":"all","first":0,"max":20}]

Obviously this is simply a wrong wrong idSpec, the  Exception should be triggered. 

Maybe it would be a good idea to use a regexp to see if it is indeed a valid idSpec. (i would write it, but was not able to find the specification about how the idSpec is supposed to look when requesting multiple USER_IDS....)

Another, related problem is that 

"idSpec":"USER_IDS"

 is handled as a valid idSpec which in my opinion it is not... so it should be removed from the $types array...


> bug in idSpec.php that doesnt allow array() of user ids
> -------------------------------------------------------
>
>                 Key: SHINDIG-392
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-392
>             Project: Shindig
>          Issue Type: Bug
>          Components: Common Components (PHP)
>            Reporter: bruno rovagnati
>            Assignee: Chris Chabot
>         Attachments: idSpec_USER_ID.patch
>
>
> if an array of id (or a single id) is sent for a IdSpec, php will rejected as invalid
> ps: this applies to JSON wired stuff

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SHINDIG-392) bug in idSpec.php that doesnt allow array() of user ids

Posted by "bruno rovagnati (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHINDIG-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12606912#action_12606912 ] 

bruno rovagnati commented on SHINDIG-392:
-----------------------------------------

i would remove USER_ID too, but still keep any non "VIEWER_ID"
"VIEWER_FRIENDS", etc

as a valid single (if only a "string" is sent) or multiple (["array"]) is
sent, since id for OS are strings, and in many places we have that
polymorphisms for strings/array params...

the only error will be empty


my 2 cents
On Fri, Jun 20, 2008 at 7:13 AM, Karsten Beyer (JIRA) <ji...@apache.org>



-- 
.-. --- .--. ..-
R o p u


> bug in idSpec.php that doesnt allow array() of user ids
> -------------------------------------------------------
>
>                 Key: SHINDIG-392
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-392
>             Project: Shindig
>          Issue Type: Bug
>          Components: Common Components (PHP)
>            Reporter: bruno rovagnati
>            Assignee: Chris Chabot
>         Attachments: idSpec_USER_ID.patch
>
>
> if an array of id (or a single id) is sent for a IdSpec, php will rejected as invalid
> ps: this applies to JSON wired stuff

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SHINDIG-392) bug in idSpec.php that doesnt allow array() of user ids

Posted by "Karsten Beyer (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHINDIG-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12606992#action_12606992 ] 

Karsten Beyer commented on SHINDIG-392:
---------------------------------------

i thought about it and agree. To keep it container independent, we should not touch the idSpec at this point. 

> bug in idSpec.php that doesnt allow array() of user ids
> -------------------------------------------------------
>
>                 Key: SHINDIG-392
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-392
>             Project: Shindig
>          Issue Type: Bug
>          Components: Common Components (PHP)
>            Reporter: bruno rovagnati
>            Assignee: Chris Chabot
>         Attachments: idSpec_USER_ID.patch
>
>
> if an array of id (or a single id) is sent for a IdSpec, php will rejected as invalid
> ps: this applies to JSON wired stuff

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (SHINDIG-392) bug in idSpec.php that doesnt allow array() of user ids

Posted by "Chris Chabot (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SHINDIG-392?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Chris Chabot resolved SHINDIG-392.
----------------------------------

    Resolution: Fixed
      Assignee: Chris Chabot

Thanks bruno, applied and committed!

> bug in idSpec.php that doesnt allow array() of user ids
> -------------------------------------------------------
>
>                 Key: SHINDIG-392
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-392
>             Project: Shindig
>          Issue Type: Bug
>          Components: Common Components (PHP)
>            Reporter: bruno rovagnati
>            Assignee: Chris Chabot
>         Attachments: idSpec_USER_ID.patch
>
>
> if an array of id (or a single id) is sent for a IdSpec, php will rejected as invalid
> ps: this applies to JSON wired stuff

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.