Skip to content

Commit e581092

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-51580-misleading-error-messages' into PR_Branch
2 parents 9701889 + c50d42c commit e581092

File tree

4 files changed

+71
-24
lines changed

4 files changed

+71
-24
lines changed

lib/internal/Magento/Framework/Setup/FilePermissions.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ private function checkRecursiveDirectories($directory)
160160
try {
161161
foreach ($directoryIterator as $subDirectory) {
162162
if (!$subDirectory->isWritable() && !$subDirectory->isLink()) {
163-
$this->nonWritablePathsInDirectories[$directory][] = $subDirectory;
163+
$this->nonWritablePathsInDirectories[$directory][] = $subDirectory->getPathname();
164164
$foundNonWritable = true;
165165
}
166166
}
@@ -226,23 +226,32 @@ protected function isReadableDirectory($directory)
226226
}
227227

228228
/**
229-
* Checks writable paths for installation
229+
* Checks writable paths for installation, returns associative array if input is true, else returns simple array
230230
*
231+
* @param bool $associative
231232
* @return array
232233
*/
233-
public function getMissingWritablePathsForInstallation()
234+
public function getMissingWritablePathsForInstallation($associative = false)
234235
{
235236
$required = $this->getInstallationWritableDirectories();
236237
$current = $this->getInstallationCurrentWritableDirectories();
237238
$missingPaths = [];
238239
foreach (array_diff($required, $current) as $missingPath) {
239240
if (isset($this->nonWritablePathsInDirectories[$missingPath])) {
240-
$missingPaths = array_merge(
241-
$missingPaths,
242-
$this->nonWritablePathsInDirectories[$missingPath]
243-
);
241+
if ($associative) {
242+
$missingPaths[$missingPath] = $this->nonWritablePathsInDirectories[$missingPath];
243+
} else {
244+
$missingPaths = array_merge(
245+
$missingPaths,
246+
$this->nonWritablePathsInDirectories[$missingPath]
247+
);
248+
}
244249
}
245250
}
251+
if ($associative) {
252+
$required = array_flip($required);
253+
$missingPaths = array_merge($required, $missingPaths);
254+
}
246255
return $missingPaths;
247256
}
248257

setup/src/Magento/Setup/Controller/Environment.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,26 @@ private function getPhpChecksInfo($type)
160160
public function filePermissionsAction()
161161
{
162162
$responseType = ResponseTypeInterface::RESPONSE_TYPE_SUCCESS;
163-
if ($this->permissions->getMissingWritablePathsForInstallation()) {
164-
$responseType = ResponseTypeInterface::RESPONSE_TYPE_ERROR;
163+
$missingWritePermissionPaths = $this->permissions->getMissingWritablePathsForInstallation(true);
164+
165+
$currentPaths = [];
166+
$requiredPaths = [];
167+
if ($missingWritePermissionPaths) {
168+
foreach ($missingWritePermissionPaths as $key => $value) {
169+
if (is_array($value)) {
170+
$requiredPaths[] = ['path' => $key, 'missing' => $value];
171+
$responseType = ResponseTypeInterface::RESPONSE_TYPE_ERROR;
172+
} else {
173+
$requiredPaths[] = ['path' => $key];
174+
$currentPaths[] = $key;
175+
}
176+
}
165177
}
166-
167178
$data = [
168179
'responseType' => $responseType,
169180
'data' => [
170-
'required' => $this->permissions->getInstallationWritableDirectories(),
171-
'current' => $this->permissions->getInstallationCurrentWritableDirectories(),
181+
'required' => $requiredPaths,
182+
'current' => $currentPaths,
172183
],
173184
];
174185

setup/src/Magento/Setup/Test/Unit/Controller/EnvironmentTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,23 @@ public function setUp()
5858
);
5959
}
6060

