diff --git a/src/applications/auth/provider/PhabricatorOAuth1AuthProvider.php b/src/applications/auth/provider/PhabricatorOAuth1AuthProvider.php index ef1991e8d7..b1590b9c82 100644 --- a/src/applications/auth/provider/PhabricatorOAuth1AuthProvider.php +++ b/src/applications/auth/provider/PhabricatorOAuth1AuthProvider.php @@ -21,7 +21,7 @@ abstract class PhabricatorOAuth1AuthProvider $config = $this->getProviderConfig(); $adapter->setConsumerKey($config->getProperty(self::PROPERTY_CONSUMER_KEY)); $secret = $config->getProperty(self::PROPERTY_CONSUMER_SECRET); - if (strlen($secret)) { + if (phutil_nonempty_string($secret)) { $adapter->setConsumerSecret(new PhutilOpaqueEnvelope($secret)); } $adapter->setCallbackURI(PhabricatorEnv::getURI($this->getLoginURI())); diff --git a/src/applications/cache/management/PhabricatorCacheManagementPurgeWorkflow.php b/src/applications/cache/management/PhabricatorCacheManagementPurgeWorkflow.php index cfe42c918b..37de525a02 100644 --- a/src/applications/cache/management/PhabricatorCacheManagementPurgeWorkflow.php +++ b/src/applications/cache/management/PhabricatorCacheManagementPurgeWorkflow.php @@ -27,11 +27,11 @@ final class PhabricatorCacheManagementPurgeWorkflow $is_all = $args->getArg('all'); $key_list = $args->getArg('caches'); - if ($is_all && strlen($key_list)) { + if ($is_all && phutil_nonempty_string($key_list)) { throw new PhutilArgumentUsageException( pht( 'Specify either "--all" or "--caches", not both.')); - } else if (!$is_all && !strlen($key_list)) { + } else if (!$is_all && !phutil_nonempty_string($key_list)) { throw new PhutilArgumentUsageException( pht( 'Select caches to purge with "--all" or "--caches". Available '. diff --git a/src/applications/daemon/event/PhabricatorDaemonEventListener.php b/src/applications/daemon/event/PhabricatorDaemonEventListener.php index 41324cc9c9..a17bab77af 100644 --- a/src/applications/daemon/event/PhabricatorDaemonEventListener.php +++ b/src/applications/daemon/event/PhabricatorDaemonEventListener.php @@ -63,9 +63,12 @@ final class PhabricatorDaemonEventListener extends PhabricatorEventListener { // TODO: This is a bit awkward for historical reasons, clean it up after // removing Conduit. $message = $event->getValue('message'); + $context = $event->getValue('context'); - if (strlen($context) && $context !== $message) { - $message = "({$context}) {$message}"; + if (phutil_nonempty_scalar($context)) { + if ($context !== $message) { + $message = "({$context}) {$message}"; + } } $type = $event->getValue('type'); diff --git a/src/applications/drydock/management/DrydockManagementLeaseWorkflow.php b/src/applications/drydock/management/DrydockManagementLeaseWorkflow.php index 08f33c6b5f..7890b27d28 100644 --- a/src/applications/drydock/management/DrydockManagementLeaseWorkflow.php +++ b/src/applications/drydock/management/DrydockManagementLeaseWorkflow.php @@ -41,7 +41,7 @@ final class DrydockManagementLeaseWorkflow } $until = $args->getArg('until'); - if (strlen($until)) { + if (phutil_nonempty_string($until)) { $until = strtotime($until); if ($until <= 0) { throw new PhutilArgumentUsageException( @@ -52,7 +52,7 @@ final class DrydockManagementLeaseWorkflow } $attributes_file = $args->getArg('attributes'); - if (strlen($attributes_file)) { + if (phutil_nonempty_string($attributes_file)) { if ($attributes_file == '-') { echo tsprintf( "%s\n", diff --git a/src/applications/policy/query/PhabricatorPolicyQuery.php b/src/applications/policy/query/PhabricatorPolicyQuery.php index 018007db28..9bd6ba5994 100644 --- a/src/applications/policy/query/PhabricatorPolicyQuery.php +++ b/src/applications/policy/query/PhabricatorPolicyQuery.php @@ -290,6 +290,10 @@ final class PhabricatorPolicyQuery } public static function isSpecialPolicy($identifier) { + if ($identifier === null) { + return true; + } + if (self::isObjectPolicy($identifier)) { return true; } diff --git a/src/applications/repository/storage/PhabricatorRepository.php b/src/applications/repository/storage/PhabricatorRepository.php index 3e0c4a45e7..0ac6687ef8 100644 --- a/src/applications/repository/storage/PhabricatorRepository.php +++ b/src/applications/repository/storage/PhabricatorRepository.php @@ -193,7 +193,7 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO public function getMonogram() { $callsign = $this->getCallsign(); - if (strlen($callsign)) { + if (phutil_nonempty_string($callsign)) { return "r{$callsign}"; } diff --git a/src/applications/transactions/storage/PhabricatorApplicationTransaction.php b/src/applications/transactions/storage/PhabricatorApplicationTransaction.php index 8abb5178d5..a470ef0c9b 100644 --- a/src/applications/transactions/storage/PhabricatorApplicationTransaction.php +++ b/src/applications/transactions/storage/PhabricatorApplicationTransaction.php @@ -605,7 +605,7 @@ abstract class PhabricatorApplicationTransaction } if (!is_array($old)) { - if (!strlen($old)) { + if ($old === '' || $old === null) { return true; } diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php index 78c8caa5a9..a96ebefda1 100644 --- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php +++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php @@ -256,6 +256,10 @@ abstract class PhabricatorStandardCustomFieldPHIDs } protected function decodeValue($value) { + if ($value === null) { + return array(); + } + $value = json_decode($value); if (!is_array($value)) { $value = array(); diff --git a/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php b/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php index 34a8e1813c..1cf2b4b9ea 100644 --- a/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php +++ b/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php @@ -369,7 +369,7 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery $this->setLimit($limit + 1); - if (strlen($pager->getAfterID())) { + if (phutil_nonempty_string($pager->getAfterID())) { $this->setExternalCursorString($pager->getAfterID()); } else if ($pager->getBeforeID()) { $this->setExternalCursorString($pager->getBeforeID());