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

Ram Sharma updated SHINDIG-367:
-------------------------------

    Attachment: BasicPeopleService.php.patch

> 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
>            Priority: Blocker
>         Attachments: BasicPeopleService.php.patch
>
>
> 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