Replace file_exists() by is_file()
This commit is contained in:
parent
641cae849b
commit
8d6e9ac31e
16
lib/Pico.php
16
lib/Pico.php
@ -423,7 +423,7 @@ class Pico
|
|||||||
$this->triggerEvent('onContentLoading');
|
$this->triggerEvent('onContentLoading');
|
||||||
|
|
||||||
$hiddenFileRegex = '/(?:^|\/)(?:_|404' . preg_quote($this->getConfig('content_ext'), '/') . '$)/';
|
$hiddenFileRegex = '/(?:^|\/)(?:_|404' . preg_quote($this->getConfig('content_ext'), '/') . '$)/';
|
||||||
if (file_exists($this->requestFile) && !preg_match($hiddenFileRegex, $this->requestFile)) {
|
if (is_file($this->requestFile) && !preg_match($hiddenFileRegex, $this->requestFile)) {
|
||||||
$this->rawContent = $this->loadFileContent($this->requestFile);
|
$this->rawContent = $this->loadFileContent($this->requestFile);
|
||||||
} else {
|
} else {
|
||||||
$this->triggerEvent('on404ContentLoading');
|
$this->triggerEvent('on404ContentLoading');
|
||||||
@ -547,10 +547,10 @@ class Pico
|
|||||||
protected function loadComposerPlugins(array $pluginBlacklist = array())
|
protected function loadComposerPlugins(array $pluginBlacklist = array())
|
||||||
{
|
{
|
||||||
$composerPlugins = array();
|
$composerPlugins = array();
|
||||||
if (file_exists($this->getVendorDir() . 'vendor/pico-plugin.php')) {
|
if (is_file($this->getVendorDir() . 'vendor/pico-plugin.php')) {
|
||||||
// composer root package
|
// composer root package
|
||||||
$composerPlugins = require($this->getVendorDir() . 'vendor/pico-plugin.php') ?: array();
|
$composerPlugins = require($this->getVendorDir() . 'vendor/pico-plugin.php') ?: array();
|
||||||
} elseif (file_exists($this->getVendorDir() . '../../../vendor/pico-plugin.php')) {
|
} elseif (is_file($this->getVendorDir() . '../../../vendor/pico-plugin.php')) {
|
||||||
// composer dependency package
|
// composer dependency package
|
||||||
$composerPlugins = require($this->getVendorDir() . '../../../vendor/pico-plugin.php') ?: array();
|
$composerPlugins = require($this->getVendorDir() . '../../../vendor/pico-plugin.php') ?: array();
|
||||||
}
|
}
|
||||||
@ -637,7 +637,7 @@ class Pico
|
|||||||
$className = preg_replace('/^[0-9]+-/', '', $file);
|
$className = preg_replace('/^[0-9]+-/', '', $file);
|
||||||
$pluginFile = $file . '/' . $className . '.php';
|
$pluginFile = $file . '/' . $className . '.php';
|
||||||
|
|
||||||
if (!file_exists($this->getPluginsDir() . $pluginFile)) {
|
if (!is_file($this->getPluginsDir() . $pluginFile)) {
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
"Unable to load plugin '" . $className . "' from '" . $pluginFile . "': File not found"
|
"Unable to load plugin '" . $className . "' from '" . $pluginFile . "': File not found"
|
||||||
);
|
);
|
||||||
@ -891,7 +891,7 @@ class Pico
|
|||||||
|
|
||||||
// load main config file (config/config.yml)
|
// load main config file (config/config.yml)
|
||||||
$this->config = is_array($this->config) ? $this->config : array();
|
$this->config = is_array($this->config) ? $this->config : array();
|
||||||
if (file_exists($this->getConfigDir() . 'config.yml')) {
|
if (is_file($this->getConfigDir() . 'config.yml')) {
|
||||||
$this->config += $loadConfigClosure($this->getConfigDir() . 'config.yml');
|
$this->config += $loadConfigClosure($this->getConfigDir() . 'config.yml');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1188,7 +1188,7 @@ class Pico
|
|||||||
// if this file doesn't exist either, show the 404 page, but assume the index
|
// if this file doesn't exist either, show the 404 page, but assume the index
|
||||||
// file as being requested (maintains backward compatibility to Pico < 1.0)
|
// file as being requested (maintains backward compatibility to Pico < 1.0)
|
||||||
$indexFile = $contentDir . $requestFile . '/index' . $contentExt;
|
$indexFile = $contentDir . $requestFile . '/index' . $contentExt;
|
||||||
if (file_exists($indexFile) || !file_exists($contentDir . $requestFile . $contentExt)) {
|
if (is_file($indexFile) || !is_file($contentDir . $requestFile . $contentExt)) {
|
||||||
return $indexFile;
|
return $indexFile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1247,11 +1247,11 @@ class Pico
|
|||||||
$errorFileDir = dirname($errorFileDir);
|
$errorFileDir = dirname($errorFileDir);
|
||||||
$errorFile = $errorFileDir . '/404' . $contentExt;
|
$errorFile = $errorFileDir . '/404' . $contentExt;
|
||||||
|
|
||||||
if (file_exists($contentDir . $errorFile)) {
|
if (is_file($contentDir . $errorFile)) {
|
||||||
return $this->loadFileContent($contentDir . $errorFile);
|
return $this->loadFileContent($contentDir . $errorFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif (file_exists($contentDir . '404' . $contentExt)) {
|
} elseif (is_file($contentDir . '404' . $contentExt)) {
|
||||||
// provided that the requested file is not in the regular
|
// provided that the requested file is not in the regular
|
||||||
// content directory, fallback to Pico's global `404.md`
|
// content directory, fallback to Pico's global `404.md`
|
||||||
return $this->loadFileContent($contentDir . '404' . $contentExt);
|
return $this->loadFileContent($contentDir . '404' . $contentExt);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user