diff --git a/scripts/ssh/ssh-auth.php b/scripts/ssh/ssh-auth.php --- a/scripts/ssh/ssh-auth.php +++ b/scripts/ssh/ssh-auth.php @@ -36,7 +36,7 @@ $authstruct = null; -if (strlen($authstruct_raw)) { +if ($authstruct_raw !== null && strlen($authstruct_raw)) { try { $authstruct = phutil_json_decode($authstruct_raw); } catch (Exception $ex) { @@ -135,7 +135,7 @@ $cmd = csprintf('%s %Ls', $bin, $key_argv); - if (strlen($instance)) { + if ($instance !== null && strlen($instance)) { $cmd = csprintf('PHABRICATOR_INSTANCE=%s %C', $instance, $cmd); } diff --git a/src/applications/almanac/util/AlmanacKeys.php b/src/applications/almanac/util/AlmanacKeys.php --- a/src/applications/almanac/util/AlmanacKeys.php +++ b/src/applications/almanac/util/AlmanacKeys.php @@ -58,7 +58,7 @@ public static function getClusterSSHUser() { $username = PhabricatorEnv::getEnvConfig('diffusion.ssh-user'); - if (strlen($username)) { + if ($username !== null && strlen($username)) { return $username; } diff --git a/src/applications/diffusion/controller/DiffusionRepositoryManagePanelsController.php b/src/applications/diffusion/controller/DiffusionRepositoryManagePanelsController.php --- a/src/applications/diffusion/controller/DiffusionRepositoryManagePanelsController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryManagePanelsController.php @@ -40,7 +40,7 @@ } $selected = $request->getURIData('panel'); - if (!strlen($selected)) { + if ($selected === null || !strlen($selected)) { $selected = head_key($panels); } diff --git a/src/applications/repository/editor/PhabricatorRepositoryEditor.php b/src/applications/repository/editor/PhabricatorRepositoryEditor.php --- a/src/applications/repository/editor/PhabricatorRepositoryEditor.php +++ b/src/applications/repository/editor/PhabricatorRepositoryEditor.php @@ -50,7 +50,7 @@ // If the repository does not have a local path yet, assign it one based // on its ID. We can't do this earlier because we won't have an ID yet. $local_path = $object->getLocalPath(); - if (!strlen($local_path)) { + if ($local_path === null || !strlen($local_path)) { $local_key = 'repository.default-local-path'; $local_root = PhabricatorEnv::getEnvConfig($local_key); diff --git a/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php b/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php --- a/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php +++ b/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php @@ -238,7 +238,7 @@ $identifier = $repository->getPHID(); $instance = PhabricatorEnv::getEnvConfig('cluster.instance'); - if (strlen($instance)) { + if ($instance !== null && strlen($instance)) { $identifier = "{$identifier}:{$instance}"; } @@ -575,7 +575,7 @@ $ref_rules); // Empty repositories don't have any refs. - if (!strlen(rtrim($stdout))) { + if ($stdout === null || !strlen(rtrim($stdout))) { return array(); } diff --git a/src/applications/repository/query/PhabricatorRepositoryRefCursorQuery.php b/src/applications/repository/query/PhabricatorRepositoryRefCursorQuery.php --- a/src/applications/repository/query/PhabricatorRepositoryRefCursorQuery.php +++ b/src/applications/repository/query/PhabricatorRepositoryRefCursorQuery.php @@ -132,7 +132,7 @@ $name_hashes); } - if (strlen($this->datasourceQuery)) { + if ($this->datasourceQuery !== null && strlen($this->datasourceQuery)) { $where[] = qsprintf( $conn, 'refNameRaw LIKE %>', diff --git a/src/applications/repository/storage/PhabricatorRepository.php b/src/applications/repository/storage/PhabricatorRepository.php --- a/src/applications/repository/storage/PhabricatorRepository.php +++ b/src/applications/repository/storage/PhabricatorRepository.php @@ -345,7 +345,7 @@ // Make some reasonable effort to produce reasonable default directory // names from repository names. - if (!strlen($name)) { + if ($name === null || !strlen($name)) { $name = $this->getName(); $name = phutil_utf8_strtolower($name); $name = preg_replace('@[ -/:->]+@', '-', $name); @@ -721,14 +721,14 @@ $head = idx($params, 'head'); $against = idx($params, 'against'); - if ($req_commit && !strlen($commit)) { + if ($req_commit && ($commit === null || !strlen($commit))) { throw new Exception( pht( 'Diffusion URI action "%s" requires commit!', $action)); } - if ($req_branch && !strlen($branch)) { + if ($req_branch && ($branch === null || !strlen($branch))) { throw new Exception( pht( 'Diffusion URI action "%s" requires branch!', @@ -779,20 +779,20 @@ break; case 'compare': $uri = $this->getPathURI("/{$action}/"); - if (strlen($head)) { + if ($head !== null && strlen($head)) { $query['head'] = $head; - } else if (strlen($raw_commit)) { + } else if ($raw_commit !== null && strlen($raw_commit)) { $query['commit'] = $raw_commit; - } else if (strlen($raw_branch)) { + } else if ($raw_branch !== null && strlen($raw_branch)) { $query['head'] = $raw_branch; } - if (strlen($against)) { + if ($against !== null && strlen($against)) { $query['against'] = $against; } break; case 'branch': - if (strlen($path)) { + if ($path != null && strlen($path)) { $uri = $this->getPathURI("/repository/{$path}"); } else { $uri = $this->getPathURI('/'); @@ -1160,7 +1160,7 @@ */ public function getRemoteURIObject() { $raw_uri = $this->getDetail('remote-uri'); - if (!strlen($raw_uri)) { + if ($raw_uri === null || !strlen($raw_uri)) { return new PhutilURI(''); } @@ -2818,7 +2818,7 @@ $permanent_rules = $this->getStringListForConduit($permanent_rules); $default_branch = $this->getDefaultBranch(); - if (!strlen($default_branch)) { + if ($default_branch === null || !strlen($default_branch)) { $default_branch = null; } diff --git a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php --- a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php +++ b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php @@ -2363,7 +2363,9 @@ // Here, we don't care about processing only new mentions after an edit // because there is no way for an object to ever "unmention" itself on // another object, so we can ignore the old value. - $engine->markupText($change->getNewValue()); + if ($change->getNewValue() !== null) { + $engine->markupText($change->getNewValue()); + } $mentioned_phids += $engine->getTextMetadata( PhabricatorObjectRemarkupRule::KEY_MENTIONED_OBJECTS, diff --git a/src/infrastructure/contentsource/PhabricatorUnknownContentSource.php b/src/infrastructure/contentsource/PhabricatorUnknownContentSource.php --- a/src/infrastructure/contentsource/PhabricatorUnknownContentSource.php +++ b/src/infrastructure/contentsource/PhabricatorUnknownContentSource.php @@ -7,7 +7,7 @@ public function getSourceName() { $source = $this->getSource(); - if (strlen($source)) { + if ($source !== null && strlen($source)) { return pht('Unknown ("%s")', $source); } else { return pht('Unknown'); diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldRemarkup.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldRemarkup.php --- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldRemarkup.php +++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldRemarkup.php @@ -30,7 +30,7 @@ public function renderPropertyViewValue(array $handles) { $value = $this->getFieldValue(); - if (!strlen($value)) { + if ($value === null || !strlen($value)) { return null; }