Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Undefined offset: 1 (enabled HTTP/2 support in the Curl library used by PHP) #1076

Closed
izuk-langmedia opened this issue Nov 5, 2018 · 6 comments · Fixed by #1079
Closed

Comments

@izuk-langmedia
Copy link

izuk-langmedia commented Nov 5, 2018

https://github.com/facebook/php-graph-sdk/blob/3138249d85e8dc040f15bedd3581a3c616f49005/src/Facebook/Http/GraphRawResponse.php#L107

From today I am getting error like in title. I can see in logs this call:

Facebook\Http\GraphRawResponse->setHttpResponseCodeFromHeader('HTTP/2 200 ')

It doesn't match to regex in code:
|HTTP/\d\.\d\s+(\d+)\s+.*|

The problem appeared after we enabled HTTP/2 support in the Curl library used by PHP.

It should be solve problem i guess:
/HTTP\/\d(?:\.\d)?\s+(\d+)\s+/

Someone else getting the same error?

We are using SDK v. 5.6.3.

@izuk-langmedia izuk-langmedia changed the title Undefined offset: 1 Undefined offset: 1 (enabled HTTP/2 support in the Curl library used by PHP) Nov 6, 2018
@izuk-langmedia
Copy link
Author

I also recommend using the standard delimiter (/) instead of the one used in your code (|).
It only complicates the code and makes it less universal.

@bytestream
Copy link

bytestream commented Nov 8, 2018

Just ran into this after libcurl was automatically updated:
ea-libcurl.x86_64 0:7.61.1-1.1.1.cpanel
to
ea-libcurl-7.62.0-1.1.1.cpanel.x86_64

Will submit a PR.

bytestream added a commit to bytestream/php-graph-sdk that referenced this issue Nov 8, 2018
@jestinas
Copy link

jestinas commented Nov 9, 2018

Dangerous programming- they are assuming that they will always get a match back from preg_match.

Atleast it should be HTTP\/\d(?:\.\d)?\s+(\d+)

@jestinas
Copy link

jestinas commented Nov 9, 2018

/HTTP/\d(?:.\d)?\s+(\d+)\s+/

This won't work in this case.

HTTP/1.1 400

@pako-pl
Copy link

pako-pl commented Nov 9, 2018

The solution in @bytestream's pull request avoids using a complicated regular expression entirely:

// https://tools.ietf.org/html/rfc7230#section-3.1.2
list($version, $status, $reason) = array_pad(explode(' ', $rawResponseHeader, 3), 3, null);
$this->httpResponseCode = (int) $status;

It also may be good to throw an exception if $status is not a valid number.

@lxgiang90
Copy link

Why fix me that do not work, Please give me. Thank you.
Error message:
Ooophs, we got an error: Facebook Graph returned an error: The request is invalid because the app is configured as a desktop app

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants