diff --git a/src/applications/config/check/PhabricatorPHPPreflightSetupCheck.php b/src/applications/config/check/PhabricatorPHPPreflightSetupCheck.php index 09b00bc991..c780f8b959 100644 --- a/src/applications/config/check/PhabricatorPHPPreflightSetupCheck.php +++ b/src/applications/config/check/PhabricatorPHPPreflightSetupCheck.php @@ -84,7 +84,7 @@ final class PhabricatorPHPPreflightSetupCheck extends PhabricatorSetupCheck { } $open_basedir = ini_get('open_basedir'); - if (strlen($open_basedir)) { + if ($open_basedir && strlen($open_basedir)) { // If `open_basedir` is set, just fatal. It's technically possible for // us to run with certain values of `open_basedir`, but: we can only // raise fatal errors from preflight steps, so we'd have to do this check diff --git a/src/applications/config/view/PhabricatorSetupIssueView.php b/src/applications/config/view/PhabricatorSetupIssueView.php index 92c97af5d0..06a1e13c87 100644 --- a/src/applications/config/view/PhabricatorSetupIssueView.php +++ b/src/applications/config/view/PhabricatorSetupIssueView.php @@ -372,14 +372,14 @@ final class PhabricatorSetupIssueView extends AphrontView { $matches = null; $ini_loc = null; - if (preg_match($rex, $phpinfo, $matches)) { + if ($phpinfo && preg_match($rex, $phpinfo, $matches)) { $ini_loc = trim($matches[1]); } $rex = '@Additional \.ini files parsed\s*(.*?)@i'; $more_loc = array(); - if (preg_match($rex, $phpinfo, $matches)) { + if ($phpinfo && preg_match($rex, $phpinfo, $matches)) { $more_loc = trim($matches[1]); if ($more_loc == '(none)') { $more_loc = array(); diff --git a/src/applications/differential/storage/DifferentialHunk.php b/src/applications/differential/storage/DifferentialHunk.php index 891fac745a..24730d3abd 100644 --- a/src/applications/differential/storage/DifferentialHunk.php +++ b/src/applications/differential/storage/DifferentialHunk.php @@ -225,7 +225,7 @@ final class DifferentialHunk } if ($line[0] == '\\') { - if ($use_next_newline) { + if ($use_next_newline && $results) { $results[last_key($results)] = rtrim(end($results), "\n"); } } else if (empty($include_map[$line[0]])) { diff --git a/src/applications/diffusion/engine/DiffusionCommitHookEngine.php b/src/applications/diffusion/engine/DiffusionCommitHookEngine.php index 9f4b1cab2d..d1ead81a4a 100644 --- a/src/applications/diffusion/engine/DiffusionCommitHookEngine.php +++ b/src/applications/diffusion/engine/DiffusionCommitHookEngine.php @@ -982,12 +982,12 @@ final class DiffusionCommitHookEngine extends Phobject { $key_name = getenv('HG_KEY'); $key_old = getenv('HG_OLD'); - if (!strlen($key_old)) { + if (!$key_old || !strlen($key_old)) { $key_old = null; } $key_new = getenv('HG_NEW'); - if (!strlen($key_new)) { + if (!$key_new || !strlen($key_new)) { $key_new = null; } diff --git a/src/applications/diviner/workflow/DivinerGenerateWorkflow.php b/src/applications/diviner/workflow/DivinerGenerateWorkflow.php index 69d6a78c2d..57cfe40642 100644 --- a/src/applications/diviner/workflow/DivinerGenerateWorkflow.php +++ b/src/applications/diviner/workflow/DivinerGenerateWorkflow.php @@ -55,11 +55,14 @@ final class DivinerGenerateWorkflow extends DivinerWorkflow { } else { $cwd = getcwd(); $this->log(pht('FINDING DOCUMENTATION BOOKS')); + $books = array(); - $books = id(new FileFinder($cwd)) - ->withType('f') - ->withSuffix('book') - ->find(); + if ($cwd) { + $books = id(new FileFinder($cwd)) + ->withType('f') + ->withSuffix('book') + ->find(); + } if (!$books) { throw new PhutilArgumentUsageException( diff --git a/src/applications/drydock/management/DrydockManagementLeaseWorkflow.php b/src/applications/drydock/management/DrydockManagementLeaseWorkflow.php index 2694d2cc64..eac3d1fab6 100644 --- a/src/applications/drydock/management/DrydockManagementLeaseWorkflow.php +++ b/src/applications/drydock/management/DrydockManagementLeaseWorkflow.php @@ -69,6 +69,7 @@ final class DrydockManagementLeaseWorkflow 'number.')); } + $attributes = array(); $attributes_file = $args->getArg('attributes'); if (phutil_nonempty_string($attributes_file)) { if ($attributes_file == '-') { @@ -80,9 +81,9 @@ final class DrydockManagementLeaseWorkflow $data = Filesystem::readFile($attributes_file); } - $attributes = phutil_json_decode($data); - } else { - $attributes = array(); + if ($data) { + $attributes = phutil_json_decode($data); + } } $filter_identifiers = $args->getArg('blueprint'); diff --git a/src/applications/harbormaster/management/HarbormasterManagementWriteLogWorkflow.php b/src/applications/harbormaster/management/HarbormasterManagementWriteLogWorkflow.php index 3676b1415c..b31d33602f 100644 --- a/src/applications/harbormaster/management/HarbormasterManagementWriteLogWorkflow.php +++ b/src/applications/harbormaster/management/HarbormasterManagementWriteLogWorkflow.php @@ -75,8 +75,12 @@ final class HarbormasterManagementWriteLogWorkflow pht('Writing log, slowly...')); $offset = 0; - $total = strlen($content); - $pieces = str_split($content, $rate); + $total = 0; + $pieces = array(); + if ($content) { + $total = strlen($content); + $pieces = str_split($content, $rate); + } $bar = id(new PhutilConsoleProgressBar()) ->setTotal($total); diff --git a/src/applications/repository/storage/PhabricatorRepository.php b/src/applications/repository/storage/PhabricatorRepository.php index 25b2364b3d..f4a6eaf949 100644 --- a/src/applications/repository/storage/PhabricatorRepository.php +++ b/src/applications/repository/storage/PhabricatorRepository.php @@ -2260,14 +2260,14 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO ); foreach ($git_env as $key) { $value = getenv($key); - if (strlen($value)) { + if ($value && strlen($value)) { $env[$key] = $value; } } $key = 'GIT_PUSH_OPTION_COUNT'; $git_count = getenv($key); - if (strlen($git_count)) { + if ($git_count && strlen($git_count)) { $git_count = (int)$git_count; $env[$key] = $git_count; for ($ii = 0; $ii < $git_count; $ii++) { diff --git a/src/infrastructure/log/PhabricatorSSHLog.php b/src/infrastructure/log/PhabricatorSSHLog.php index e3c15de6bf..8835e1b66b 100644 --- a/src/infrastructure/log/PhabricatorSSHLog.php +++ b/src/infrastructure/log/PhabricatorSSHLog.php @@ -35,7 +35,7 @@ final class PhabricatorSSHLog extends Phobject { } $client = getenv('SSH_CLIENT'); - if (strlen($client)) { + if ($client && strlen($client)) { $remote_address = head(explode(' ', $client)); $data['r'] = $remote_address; } diff --git a/src/infrastructure/ssh/PhabricatorSSHWorkflow.php b/src/infrastructure/ssh/PhabricatorSSHWorkflow.php index f7739f1332..8b2c93de8c 100644 --- a/src/infrastructure/ssh/PhabricatorSSHWorkflow.php +++ b/src/infrastructure/ssh/PhabricatorSSHWorkflow.php @@ -101,7 +101,7 @@ abstract class PhabricatorSSHWorkflow public function getSSHRemoteAddress() { $ssh_client = getenv('SSH_CLIENT'); - if (!strlen($ssh_client)) { + if (!$ssh_client || !strlen($ssh_client)) { return null; }