Skip to content

Commit

Permalink
Extension::checkFileExists fix for cron usage vs open_basedir
Browse files Browse the repository at this point in the history
  • Loading branch information
Gappa committed May 2, 2018
1 parent bc39467 commit 3b13e92
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions WebLoader/Nette/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,27 @@ private function findFiles(array $filesConfig, string $sourceDir): array

protected function checkFileExists(string $file, string $sourceDir): void
{
if (!file_exists($file)) {
if (!$this->fileExists($file)) {
$tmp = rtrim($sourceDir, '/\\') . DIRECTORY_SEPARATOR . $file;
if (!file_exists($tmp)) {
if (!$this->fileExists($tmp)) {
throw new \WebLoader\FileNotFoundException(sprintf("Neither '%s' or '%s' was found", $file, $tmp));
}
}
}


/**
* Some servers seem to have problems under cron user with open_basedir restriction when using relative paths
*/
protected function fileExists(string $file): bool
{
$file = realpath($file);

if ($file === false) {
$file = '';
}

return file_exists($file);
}
}

0 comments on commit 3b13e92

Please sign in to comment.