Start ConnectionWatcher before the application starts

オープン 初心者向け
#148 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
96/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
php
領域
testing

調査の方向性

Issue では Yii2::_before() が特定され、関連する起動順序が示されています。このメソッドを読み、_after() が ConnectionWatcher::closeAll() をどのように使うか確認してください。watcher の起動を recreateClient() と startApp() の間に移動してください。アプリの作成中に開かれた接続が追跡され、テスト後に閉じられれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Problem

Yii2::_before() starts the ConnectionWatcher only after startApp():

$this->recreateClient();

$this->yiiLogger = new Yii2Connector\Logger();
$this->getClient()->startApp($this->yiiLogger);

$this->connectionWatcher = new ConnectionWatcher();
$this->connectionWatcher->start();

If a connection is opened while the application is being created, the watcher never sees its EVENT_AFTER_OPEN, and closeAll() in _after() does not close it. The application is reset after each test, but the old Connection objects are not always freed, so the PDO handle stays open until the process ends. That leaks one connection per test, and a large enough suite fails with SQLSTATE[HY000] [1040] Too many connections.

Fix

Start the watcher after recreateClient() and before startApp():

         $this->recreateClient();
+
+        $this->connectionWatcher = new ConnectionWatcher();
+        $this->connectionWatcher->start();
+
         $this->yiiLogger = new Yii2Connector\Logger();
         $this->getClient()->startApp($this->yiiLogger);
-
-        $this->connectionWatcher = new ConnectionWatcher();
-        $this->connectionWatcher->start();
主要言語
PHP
スター
19
フォーク
43
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Codeception/module-yii2 のほかの issue

Codeception/module-yii2 の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。