[ 
https://issues.apache.org/jira/browse/SHINDIG-367?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Kevin Brown updated SHINDIG-367:
--------------------------------

    Component/s:     (was: Sample container & Examples)
                 RESTful API (PHP)

Please stop changing the components for this issue. This *IS NOT* a "sample 
container and examples" issue. Incorrectly classifying an issue will result in 
either the issue being ignored (because the people working in that area aren't 
able to help), or the issue being closed.

Thank you.

> Code was written to return only the requested profile fields but it was 
> changing the object value right after the first value check.
> ------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: SHINDIG-367
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-367
>             Project: Shindig
>          Issue Type: Bug
>          Components: RESTful API (PHP)
>         Environment: Windows, Apache
>            Reporter: Ram Sharma
>
> In php\src\socialdata\samplecontainer\BasicPeopleService.php following code 
> is written to return only those fields which are requested by the 
> gadget/client.
> if (is_array($profileDetails) && count($profileDetails)) {
>                                       $newPerson = array();
>                                       $newPerson['isOwner'] = 
> $person->isOwner;
>                                       $newPerson['isViewer'] = 
> $person->isViewer;
>                                       $newPerson['name'] = $person->name;
>                                       foreach ($profileDetails as $field) {
>                                               if (isset($person->$field) && ! 
> isset($newPerson[$field])) {
>                                                       $newPerson[$field] = 
> $person->$field;
>                                               }
>                                               $person = $newPerson;
>                                       }
> }
> But the line $person = $newPerson; which is inside the foreach loop was 
> resetting the people object just after the first field check. So other fields 
> are getting reset(unset) and not retrieved by the code even after the fields 
> are there in data source.
> I just took out the $person = $newPerson; from the foreach loop and it 
> started retrieving all the requested fields. Now code for the same looks like:
> if (is_array($profileDetails) && count($profileDetails)) {
>                                       $newPerson = array();
>                                       $newPerson['isOwner'] = 
> $person->isOwner;
>                                       $newPerson['isViewer'] = 
> $person->isViewer;
>                                       $newPerson['name'] = $person->name;
>                                       foreach ($profileDetails as $field) {
>                                               if (isset($person->$field) && ! 
> isset($newPerson[$field])) {
>                                                       $newPerson[$field] = 
> $person->$field;
>                                               }
>                                       }
> $person = $newPerson;

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

Reply via email to