FamilySearch / gedcomx-php

PHP SDK for GEDCOM X Processing. See the documentation at
http://familysearch.github.io/gedcomx-php/
Other
35 stars 15 forks source link

Serialization for the create person request is missing the "living" property if it is false resulting in a BAD REQUEST error #59

Closed ghalpert closed 8 years ago

ghalpert commented 8 years ago

I found a bug in the toArray method (and similarly in writeXmlContents) of the Person class (gedcomx/gedcomx-php/src/Conclusion/Person.php) where the following code:

if ($this->living)) {
    $a["living"] = $this->living;
}

should be changed to:

if (isset($this->living)) {
    $a["living"] = $this->living;
}

Without the above change we get the following BAD REQUEST error when we try to create a deceased person in the FamilySearch production environment:

[Warning] => 400 FamilySearch "A living declaration is required."

The BAD REQUEST error occurs because the JSON serialization for the create person request is missing the "living" property when $this->living is false:

{ 
  "persons": [ 
    { 
      "gender": { 
        "type": "http:\/\/gedcomx.org\/Female" 
      }, 
      "names": [ 
        { 
          "type": "http:\/\/gedcomx.org\/BirthName", 
          "preferred": true, 
          "nameForms": [ 
            { 
              "fullText": "Test Mother MaidenName", 
              "parts": [ 
                { 
                  "value": "Test Mother", 
                  "type": "http:\/\/gedcomx.org\/Given" 
                }, 
                { 
                  "value": "MaidenName", 
                  "type": "http:\/\/gedcomx.org\/Surname" 
                } 
              ] 
            } 
          ] 
        } 
      ] 
    } 
  ] 
}
stoicflame commented 8 years ago

Thanks for the report.

I'll try to take a look. If you'd like to put together a pull request with the fix, that might expedite the process...

ghalpert commented 8 years ago

Sorry, not currently using git so I won't be able to do a pull request.

Thanks, George

On Thu, May 19, 2016 at 7:19 PM, Ryan Heaton notifications@github.com wrote:

Thanks for the report.

I'll try to take a look. If you'd like to put together a pull request with the fix, that might expedite the process...

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/FamilySearch/gedcomx-php/issues/59#issuecomment-220474133

stoicflame commented 8 years ago

Fixed at e4ded6e.

justincy commented 8 years ago

Any boolean property is going to be afflicted by this bug. The PHP classes use code that was generated from Enunciate, right? I believe the bug's in there.