Set recreateApplicationBetweenRequests to true by default
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 45/100
Direzione di ricerca
Esamina i commit referenziati e individua dove sono definiti recreateApplicationBetweenTests e recreateApplicationBetweenRequests e dove vengono applicati i relativi valori predefiniti. Conferma il comportamento di reimpostazione dello stato a livello di richiesta descritto nell’esempio IdentityHelperMiddleware, quindi verifica che il valore predefinito sia true e che i test dei moduli esistenti coprano il comportamento modificato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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?
- Lingua principale
- PHP
- Stelle
- 1
- Fork
- 4
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Codeception/module-mezzio
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
Codeception/module-mezzio#18 · 3 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
Codeception/module-mezzio#7 · 4 commenti ·
Tutte le issue di Codeception/module-mezzio
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
taskforcesh/bullmq#5238 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug] v-change-database-password reports success but doesn't change the password when MySQL validate_password rejects itForse già presa @bfs2021 l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
Automattic/jetpack#55517 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 84/100
-
area/import type/enhancement when/later
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
I maintainer di solito rispondono entro 1 giorno