facebookarchive / php-graph-sdk

The Facebook SDK for PHP provides a native interface to the Graph API and Facebook Login. https://developers.facebook.com/docs/php
Other
3.17k stars 1.95k forks source link

AccessTokenMetadata::getMetadata() should return metadata field; instead returns null. #1211

Open endersaka opened 3 years ago

endersaka commented 3 years ago

This issue affects both 5.7 Line 253 and master Line 235.

public function getMetadata()
{
    return $this->getField('metadata');
}

This is getField() method. Quite obviously there is no 'metadata' field inside $this->metadata. Therefore getMetadata() always returns null.

public function getField($field, $default = null)
{
    if (isset($this->metadata[$field])) {
        return $this->metadata[$field];
    }

    return $default;
}

I think that getMetadata() body should be something like:

    return isset($this->metadata) ? $this->metadata : null;