@tsteur opened this Issue on February 2nd 2022 Member

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

@sgiehl commented on February 2nd 2022 Member

@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 commented on February 2nd 2022 Member

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

@sgiehl commented on February 3rd 2022 Member

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

This Issue was closed on February 3rd 2022
Powered by GitHub Issue Mirror