61+
public function testFilePermissionsInstaller()
62+
{
63+
$request = $this->getMock('\Zend\Http\PhpEnvironment\Request', [], [], '', false);
64+
$response = $this->getMock('\Zend\Http\PhpEnvironment\Response', [], [], '', false);
65+
$routeMatch = $this->getMock('\Zend\Mvc\Router\RouteMatch', [], [], '', false);
66+
67+
$mvcEvent = $this->getMock('\Zend\Mvc\MvcEvent', [], [], '', false);
68+
$mvcEvent->expects($this->once())->method('setRequest')->with($request)->willReturn($mvcEvent);
69+
$mvcEvent->expects($this->once())->method('setResponse')->with($response)->willReturn($mvcEvent);
70+
$mvcEvent->expects($this->once())->method('setTarget')->with($this->environment)->willReturn($mvcEvent);
71+
$mvcEvent->expects($this->any())->method('getRouteMatch')->willReturn($routeMatch);
72+
$this->permissions->expects($this->once())->method('getMissingWritablePathsForInstallation');
73+
$this->environment->setEvent($mvcEvent);
74+
$this->environment->dispatch($request, $response);
75+
$this->environment->filePermissionsAction();
76+
}
77+
6178
public function testPhpVersionActionInstaller()
6279
{
6380
$request = $this->getMock('\Zend\Http\PhpEnvironment\Request', [], [], '', false);

setup/view/magento/setup/readiness-check/progress.phtml

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<div class="message message-error" ng-switch-when="true">
1515
<span class="message-text">
16-
<strong>Completed!</strong> You need to resolve these issues to continue.
16+
<strong>Error!</strong> You need to resolve these issues to continue.
1717
</span>
1818
</div>
1919

@@ -443,25 +443,35 @@
443443
<span ng-show="permissions.expanded">Hide detail</span>
444444
</a>
445445
</p>
446-
<p>
447-
The best way to resolve this is to allow write permissions for the following Magento
448-
directories and their sub-directories. The exact fix depends on your server, your host,
446+
<p ng-show="permissions.expanded">
447+
The best way to resolve this is to allow write permissions for files in the following Magento directories and subdirectories. The exact fix depends on your server, your host,
449448
and other system variables.
450449
<br>
451-
Our <a href="http://devdocs.magento.com/guides/v2.0/install-gde/install/file-system-perms.html" target="_blank">File Permission Help</a> can get you started.
452-
</p>
453-
<p>
454-
If you need more help, please call your hosting provider.
450+
For help, see our <a href="http://devdocs.magento.com/guides/v2.0/install-gde/install/file-system-perms.html" target="_blank">File Permission Help</a> or call your hosting provider.
455451
</p>
456-
457-
<ul class="list" ng-show="permissions.expanded">
452+
<ul class="list" ng-show="permissions.expanded" ng-init="showDetails=false">
458453
<li
459454
class="list-item-icon"
460455
ng-repeat="name in permissions.data.required"
461-
ng-switch="hasItem(permissions.data.current, name)">
456+
ng-switch="hasItem(permissions.data.current, name.path)">
462457
<span ng-switch-when="true" class="icon-success"></span>
463458
<span ng-switch-default class="icon-failed"></span>
464-
<span>"{{name}}" writable directory permission.</span>
459+
<span>"{{name.path}}"</span>
460+
<span ng-switch-when="true">
461+
- Writable.
462+
</span>
463+
<span ng-switch-default ng-hide="permission.expanded">
464+
- Not writable, change the permissions.
465+
<a href="#" ng-click="showDetails = !showDetails"">
466+
<span ng-hide="showDetails">Show details</span>
467+
<span ng-show="showDetails">Hide details</span>
468+
</a>
469+
<ul ng-show="showDetails" ng-repeat="file in name.missing">
470+
<li class="icon-failed">
471+
{{file}}<br>
472+
</li>
473+
</ul>
474+
</span>
465475
</li>
466476
</ul>
467477

0 commit comments

Comments
 (0)