Skip to content

Commit fb0b7bb

Browse files
committed
Fix request parameters after calling rewrite() on the request
1 parent 71e07ac commit fb0b7bb

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

ChangeLog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ Web change log
33

44
## ?.?.? / ????-??-??
55

6+
## 4.1.1 / 2024-04-20
7+
8+
* Fixed request parameters being out of sync with the URI after calling
9+
the `web.Request::rewrite()` method
10+
(@thekid)
611
* Made compatible with `xp-forge/uri` version 3.0.0 - @thekid
712

813
## 4.1.0 / 2024-03-24

src/main/php/web/Request.class.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public function pass($name, $value) {
5656
*/
5757
public function rewrite($uri) {
5858
$this->uri= $this->uri->resolve($uri instanceof URI ? $uri : new URI($uri));
59+
$this->params= null; // Force re-evaluation
5960
return $this;
6061
}
6162

src/test/php/web/unittest/RequestTest.class.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ public function rewrite_request_relative($uri) {
5151
Assert::equals(new URI('http://localhost/r'), (new Request(new TestInput('GET', '/')))->rewrite($uri)->uri());
5252
}
5353

54+
#[Test, Values([['/', []], ['/?c=test', ['c' => 'test']]])]
55+
public function parameters_and_rewriting($uri, $expected) {
56+
$req= new Request(new TestInput('GET', '/?a=b&c=d'));
57+
$req->params(); // Ensure params are passed from the query string
58+
59+
Assert::equals($expected, $req->rewrite($uri)->params());
60+
}
61+
5462
#[Test]
5563
public function uri_respects_host_header() {
5664
Assert::equals(

0 commit comments

Comments
 (0)