Skip to content

Commit

Permalink
refs matomo-org#5144 better fix for array to string to conversion.
Browse files Browse the repository at this point in the history
Noticed this hack while I worked on the tracker refactoring. Dispatch
should always return a string. Fixing the problem where it actually occurs.
An even better fix would be not to support serialize=0 for format PHP as
it is meant only for internal requests. If someone wants to access data
serialize=1 should be set.
  • Loading branch information
tsteur committed Dec 4, 2014
1 parent 8fe1e92 commit 54ce7af
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 1 addition & 3 deletions core/dispatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@
$controller->init();
$response = $controller->dispatch();

if (is_array($response)) {
var_export($response);
} elseif (!is_null($response)) {
if (!is_null($response)) {
echo $response;
}
} catch (Exception $ex) {
Expand Down
8 changes: 7 additions & 1 deletion plugins/API/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ function index()
}

$request = new Request('token_auth=' . Common::getRequestVar('token_auth', 'anonymous', 'string'));
return $request->process();
$response = $request->process();

if (is_array($response)) {
$response = var_export($response, true);
}

return $response;
}

public function listAllMethods()
Expand Down

0 comments on commit 54ce7af

Please sign in to comment.