matomo-org / matomo

Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
https://matomo.org/
GNU General Public License v3.0
19.88k stars 2.65k forks source link

preg_match(): Argument #2 ($subject) must be of type string, array given #19220

Closed JasonMortonNZ closed 1 year ago

JasonMortonNZ commented 2 years ago

The following error has been popping up recently:

Error: {"message":"preg_match(): Argument #2 ($subject) must be of type string, array given","file":"\/var\/www\/html\/core\/Period\/Factory.php","line":170,"request_id":"da1a8","backtrace":" on \/var\/www\/html\/core\/Period\/Factory.php(170)\n#0 \/var\/www\/html\/core\/Period\/Factory.php(170): preg_match('\/^(now|today|ye...', Array)\n#1 \/var\/www\/html\/core\/Archive\/ArchiveQueryFactory.php(107): Piwik\\Period\\Factory::makePeriodFromQueryParams('Europe\/Paris', 'day', Array)\n#2 \/var\/www\/html\/core\/Archive\/ArchiveQueryFactory.php(31): Piwik\\Archive\\ArchiveQueryFactory->getPeriodInfoFromQueryParam(Array, 'day', 'Europe\/Paris')\n#3 \/var\/www\/html\/core\/Archive.php(218): Piwik\\Archive\\ArchiveQueryFactory->build('1', 'day', Array, false, false)\n#4 \/var\/www\/html\/plugins\/Resolution\/API.php(27): Piwik\\Archive::build('1', 'day', Array, false)\n#5 \/var\/www\/html\/plugins\/Resolution\/API.php(36): Piwik\\Plugins\\Resolution\\API->getDataTable('Resolution_reso...', '1', 'day', Array, false)\n#6 [internal function]: Piwik\\Plugins\\Resolution\\API->getResolution('1', 'day', Array, false)\n#7 \/var\/www\/html\/core\/API\/Proxy.php(244): call_user_func_array(Array, Array)\n#8 \/var\/www\/html\/core\/Context.php(28): Piwik\\API\\Proxy->Piwik\\API\\{closure}()\n#9 \/var\/www\/html\/core\/API\/Proxy.php(335): Piwik\\Context::executeWithQueryParameters(Array, Object(Closure))\n#10 \/var\/www\/html\/core\/API\/Request.php(266): Piwik\\API\\Proxy->call('\\\\Piwik\\\\Plugins\\\\...', 'getResolution', Array)\n#11 \/var\/www\/html\/plugins\/API\/Controller.php(45): Piwik\\API\\Request->process()\n#12 [internal function]: Piwik\\Plugins\\API\\Controller->index()\n#13 \/var\/www\/html\/core\/FrontController.php(631): call_user_func_array(Array, Array)\n#14 \/var\/www\/html\/core\/FrontController.php(169): Piwik\\FrontController->doDispatch('API', false, Array)\n#15 \/var\/www\/html\/core\/dispatch.php(32): Piwik\\FrontController->dispatch()\n#16 \/var\/www\/html\/index.php(25): require_once('\/var\/www\/html\/c...')\n#17 {main}","safemode_backtrace":"#0 [internal function]: Piwik\\Plugins\\Cloud\\Controller->safemode(Array)\n#1 \/core\/FrontController.php(631): call_user_func_array(Array, Array)\n#2 \/core\/FrontController.php(169): Piwik\\FrontController->doDispatch('Cloud', 'safemode', Array)\n#3 \/core\/FrontController.php(100): Piwik\\FrontController->dispatch('CorePluginsAdmi...', 'safemode', Array)\n#4 \/core\/FrontController.php(140): Piwik\\FrontController::(Array)\n#5 \/core\/FrontController.php(190): Piwik\\FrontController::(Object(TypeError))\n#6 \/core\/dispatch.php(32): Piwik\\FrontController->dispatch()\n#7 \/index.php(25): require_once('\/c...')\n#8 {main}"}

Steps to reproduce

URL: https://matomo.test/index.php?date[$acunetix]=1&format=JSON&idSite=1&method=Resolution.getResolution&module=API&period=day&token_auth=XYZANONYMIZED

Your environment

sgiehl commented 2 years ago

Also improper parameter handling. date is provided as an array, but we expect a single value only. See https://github.com/matomo-org/matomo/issues/19222#issuecomment-1127400420