-
Notifications
You must be signed in to change notification settings - Fork 2k
Remove default Graph API version fallback #643
Changes from 1 commit
0f3ba5b
1db2588
883982d
a652499
4d8edbe
fd40369
7e222e8
967246f
bc15ca9
bf90316
1362e0e
041164b
4efc534
3f9fd16
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,11 +55,6 @@ class Facebook | |
*/ | ||
const VERSION = '6.0-dev'; | ||
|
||
/** | ||
* @const string Default Graph API version for requests. | ||
*/ | ||
const DEFAULT_GRAPH_VERSION = 'v2.7'; | ||
|
||
/** | ||
* @const string The name of the environment variable that contains the app ID. | ||
*/ | ||
|
@@ -127,7 +122,6 @@ public function __construct(array $config = []) | |
$config = array_merge([ | ||
'app_id' => getenv(static::APP_ID_ENV_NAME), | ||
'app_secret' => getenv(static::APP_SECRET_ENV_NAME), | ||
'default_graph_version' => static::DEFAULT_GRAPH_VERSION, | ||
'enable_beta_mode' => false, | ||
'http_client_handler' => null, | ||
'persistent_data_handler' => null, | ||
|
@@ -141,6 +135,9 @@ public function __construct(array $config = []) | |
if (!$config['app_secret']) { | ||
throw new FacebookSDKException('Required "app_secret" key not supplied in config and could not find fallback environment variable "' . static::APP_SECRET_ENV_NAME . '"'); | ||
} | ||
if (empty($config['default_graph_version'])) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you keep the key above, then I'll check here like above, |
||
throw new \InvalidArgumentException('Required "default_graph_version" key not supplied in config'); | ||
} | ||
|
||
$this->app = new FacebookApp($config['app_id'], $config['app_secret']); | ||
$this->client = new FacebookClient( | ||
|
@@ -159,7 +156,6 @@ public function __construct(array $config = []) | |
$this->setDefaultAccessToken($config['default_access_token']); | ||
} | ||
|
||
// @todo v6: Throw an InvalidArgumentException if "default_graph_version" is not set | ||
$this->defaultGraphVersion = $config['default_graph_version']; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,7 +102,8 @@ public function __construct(FacebookApp $app = null, $accessToken = null, $metho | |
$this->setEndpoint($endpoint); | ||
$this->setParams($params); | ||
$this->setETag($eTag); | ||
$this->graphVersion = $graphVersion ?: Facebook::DEFAULT_GRAPH_VERSION; | ||
// @TODO Remove this fall-back | ||
$this->graphVersion = $graphVersion ?: 'v2.7'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the way to handle this case is to allow null graph version in requests. This parameter is here to override the version given in the client, so it can be null, we just have to take care of this value when sending the request, falling back to the client version when this is null :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hello yguedidi! I have no certainties about this case version 2.8 yet and icoguinita for me, but I resolve to be with this team for sure has brilhates minds, we try faser tests, for and studying the case to come to perfection. I trust you guys the importate and not waste time, bad weather do quick pass worth every second. with an impeccable work. ok let's see what happens reversing from 2.7 to 2.8 ok There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,14 +125,14 @@ public function testAProperUrlWillBeGenerated() | |
|
||
$getUrl = $getRequest->getUrl(); | ||
$expectedParams = 'foo=bar&access_token=foo_token&appsecret_proof=df4256903ba4e23636cc142117aa632133d75c642bd2a68955be1443bd14deb9'; | ||
$expectedUrl = '/' . Facebook::DEFAULT_GRAPH_VERSION . '/foo?' . $expectedParams; | ||
$expectedUrl = '/' . FacebookTest::DEFAULT_GRAPH_VERSION . '/foo?' . $expectedParams; | ||
|
||
$this->assertEquals($expectedUrl, $getUrl); | ||
|
||
$postRequest = new FacebookRequest($app, 'foo_token', 'POST', '/bar', ['foo' => 'bar']); | ||
|
||
$postUrl = $postRequest->getUrl(); | ||
$expectedUrl = '/' . Facebook::DEFAULT_GRAPH_VERSION . '/bar'; | ||
$expectedUrl = '/' . FacebookTest::DEFAULT_GRAPH_VERSION . '/bar'; | ||
|
||
$this->assertEquals($expectedUrl, $postUrl); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd add a case for a versionned request, as it useful in the case of batched request to use a different version than the one of the master request :) |
||
} | ||
|
@@ -156,7 +156,7 @@ public function testAuthenticationParamsAreStrippedAndReapplied() | |
$url = $request->getUrl(); | ||
|
||
$expectedParams = 'bar=baz&access_token=foo_token&appsecret_proof=df4256903ba4e23636cc142117aa632133d75c642bd2a68955be1443bd14deb9'; | ||
$expectedUrl = '/' . Facebook::DEFAULT_GRAPH_VERSION . '/foo?' . $expectedParams; | ||
$expectedUrl = '/' . FacebookTest::DEFAULT_GRAPH_VERSION . '/foo?' . $expectedParams; | ||
$this->assertEquals($expectedUrl, $url); | ||
|
||
$params = $request->getParams(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,8 @@ | |
|
||
class FacebookTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
const DEFAULT_GRAPH_VERSION = 'v2.7'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be changed to 2.8 :) |
||
|
||
protected $config = [ | ||
'app_id' => '1337', | ||
'app_secret' => 'foo_secret', | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong indentation :)