mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 07:44:04 +02:00
Fix ApplicationBootstrap::getBootstrapDirectory() when Icinga Web 2 is served using PHP's built-in web server
This commit is contained in:
parent
925348d171
commit
2c0122ba9f
@ -6,6 +6,7 @@ namespace Icinga\Application;
|
|||||||
|
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use LogicException;
|
||||||
use Icinga\Application\Modules\Manager as ModuleManager;
|
use Icinga\Application\Modules\Manager as ModuleManager;
|
||||||
use Icinga\Data\ResourceFactory;
|
use Icinga\Data\ResourceFactory;
|
||||||
use Icinga\Exception\ConfigurationError;
|
use Icinga\Exception\ConfigurationError;
|
||||||
@ -292,11 +293,25 @@ abstract class ApplicationBootstrap
|
|||||||
*
|
*
|
||||||
* This is usually /public for Web and EmbeddedWeb and /bin for the CLI
|
* This is usually /public for Web and EmbeddedWeb and /bin for the CLI
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
|
*
|
||||||
|
* @throws LogicException If the base directory can not be detected
|
||||||
*/
|
*/
|
||||||
public function getBootstrapDirectory()
|
public function getBootstrapDirectory()
|
||||||
{
|
{
|
||||||
return dirname(realpath($_SERVER['SCRIPT_FILENAME']));
|
$script = $_SERVER['SCRIPT_FILENAME'];
|
||||||
|
$canonical = realpath($script);
|
||||||
|
if ($canonical !== false) {
|
||||||
|
$dir = dirname($canonical);
|
||||||
|
} elseif (substr($script, -14) === '/webrouter.php') {
|
||||||
|
// If Icinga Web 2 is served using PHP's built-in webserver with our webrouter.php script, the $_SERVER
|
||||||
|
// variable SCRIPT_FILENAME is set to DOCUMENT_ROOT/webrouter.php which is not a valid path to
|
||||||
|
// realpath but DOCUMENT_ROOT here still is the bootstrapping directory
|
||||||
|
$dir = dirname($script);
|
||||||
|
} else {
|
||||||
|
throw new LogicException('Can\'t detected base directory');
|
||||||
|
}
|
||||||
|
return $dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user