[php-src] Issue #20501: \Uri\WhatWg\Url miss host after calling withPath() or withQuery()

From: Date: Sun, 16 Nov 2025 07:50:08 +0000
Subject: [php-src] Issue #20501: \Uri\WhatWg\Url miss host after calling withPath() or withQuery()
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-251231@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/20501 Author: asika32764 ### Description The following code: ```php <?php $url = new \Uri\WhatWg\Url('http://127.0.0.1:8080/path?query=123#fragment'); var_dump($url, $url->toAsciiString()); $url = $url->withPath('/hello-world'); var_dump($url, $url->toAsciiString()); ``` Resulted in this output: ``` object(Uri\WhatWg\Url)#1 (8) { ["scheme"]=> string(4) "http" ["username"]=> NULL ["password"]=> NULL ["host"]=> string(9) "127.0.0.1" ["port"]=> int(8080) ["path"]=> string(5) "/path" ["query"]=> string(9) "query=123" ["fragment"]=> string(8) "fragment" } string(45) "http://127.0.0.1:8080/path?query=123#fragment" object(Uri\WhatWg\Url)#2 (8) { ["scheme"]=> string(4) "http" ["username"]=> NULL ["password"]=> NULL ["host"]=> NULL ["port"]=> int(8080) ["path"]=> string(12) "/hello-world" ["query"]=> string(9) "query=123" ["fragment"]=> string(8) "fragment" } string(36) "http:/hello-world?query=123#fragment" ``` But I expected this output instead: ``` object(Uri\WhatWg\Url)#1 (8) { ["scheme"]=> string(4) "http" ["username"]=> NULL ["password"]=> NULL ["host"]=> string(9) "127.0.0.1" ["port"]=> int(8080) ["path"]=> string(5) "/path" ["query"]=> string(9) "query=123" ["fragment"]=> string(8) "fragment" } string(45) "http://127.0.0.1:8080/path?query=123#fragment" object(Uri\WhatWg\Url)#2 (8) { ["scheme"]=> string(4) "http" ["username"]=> NULL ["password"]=> ["host"]=> string(9) "127.0.0.1" NULL ["port"]=> int(8080) ["path"]=> string(12) "/hello-world" ["query"]=> string(9) "query=123" ["fragment"]=> string(8) "fragment" } string(36) "http://127.0.0.1:8080/hello-world?query=123#fragment" ``` ### PHP Version ```plain PHP 8.5.0RC4 (cli) (built: Nov 6 2025 03:02:00) (NTS) Copyright (c) The PHP Group Zend Engine v4.5.0RC4, Copyright (c) Zend Technologies with Zend OPcache v8.5.0RC4, Copyright (c), by Zend Technologies ``` ### Operating System macOS

« previous php.bugs (#251231) next »