Merge pull request #7179 from robbieaverill/pulls/4.0/is-cli-for-phpdbg

FIX Ensure phpdbg calls are registered by SilverStripe core as a CLI call
This commit is contained in:
Daniel Hensby 2017-07-17 14:26:39 +01:00 committed by GitHub
commit be7b2d4970
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');
}
}