File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,10 @@ class FacebookApiException extends Exception
4242 public function __construct ($ result ) {
4343 $ this ->result = $ result ;
4444
45- $ code = isset ($ result ['error_code ' ]) ? $ result ['error_code ' ] : 0 ;
45+ $ code = 0 ;
46+ if (isset ($ result ['error_code ' ]) && is_int ($ result ['error_code ' ])) {
47+ $ code = $ result ['error_code ' ];
48+ }
4649
4750 if (isset ($ result ['error_description ' ])) {
4851 // OAuth 2.0 Draft 10 style
Original file line number Diff line number Diff line change @@ -1350,6 +1350,11 @@ public function testExceptionConstructorWithErrorCode() {
13501350 $ this ->assertEquals ($ code , $ e ->getCode ());
13511351 }
13521352
1353+ public function testExceptionConstructorWithInvalidErrorCode () {
1354+ $ e = new FacebookApiException (array ('error_code ' => 'not an int ' ));
1355+ $ this ->assertEquals (0 , $ e ->getCode ());
1356+ }
1357+
13531358 // this happens often despite the fact that it is useless
13541359 public function testExceptionTypeFalse () {
13551360 $ e = new FacebookApiException (false );
You can’t perform that action at this time.
0 commit comments