Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doctrine DBAL 2.9.3 Support #4387

Closed
nanasess opened this issue Nov 18, 2019 · 2 comments · Fixed by #4396
Closed

Doctrine DBAL 2.9.3 Support #4387

nanasess opened this issue Nov 18, 2019 · 2 comments · Fixed by #4396
Labels
improvement 機能改善
Milestone

Comments

@nanasess
Copy link
Contributor

nanasess commented Nov 18, 2019

概要(Overview)

Doctrine DBAL 2.9.3 にて Eccube\Tests\Web\Admin\Order\ShippingControllerTest::testAddAndDeleteShipping を実行すると以下のようなエラーが発生する

[2019-11-15 16:48:24] app.ERROR [N/A] [8f6b654] [N/A] [Eccube\Log\Logger:log:68] - システムエラーが発生しました。 ["There is no active transaction","/Users/nanasess/git-repos/ec-cube/vendor/dama/doctrine-test-bundle/src/DAMA/DoctrineTestBundle/Doctrine/DBAL/StaticDriver.php",142,"#0 /Users/nanasess/git-repos/ec-cube/vendor/dama/doctrine-test-bundle/src/DAMA/DoctrineTestBundle/Doctrine/DBAL/StaticDriver.php(142): PDO->rollBack()\n#1 /Users/nanasess/git-repos/ec-cube/vendor/dama/doctrine-test-bundle/src/DAMA/DoctrineTestBundle/PHPUnit/PHPUnitListener.php(18): DAMA\\DoctrineTestBundle\\Doctrine\\DBAL\\StaticDriver::rollBack()\n#2 /Users/nanasess/git-repos/ec-cube/vendor/phpunit/phpunit/src/Framework/TestResult.php(408): DAMA\\DoctrineTestBundle\\PHPUnit\\PHPUnitListener->endTest(Object(Eccube\\Tests\\Web\\Admin\\Order\\ShippingControllerTest), 1.4377460479736)\n#3 /Users/nanasess/git-repos/ec-cube/vendor/phpunit/phpunit/src/Framework/TestResult.php(895): PHPUnit\\Framework\\TestResult->endTest(Object(Eccube\\Tests\\Web\\Admin\\Order\\ShippingControllerTest), 1.4377460479736)\n#4 /Users/nanasess/git-repos/ec-cube/vendor/phpunit/phpunit/src/Framework/TestCase.php(894): PHPUnit\\Framework\\TestResult->run(Object(Eccube\\Tests\\Web\\Admin\\Order\\ShippingControllerTest))\n#5 /Users/nanasess/git-repos/ec-cube/vendor/phpunit/phpunit/src/Framework/TestSuite.php(755): PHPUnit\\Framework\\TestCase->run(Object(PHPUnit\\Framework\\TestResult))\n#6 /Users/nanasess/git-repos/ec-cube/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(545): PHPUnit\\Framework\\TestSuite->run(Object(PHPUnit\\Framework\\TestResult))\n#7 /Users/nanasess/git-repos/ec-cube/bin/.phpunit/phpunit-6.5/src/TextUI/Command.php(195): PHPUnit\\TextUI\\TestRunner->doRun(Object(PHPUnit\\Framework\\TestSuite), Array, true)\n#8 /Users/nanasess/git-repos/ec-cube/bin/.phpunit/phpunit-6.5/src/TextUI/Command.php(148): PHPUnit\\TextUI\\Command->run(Array, true)\n#9 /Users/nanasess/git-repos/ec-cube/bin/.phpunit/phpunit-6.5/phpunit(17): PHPUnit\\TextUI\\Command::main()\n#10 /Users/nanasess/git-repos/ec-cube/vendor/symfony/phpunit-bridge/bin/simple-phpunit(239): include('/Users/nanasess...')\n#11 /Users/nanasess/git-repos/ec-cube/bin/phpunit(18): require('/Users/nanasess...')\n#12 {main}"] [, , , , ]

2.9.2(EC-CUBE4.0.3 で採用しているバージョン) では問題なし

以下の PR が原因の模様
doctrine/dbal#3679

期待する内容(Expect) or 要望 (Requirement)

Eccube\Tests\Web\Admin\Order\ShippingControllerTest::testAddAndDeleteShipping が正常に通る

再現手順(Procedure)

以下のコマンドを実行する

composer require doctrine/dbal "2.9.3"
bin/phpunit --exclude-group cache-clear,cache-clear-install,update-schema-doctrine --filter=testAddAndDeleteShipping tests/Eccube/Tests/Web/Admin/Order/ShippingControllerTest.php

環境 (environment)

  • EC-CUBE: 4.0.3
  • PHP: 7.3.10
  • DB:
    • PostgreSQL
    • MySQL
    • SQLite3

関連情報 (Ref)

  • PHP7.4 に対応するためには、本件の問題を解決する必要がありそう
  • PHP7.4 対応 #4384
@nanasess nanasess changed the title Doctrine DBAL 2.9.3 対応 Doctrine DBAL 2.9.3 Support Nov 18, 2019
@nanasess
Copy link
Contributor Author

以下、最小限の再現コードです。
2回リクエストをコールした後、 INSERT をするとアクティブではないトランザクションが発生します。

<?php

namespace Eccube\Tests\Web;

use Eccube\Common\Constant;
use Eccube\Entity\ProductClass;

class TopControllerTest extends AbstractWebTestCase
{
    public function testRoutingIndex()
    {
        $this->client->request('GET', $this->generateUrl('homepage'));
        $this->client->request('GET', $this->generateUrl('homepage'));

        $News = new \Eccube\Entity\News();
        $News->setTitle('aaa');
        $News->setVisible(true);
        $this->entityManager->persist($News);
        $this->entityManager->flush();

        self::assertTrue(true);
    }
}

@nanasess
Copy link
Contributor Author

2回リクエストをコールした後、

1回目のリクエスト終了時に DoctrineBundle::shutdown() がコールされた際、 Connection が close されてしまうのが根本的な原因の模様。
テスト用の DoctrineBundle を独自に作成することで回避できそう

nanasess added a commit to nanasess/ec-cube that referenced this issue Nov 26, 2019
This was referenced Nov 26, 2019
@chihiro-adachi chihiro-adachi added the improvement 機能改善 label Dec 10, 2019
@chihiro-adachi chihiro-adachi added this to the 4.0.x milestone Dec 10, 2019
@chihiro-adachi chihiro-adachi modified the milestones: 4.0.x, 4.0.4 May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement 機能改善
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants