Bug: `getVar()` behaves inconsistently with GET parameters
メンテナーはふだん 1 日以内に返信
@rahul05ranjan がすでに取り組んでいます。
2026年10月9日 から。
評価
調査の方向性
tests/system/HTTP/SiteURIFactoryDetectRoutePathTest.php にある参照先のテストと、system/HTTP/SiteURIFactory.php のスーパーグローバルの更新から始めます。system/Validation/Validation.php と system/HTTP/IncomingRequest.php を読み、withRequest() が getVar() をどのように使用するかを追跡します。完了条件は、テストの $_REQUEST アサーションが通過し、意図された PHP のリクエストセマンティクスに違反することなく validator->withRequest() が正しく動作することです。
索引モデルが issue の本文から書いたものです。
説明
PHP Version
8.4
CodeIgniter4 Version
4.6.4
CodeIgniter4 Installation Method
Composer (using codeigniter4/appstarter)
Which operating systems have you tested for this bug?
macOS
Which server did you use?
cli-server (PHP built-in webserver)
Environment
development
Database
What happened?
In some cases, using $validator->withRequest() will not work correctly. Let's consider this test:
As you may notice in the above test, SiteURIFactory updates some superglobals, here:
The problem is that while $_SERVER['QUERY_STRING'] and $_GET are being updated, the $_REQUEST isn't. And $_REQUEST is needed to make getVar() work correctly.
Steps to Reproduce
public function testQueryStringWithQueryStringAndRequest(): void
{
// /index.php?/ci/woot?code=good#pos
$_SERVER['REQUEST_URI'] = '/index.php?/ci/woot?code=good';
$_SERVER['QUERY_STRING'] = '/ci/woot?code=good';
$_SERVER['SCRIPT_NAME'] = '/index.php';
// these are always the same at the beginning
$_GET['/ci/woot?code'] = 'good';
$_REQUEST['/ci/woot?code'] = 'good';
$factory = $this->createSiteURIFactory($_SERVER);
$expected = 'ci/woot';
$this->assertSame($expected, $factory->detectRoutePath('QUERY_STRING'));
$this->assertSame('code=good', $_SERVER['QUERY_STRING']);
$this->assertSame(['code' => 'good'], $_GET);
// this will fail
$this->assertSame(['code' => 'good'], $_REQUEST);
}
Expected Output
Validation method $validator->withRequest() should work correctly.
The most tempting solution is to add syncRequestAfterGetChange() to Superglobals and call it from SiteURIFactory whenever $_GET is modified. This would keep $_REQUEST synchronized with current values.
The downside is it introduces "magic" behavior that violates standard PHP semantics where $_REQUEST is populated once and never auto-updated. However, since we update $_GET as a "standard", behavior, then updating $_REQUEST may be acceptable?
I was thinking about something like this:
public function syncRequestAfterGetChange(): void
{
$requestOrder = ini_get('request_order') ?: ini_get('variables_order');
$this->request = [];
foreach (str_split($requestOrder) as $type) {
match ($type) {
'G' => $this->request = array_merge($this->request, $this->get),
'P' => $this->request = array_merge($this->request, $this->post),
'C' => $this->request = array_merge($this->request, $this->cookie),
default => null,
};
}
$_REQUEST = $this->request;
}
But I'm unsure if this is the right direction.
Anything else?
- 主要言語
- PHP
- スター
- 6k
- フォーク
- 2k
- 平均マージ
- 1日 22時間
- マージ済み PR(30日)
- 59
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
codeigniter4/CodeIgniter4 のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
codeigniter4/CodeIgniter4#10616 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
codeigniter4/CodeIgniter4#10618 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 62/100
codeigniter4/CodeIgniter4#10617 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
codeigniter4/CodeIgniter4#10615 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
codeigniter4/CodeIgniter4#10589 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
codeigniter4/CodeIgniter4 の issue をすべて見る
似ている issue
-
FrameworkBundle SecurityBundle
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
symfony/symfony-docs#23277 ·
メンテナーはふだん 3 日以内に返信
-
[Sync EN] hard link does not need special permissions対応中かも @lacatoire が今日担当しました。 オープンsync-en
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
メンテナーはふだん 1 日以内に返信
-
sync-en
難易度 1/5 1時間未満 初心者へのやさしさ 76/100
メンテナーはふだん 4 日以内に返信
-
feature-request
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
omegaup/omegaup#10323 · コメント 1 件 ·
メンテナーはふだん 5 日以内に返信
-
bug mod:appointments
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
3pontos-tech/gil-benefits#303 ·