Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Warning: Undefined array key 1" && "strtok(): Argument #1 ($string) must be of type string, null given" #197

Open
developers-shared opened this issue Feb 18, 2025 · 2 comments

Comments

@developers-shared
Copy link
Contributor

developers-shared commented Feb 18, 2025

Hello, after upgrading from 0.6.2 to 0.8.3 we notice following errors and warning into our logs

/app/vendor/membrane/membrane/src/OpenAPI/Filter/QueryStringToArray.php:66

"Warning: Undefined array key 4"

"[\"/app/vendor/membrane/membrane/src/Processor/Field.php:70\",\"/app/vendor/membrane/membrane/src/Processor/BeforeSet.php:42\",\"/app/vendor/membrane/membrane/src/Processor/FieldSet.php:184\",\"/app/vendor/membrane/membrane/src/Processor/FieldSet.php:128\",\"/app/vendor/membrane/membrane/src/OpenAPI/Processor/Request.php:96\",...]"

/app/vendor/membrane/membrane/src/OpenAPI/Filter/QueryStringToArray.php:70

"strtok(): Argument #1 ($string) must be of type string, null given"

"[\"/app/vendor/membrane/membrane/src/OpenAPI/Filter/QueryStringToArray.php:70\",\"/app/vendor/membrane/membrane/src/Processor/Field.php:70\",\"/app/vendor/membrane/membrane/src/Processor/BeforeSet.php:42\",\"/app/vendor/membrane/membrane/src/Processor/FieldSet.php:184\",\"/app/vendor/membrane/membrane/src/Processor/FieldSet.php:128\",\"/app/vendor/membrane/membrane/src/OpenAPI/Processor/Request.php:96,...]"

As far as I can see it issue is in here https://github.com/membrane-php/membrane-core/blob/main/src/OpenAPI/Filter/QueryStringToArray.php#L59

it should be wrapped with array_values like this

$tokens = array_values(array_filter(explode('&', rawurldecode($value)), fn($p) => $p !== ''));

this is what I get in dump if I don't wrap it

array:5 [ 0 => "filter=all" 1 => "page=1" 2 => "per-page=40" 3 => "query=B" 5 => "sort-by=phone:asc" ]

part of url: filter=all&page=1&per-page=40&query=B%26&sort-by=phone%3Aasc

@carnage
Copy link
Contributor

carnage commented Feb 18, 2025

Your Url has a double && in it one url encoded and one not. query=B**%26&**sort-by=phone%3Aasc which would allow you to solve this issue.

It is a bug though, if you want to put a PR in I'll merge it; otherwise I'll get to it myself when I've got a bit of spare time

@developers-shared
Copy link
Contributor Author

here: #198 😄

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

No branches or pull requests

2 participants