Skip to content

Commit 5089d58

Browse files
committed
MAGETWO-60724: [Backport] - Nginx doesn't redirect to setup page when using port - for 2.0
1 parent 4ac2029 commit 5089d58

File tree

5 files changed

+26
-2
lines changed

5 files changed

+26
-2
lines changed

lib/internal/Magento/Framework/App/Http.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,7 @@ private function redirectToSetup(Bootstrap $bootstrap, \Exception $exception)
188188
. "because the Magento setup directory cannot be accessed. \n"
189189
. 'You can install Magento using either the command line or you must restore access '
190190
. 'to the following directory: ' . $setupInfo->getDir($projectRoot) . "\n";
191-
$newMessage .= 'If you are using the sample nginx configuration, please go to '
192-
. $this->_request->getScheme(). '://' . $this->_request->getHttpHost() . $setupInfo->getUrl();
191+
193192
throw new \Exception($newMessage, 0, $exception);
194193
}
195194
}

lib/internal/Magento/Framework/App/SetupInfo.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,14 @@ public function isAvailable()
145145
{
146146
$setupDir = $this->getDir($this->projectRoot);
147147
$isSubDir = false !== strpos($setupDir . '/', $this->docRoot . '/');
148+
// Setup is not accessible from pub folder
149+
$setupDir = rtrim($setupDir, '/');
150+
$lastOccurrence = strrpos($setupDir, '/pub/setup');
151+
152+
if (false !== $lastOccurrence) {
153+
$setupDir = substr_replace($setupDir, '/setup', $lastOccurrence, strlen('/pub/setup'));
154+
}
155+
148156
return $isSubDir && realpath($setupDir);
149157
}
150158

lib/internal/Magento/Framework/App/Test/Unit/SetupInfoTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,13 @@ public function isAvailableDataProvider()
191191
],
192192
true
193193
],
194+
'root within doc root + pub, existent sub-directory' => [
195+
[
196+
'DOCUMENT_ROOT' => __DIR__ . '/_files/pub/',
197+
'SCRIPT_FILENAME' => __DIR__ . '/_files/pub/index.php',
198+
],
199+
true
200+
],
194201
];
195202
}
196203
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/

0 commit comments

Comments
 (0)