What happened?
Http::sendHttpRequest() silently drops HTTP auth credentials when the username or password is exactly 0, and the request fails with 401 as though they were wrong.
The cURL transport gates them on !empty($httpUsername) && !empty($httpPassword) (core/Http.php:813 on 6.x-dev, :816 on 5.x-dev), and empty('0') is true in PHP. The socket transport does not agree: it uses || and then encodes the raw values (:398 / :401), so it authenticates correctly with the same credentials. Which transport runs decides whether the request succeeds.
What should happen?
A password of 0 is a valid password and should be sent, by both transports.
How can this be reproduced?
Call Http::sendHttpRequest() against a Basic-auth endpoint through the cURL transport:
- password
test → 200
- password
0 → 401
Matomo version
6.x-dev and 5.x-dev (same guard in both)
PHP version
Any — empty('0') is true in every supported version.
What browsers are you seeing the problem on?
Not applicable (e.g. an API call etc.)
Validations
What happened?
Http::sendHttpRequest()silently drops HTTP auth credentials when the username or password is exactly0, and the request fails with 401 as though they were wrong.The cURL transport gates them on
!empty($httpUsername) && !empty($httpPassword)(core/Http.php:813on 6.x-dev,:816on 5.x-dev), andempty('0')is true in PHP. The socket transport does not agree: it uses||and then encodes the raw values (:398/:401), so it authenticates correctly with the same credentials. Which transport runs decides whether the request succeeds.What should happen?
A password of
0is a valid password and should be sent, by both transports.How can this be reproduced?
Call
Http::sendHttpRequest()against a Basic-auth endpoint through the cURL transport:test→ 2000→ 401Matomo version
6.x-dev and 5.x-dev (same guard in both)
PHP version
Any —
empty('0')is true in every supported version.What browsers are you seeing the problem on?
Not applicable (e.g. an API call etc.)
Validations