MDL-68714 clilib: Check set_process_title exists

The web cron script at /admin/cron.php pretends to be a CLI script which
means that it is not possible to rely upon the CLI_SCRIPT constant.
This commit is contained in:
Andrew Nicols 2020-07-03 09:49:08 +08:00
parent 834aba2309
commit 9eaf7a4c3f

View File

@ -154,7 +154,7 @@ function cli_get_params(array $longoptions, array $shortmapping=null) {
* @param string $suffix process suffix
*/
function cli_set_process_title_suffix(string $suffix) {
if (CLI_SCRIPT && isset($_SERVER['argv'])) {
if (CLI_SCRIPT && function_exists('cli_set_process_title') && isset($_SERVER['argv'])) {
$command = join(' ', $_SERVER['argv']);
@cli_set_process_title("php $command ($suffix)");
}