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

Fix invalid parameter handling for PHP 8 in API.getBulkRequest #18720

Closed
tsteur opened this issue Feb 2, 2022 · 3 comments · Fixed by #18734
Closed

Fix invalid parameter handling for PHP 8 in API.getBulkRequest #18720

tsteur opened this issue Feb 2, 2022 · 3 comments · Fixed by #18734
Assignees
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@tsteur
Copy link
Member

tsteur commented Feb 2, 2022

Issue with PHP 8:

Error: {"message":"array_map(): Argument #2 ($array) must be of type array, string given","file":"/plugins/API/API.php","line":463,"request_id":"962b0","backtrace":" on /plugins/API/API.php(463)\n#0 /plugins/API/API.php(463): array_map('urldecode', 'pageUrl=https:/...')\n#1 [internal function]: Piwik\Plugins\API\API->getBulkRequest('pageUrl=https:/...')\n#2 /core/API/Proxy.php(244): call_user_func_array(Array, Array)\n#3 /core/Context.php(28): Piwik\API\Proxy->Piwik\API\{closure}()\n#4 /core/API/Proxy.php(335): Piwik\Context::executeWithQueryParameters(Array, Object(Closure))\n#5 /core/API/Request.php(266): Piwik\API\Proxy->call('\\Piwik\\Plugins\\...', 'getBulkRequest', Array)\n#6 /plugins/API/Controller.php(46): Piwik\API\Request->process()\n#7 [internal function]: Piwik\Plugins\API\Controller->index()\n#8 /core/FrontController.php(619): call_user_func_array(Array, Array)\n#9 /core/FrontController.php(168)

GET: {"filter_limit":100}

POST: {"token_auth":"XYZANONYMIZED","module":"API","method":"API.getBulkRequest","format":"json","urls":"pageUrl=https://www.foo.bar/baz/123"}

urls should have been an array but was a string

@tsteur tsteur added the Bug For errors / faults / flaws / inconsistencies etc. label Feb 2, 2022
@tsteur tsteur added this to the 4.8.0 milestone Feb 2, 2022
@sgiehl
Copy link
Member

sgiehl commented Feb 2, 2022

@tsteur should we throw an exception in case the parameter type doesn't match or would you expect the parameter to be converted to and array with one element?

@tsteur
Copy link
Member Author

tsteur commented Feb 2, 2022

No preference. Mostly concerned around backwards compatibility. Do we know what PHP 7.X did? be great to keep kind of same behaviour.

@sgiehl
Copy link
Member

sgiehl commented Feb 3, 2022

array_map on a string results in NULL on PHP 7. Will create PR to make that behavior consistent across PHP versions.

@sgiehl sgiehl self-assigned this Feb 3, 2022
@justinvelluppillai justinvelluppillai changed the title Fatal error array_map(): Argument #2 ($array) must be of type array, string in API/API.php Fix invalid parameter handling for PHP 8 in API.getBulkRequest Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants