Set recreateApplicationBetweenRequests to true by default
まだ誰も着手していません。
評価
調査の方向性
参照されているコミットを確認し、recreateApplicationBetweenTests と recreateApplicationBetweenRequests がどこで定義され、それらのデフォルト値がどこで適用されているかを追跡してください。IdentityHelperMiddleware の例で説明されているリクエストレベルの状態リセット動作を確認し、その後、デフォルト値が true であること、および既存のモジュールテストが変更された動作をカバーしていることを検証してください。
索引モデルが issue の本文から書いたものです。
説明
Hi, commit https://github.com/Codeception/module-zendexpressive/commit/7d405fd406bd55e1eea671ddf4faa449b3be8229 introduced the flags to recreate the application instance between tests and between requests, both set to false by default.
Commit https://github.com/Codeception/module-zendexpressive/commit/8233e766f39effd52a9d8abbe18b06bc58b759fa changed the default of recreateApplicationBetweenTests to true, which is sane to me, but without any reason described.
In my humble opinion also recreateApplicationBetweenRequests should be set to true by default, because any stateful service or component with non-deterministic behavior related to the request fails to be reset on subsequent requests.
A trivial example may be the initialization of an Identity helper:
class IdentityHelperMiddleware implements MiddlewareInterface
{
private IdentityHelper $identityHelper;
public function __construct(IdentityHelper $identityHelper)
{
$this->identityHelper = $identityHelper;
}
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$username = $request->getAttribute('username');
if (null !== $username) {
$this->identityHelper->setIdentity($username);
}
return $handler->handle($request);
}
}
In this code snipped IdentityHelper is a service instantiated only once per test with recreateApplicationBetweenRequests = false, so an hypothetical second request in the same test without the username attribute wouldn't clear the previously registered identity, while a real scenario would instead end with an empty identity for the second request.
Is this a user fault? Maybe, but PHP is shared-nothing by default, and almost every developer takes it for granted.
I don't experience any visible performance degradation switching the flag.
@Naktibalda is there any reason recreateApplicationBetweenRequests was set to false by default?
- 主要言語
- PHP
- スター
- 1
- フォーク
- 4
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Codeception/module-mezzio のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
Codeception/module-mezzio#18 · コメント 3 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
Codeception/module-mezzio#7 · コメント 4 件 ·
Codeception/module-mezzio の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
taskforcesh/bullmq#5238 ·
メンテナーはふだん 1 日以内に返信
-
[Bug] v-change-database-password reports success but doesn't change the password when MySQL validate_password rejects it対応中かも @bfs2021 が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Automattic/jetpack#55517 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 84/100
-
area/import type/enhancement when/later
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
メンテナーはふだん 1 日以内に返信