From fbb688e89bea2885b339c792de3bdee35e9bad69 Mon Sep 17 00:00:00 2001 From: hideki_okajima Date: Fri, 16 Nov 2018 12:39:19 +0900 Subject: [PATCH] =?UTF-8?q?fix=20=E3=82=A4=E3=83=B3=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E6=99=82=E3=81=AB=E3=83=87=E3=82=A3=E3=83=AC?= =?UTF-8?q?=E3=82=AF=E3=83=88=E3=83=AA=E3=81=AB=E5=8A=A0=E3=81=88=E3=81=A6?= =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=81=AE=E6=9B=B8=E3=81=8D?= =?UTF-8?q?=E8=BE=BC=E3=81=BF=E6=A8=A9=E9=99=90=E3=82=82=E3=83=81=E3=82=A7?= =?UTF-8?q?=E3=83=83=E3=82=AF=E3=81=99=E3=82=8B=E5=87=A6=E7=90=86=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/Install/InstallController.php | 38 ++++++++++--------- src/Eccube/Resource/locale/messages.ja.yaml | 2 +- .../Resource/template/install/step2.twig | 18 ++++----- .../Web/Install/InstallControllerTest.php | 2 +- 4 files changed, 32 insertions(+), 28 deletions(-) diff --git a/src/Eccube/Controller/Install/InstallController.php b/src/Eccube/Controller/Install/InstallController.php index 07df133e1be..2cff1f4b8a3 100644 --- a/src/Eccube/Controller/Install/InstallController.php +++ b/src/Eccube/Controller/Install/InstallController.php @@ -73,12 +73,6 @@ class InstallController extends AbstractController 'mcrypt', ]; - protected $writableDirs = [ - 'app', - 'html', - 'var', - ]; - /** * @var PasswordEncoder */ @@ -159,7 +153,7 @@ public function step1(Request $request) } /** - * ディレクトリの書き込み権限をチェック. + * ディレクトリとファイルの書き込み権限をチェック. * * @Route("/install/step2", name="install_step2") * @Template("step2.twig") @@ -172,20 +166,30 @@ public function step2() throw new NotFoundHttpException(); } - $protectedDirs = []; - foreach ($this->writableDirs as $writableDir) { - $targetDirs = Finder::create() - ->in($this->getParameter('kernel.project_dir').'/'.$writableDir) - ->directories(); - foreach ($targetDirs as $targetDir) { - if (!is_writable($targetDir->getRealPath())) { - $protectedDirs[] = $targetDir; - } + $noWritePermissions = []; + + // ディレクトリの書き込み権限をチェック + $targetDirs = Finder::create() + ->in($this->getParameter('kernel.project_dir')) + ->directories(); + foreach ($targetDirs as $targetDir) { + if (!is_writable($targetDir->getRealPath())) { + $noWritePermissions[] = $targetDir; + } + } + + // ファイルの書き込み権限をチェック + $targetFiles = Finder::create() + ->in($this->getParameter('kernel.project_dir')) + ->files(); + foreach ($targetFiles as $targetFile) { + if (!is_writable($targetFile->getRealPath())) { + $noWritePermissions[] = $targetFile; } } return [ - 'protectedDirs' => $protectedDirs, + 'noWritePermissions' => $noWritePermissions, ]; } diff --git a/src/Eccube/Resource/locale/messages.ja.yaml b/src/Eccube/Resource/locale/messages.ja.yaml index d92088833c6..a7aeac98659 100644 --- a/src/Eccube/Resource/locale/messages.ja.yaml +++ b/src/Eccube/Resource/locale/messages.ja.yaml @@ -1566,7 +1566,7 @@ install.start_eccube_installation: '

EC-CUBEのインストールを開始し install.cooperation_of_providing_information: 'EC-CUBEのシステム向上・デバッグのため、サイト情報の提供にご協力おねがいいたします。
目的以外で利用することはございません。
(サイト情報:お店のURL、PHPバージョン、DBバージョン)' install.accept_infomation_provision: 送信を承諾する install.permission_is_valid: アクセス権限は正常です -install.permission_is_invalid: 以下のディレクトリのアクセス制限を変更してください。 +install.permission_is_invalid: 以下のファイルまたはディレクトリに書き込み権限を付与してください。 install.system_requirement: システム要件をご確認ください install.required_extension_disabled: '[必須] %module%拡張モジュールが有効になっていません。' install.required_database_extension_disabled: '[必須] pdo_pgsql又はpdo_mysql 拡張モジュールを有効にしてください。' diff --git a/src/Eccube/Resource/template/install/step2.twig b/src/Eccube/Resource/template/install/step2.twig index 38f48db3a3f..56195fddc6a 100644 --- a/src/Eccube/Resource/template/install/step2.twig +++ b/src/Eccube/Resource/template/install/step2.twig @@ -23,18 +23,18 @@ file that was distributed with this source code.

  • - {% if protectedDirs|length > 0 %} + {% if noWritePermissions|length > 0 %} {{ 'install.update'|trans }} {% else %} {{ 'install.next'|trans }} diff --git a/tests/Eccube/Tests/Web/Install/InstallControllerTest.php b/tests/Eccube/Tests/Web/Install/InstallControllerTest.php index 320230d4bd1..38a35a64893 100644 --- a/tests/Eccube/Tests/Web/Install/InstallControllerTest.php +++ b/tests/Eccube/Tests/Web/Install/InstallControllerTest.php @@ -85,7 +85,7 @@ public function testStep1() public function testStep2() { $this->actual = $this->controller->step2($this->request); - $this->assertArrayHasKey('protectedDirs', $this->actual); + $this->assertArrayHasKey('noWritePermissions', $this->actual); } public function testStep3()