diff --git a/src/applications/auth/provider/PhabricatorOAuth1AuthProvider.php b/src/applications/auth/provider/PhabricatorOAuth1AuthProvider.php --- a/src/applications/auth/provider/PhabricatorOAuth1AuthProvider.php +++ b/src/applications/auth/provider/PhabricatorOAuth1AuthProvider.php @@ -21,7 +21,7 @@ $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 --- a/src/applications/cache/management/PhabricatorCacheManagementPurgeWorkflow.php +++ b/src/applications/cache/management/PhabricatorCacheManagementPurgeWorkflow.php @@ -27,11 +27,11 @@ $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 --- a/src/applications/daemon/event/PhabricatorDaemonEventListener.php +++ b/src/applications/daemon/event/PhabricatorDaemonEventListener.php @@ -63,9 +63,12 @@ // 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 --- a/src/applications/drydock/management/DrydockManagementLeaseWorkflow.php +++ b/src/applications/drydock/management/DrydockManagementLeaseWorkflow.php @@ -41,7 +41,7 @@ } $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 @@ } $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 --- a/src/applications/policy/query/PhabricatorPolicyQuery.php +++ b/src/applications/policy/query/PhabricatorPolicyQuery.php @@ -290,6 +290,10 @@ } 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 --- a/src/applications/repository/storage/PhabricatorRepository.php +++ b/src/applications/repository/storage/PhabricatorRepository.php @@ -193,7 +193,7 @@ 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 --- a/src/applications/transactions/storage/PhabricatorApplicationTransaction.php +++ b/src/applications/transactions/storage/PhabricatorApplicationTransaction.php @@ -605,7 +605,7 @@ } 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 --- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php +++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php @@ -256,6 +256,10 @@ } 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 --- a/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php +++ b/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php @@ -369,7 +369,7 @@ $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());