FIX Ensure phpdbg calls are registered by SilverStripe core as a CLI call

This commit is contained in:
Robbie Averill 2017-07-17 16:56:01 +12:00
parent 7fd316d405
commit ea4181166f
2 changed files with 9 additions and 1 deletions

View File

@ -944,7 +944,7 @@ class Director implements TemplateGlobalProvider
*/
public static function is_cli()
{
return php_sapi_name() === "cli";
return in_array(php_sapi_name(), ['cli', 'phpdbg']);
}
/**

View File

@ -761,4 +761,12 @@ class DirectorTest extends SapphireTest
$this->assertEquals(2, $middleware->preCalls);
$this->assertEquals(1, $specificMiddleware->postCalls);
}
/**
* If using phpdbg it returns itself instead of "cli" from php_sapi_name()
*/
public function testIsCli()
{
$this->assertTrue(Director::is_cli(), 'is_cli should be true for PHP CLI and phpdbg');
}
}