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

More helpful error message in checkEnvironment.php #958

Merged
merged 4 commits into from Apr 18, 2019
Merged
Changes from 3 commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -125,6 +125,12 @@ public function checkAll()
$problemsFound = true;
}
if ($this->checkDirectories()) {
$problemsFound = true;
// Skip checkPermissions() if the required directories do not exist.
return $problemsFound;

This comment has been minimized.

Copy link
@lcharette

lcharette Apr 6, 2019

Member

Careful with the indentation here

This comment has been minimized.

Copy link
@amosfolz

amosfolz Apr 6, 2019

Author Contributor

Thanks for the information! I will look over the PSR guides and get more familiar with the UF style guide as well.

}
if ($this->checkPermissions()) {
$problemsFound = true;
}
@@ -257,6 +263,39 @@ public function checkPdo()
return $problemsFound;
}
/**
* Check that log, cache, and session directories exist.
*/
public function checkDirectories()
{
$problemsFound = false;
$directoryPaths = [
"logs" => $this->locator->findResource('log://'),
"cache" => $this->locator->findResource('cache://'),
"sessions" => $this->locator->findResource('session://')
];
foreach ($directoryPaths as $directory => $path) {
if ($path == null) {

This comment has been minimized.

Copy link
@lcharette

lcharette Apr 6, 2019

Member

Indentation should be 4 spaces

$problemsFound = true;
$this->resultsFailed['directory-' . $directory] = [
'title' => "<i class='fa fa-file-o fa-fw'></i> A required directory was not found.",
'message' => "Please check that <code>userfrosting/app/$directory</code> exists.",
'success' => false
];
}
else {

This comment has been minimized.

Copy link
@lcharette

lcharette Apr 6, 2019

Member

Brace should be on the same line per PSR-2
https://www.php-fig.org/psr/psr-2/#51-if-elseif-else

$this->resultsSuccess['directory-' . $directory] = [
'title' => "<i class='fa fa-file-o fa-fw'></i> File/directory check passed!",
'message' => "<code>userfrosting/app/$directory</code> exists.",
'success' => true
];
}
}
return $problemsFound;
}
/**
* Check that log, cache, and session directories are writable, and that other directories are set appropriately for the environment.
*/
@@ -280,15 +319,6 @@ public function checkPermissions()
// Check for essential files & perms
foreach ($shouldBeWriteable as $file => $assertWriteable) {
$is_dir = false;
if (!file_exists($file)) {
$problemsFound = true;
$this->resultsFailed['file-' . $file] = [
'title' => "<i class='fa fa-file-o fa-fw'></i> File or directory does not exist.",
'message' => "We could not find the file or directory <code>$file</code>.",
'success' => false
];
} else {
$writeable = is_writable($file);
if ($assertWriteable !== $writeable) {
$problemsFound = true;
@@ -311,10 +341,8 @@ public function checkPermissions()
. '</b>.',
'success' => true
];
}
}
}
}
return $problemsFound;
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.