When the connection to database fails, the API should return a valid response · Issue #7903 · matomo-org/matomo · GitHub
Skip to content

When the connection to database fails, the API should return a valid response #7903

Closed
@mattab

Description

@mattab

When Piwik cannot connect to the database, the API should return a valid response.

Reproduce:

  • Edit config.ini.php and set a wrong username for the database eg. xyytueyeat
  • Open index.php?module=API&method=API.getPiwikVersion&format=xml
  • Got: HTML error output
  • Expected:
    • HTTP error code 500,
    • and the API call returns a valid eg. XML response that returns the API error reponse eg.
<?xml version="1.0" encoding="utf-8" ?>
<result>
    <error message="Cannot connect to the database: SQLSTATE[28000] [1045] Access denied for user 'xyytueyeat'@'localhost' (using password: YES)" />
</result>

Steps:

  • Add test case
  • Fix issue

Refs #7901 #7902

Metadata

Metadata

Assignees

Labels

TaskIndicates an issue is neither a feature nor a bug and it's purely a "technical" change.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions