if query parameter value processing is different when value is empty or null
Open
Nobody has claimed this yet.
Extension: standard
Feature
Status: Needs Triage
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
Description
The following code:
CASE 1:
<?php
$url = "http://localhost:8964/?soap";
CASE1:
parse_url($url);
echo var_dump(parse_url($url));
$query = parse_str(parse_url($url)["query"], $result);
echo var_dump($result);
$http_query = http_build_query($result);
echo $http_query;
//CASE2 assign query param value to null
$result["soap"]=null;
echo $http_query;
//CASE 3 - replicate same as case 2 but in other form and results are different.
$arr = array('test' => null);
echo http_build_query($arr);
?>
array(5) {
["scheme"]=>
string(4) "http"
["host"]=>
string(9) "localhost"
["port"]=>
int(8964)
["path"]=>
string(1) "/"
["query"]=>
string(4) "soap"
}
array(1) {
["soap"]=>
string(0) ""
}
soap=soap=
But I expected this output instead:
CASE1: soap=
CASE2: soap
CASE3 soap
PS: if query param value is empty string or null , but query param should be in url.
PHP Version
PHP 8.1.2
Operating System
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the three cases using parse_url(), parse_str(), and http_build_query() with the sample URL and arrays. Read the existing tests for these functions and compare handling of missing, empty-string, and null values. Done means the intended query representation is documented by tests and the observed outputs are consistent with that behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100