1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-25 14:08:19 +01:00

Fix various "strlen(null)" PHP 8.1 issues on "bin/phd" and "bin/drydock" pathways

Summary: Ref T13676. Ref T13588. Fix some issues that prevent "bin/phd" and "bin/drydock" from executing under PHP 8.1, broadly because `null` is being passed to `strlen()`.

Test Plan: Ran `bin/phd debug task` and `bin/drydock ...` under PHP 8.1.

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13676, T13588

Differential Revision: https://secure.phabricator.com/D21795
This commit is contained in:
epriestley 2022-05-03 11:09:19 -07:00
parent c415622923
commit 00a20d3cdc
9 changed files with 21 additions and 10 deletions

View file

@ -21,7 +21,7 @@ abstract class PhabricatorOAuth1AuthProvider
$config = $this->getProviderConfig(); $config = $this->getProviderConfig();
$adapter->setConsumerKey($config->getProperty(self::PROPERTY_CONSUMER_KEY)); $adapter->setConsumerKey($config->getProperty(self::PROPERTY_CONSUMER_KEY));
$secret = $config->getProperty(self::PROPERTY_CONSUMER_SECRET); $secret = $config->getProperty(self::PROPERTY_CONSUMER_SECRET);
if (strlen($secret)) { if (phutil_nonempty_string($secret)) {
$adapter->setConsumerSecret(new PhutilOpaqueEnvelope($secret)); $adapter->setConsumerSecret(new PhutilOpaqueEnvelope($secret));
} }
$adapter->setCallbackURI(PhabricatorEnv::getURI($this->getLoginURI())); $adapter->setCallbackURI(PhabricatorEnv::getURI($this->getLoginURI()));

View file

@ -27,11 +27,11 @@ final class PhabricatorCacheManagementPurgeWorkflow
$is_all = $args->getArg('all'); $is_all = $args->getArg('all');
$key_list = $args->getArg('caches'); $key_list = $args->getArg('caches');
if ($is_all && strlen($key_list)) { if ($is_all && phutil_nonempty_string($key_list)) {
throw new PhutilArgumentUsageException( throw new PhutilArgumentUsageException(
pht( pht(
'Specify either "--all" or "--caches", not both.')); '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( throw new PhutilArgumentUsageException(
pht( pht(
'Select caches to purge with "--all" or "--caches". Available '. 'Select caches to purge with "--all" or "--caches". Available '.

View file

@ -63,9 +63,12 @@ final class PhabricatorDaemonEventListener extends PhabricatorEventListener {
// TODO: This is a bit awkward for historical reasons, clean it up after // TODO: This is a bit awkward for historical reasons, clean it up after
// removing Conduit. // removing Conduit.
$message = $event->getValue('message'); $message = $event->getValue('message');
$context = $event->getValue('context'); $context = $event->getValue('context');
if (strlen($context) && $context !== $message) { if (phutil_nonempty_scalar($context)) {
$message = "({$context}) {$message}"; if ($context !== $message) {
$message = "({$context}) {$message}";
}
} }
$type = $event->getValue('type'); $type = $event->getValue('type');

View file

@ -41,7 +41,7 @@ final class DrydockManagementLeaseWorkflow
} }
$until = $args->getArg('until'); $until = $args->getArg('until');
if (strlen($until)) { if (phutil_nonempty_string($until)) {
$until = strtotime($until); $until = strtotime($until);
if ($until <= 0) { if ($until <= 0) {
throw new PhutilArgumentUsageException( throw new PhutilArgumentUsageException(
@ -52,7 +52,7 @@ final class DrydockManagementLeaseWorkflow
} }
$attributes_file = $args->getArg('attributes'); $attributes_file = $args->getArg('attributes');
if (strlen($attributes_file)) { if (phutil_nonempty_string($attributes_file)) {
if ($attributes_file == '-') { if ($attributes_file == '-') {
echo tsprintf( echo tsprintf(
"%s\n", "%s\n",

View file

@ -290,6 +290,10 @@ final class PhabricatorPolicyQuery
} }
public static function isSpecialPolicy($identifier) { public static function isSpecialPolicy($identifier) {
if ($identifier === null) {
return true;
}
if (self::isObjectPolicy($identifier)) { if (self::isObjectPolicy($identifier)) {
return true; return true;
} }

View file

@ -193,7 +193,7 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
public function getMonogram() { public function getMonogram() {
$callsign = $this->getCallsign(); $callsign = $this->getCallsign();
if (strlen($callsign)) { if (phutil_nonempty_string($callsign)) {
return "r{$callsign}"; return "r{$callsign}";
} }

View file

@ -605,7 +605,7 @@ abstract class PhabricatorApplicationTransaction
} }
if (!is_array($old)) { if (!is_array($old)) {
if (!strlen($old)) { if ($old === '' || $old === null) {
return true; return true;
} }

View file

@ -256,6 +256,10 @@ abstract class PhabricatorStandardCustomFieldPHIDs
} }
protected function decodeValue($value) { protected function decodeValue($value) {
if ($value === null) {
return array();
}
$value = json_decode($value); $value = json_decode($value);
if (!is_array($value)) { if (!is_array($value)) {
$value = array(); $value = array();

View file

@ -369,7 +369,7 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
$this->setLimit($limit + 1); $this->setLimit($limit + 1);
if (strlen($pager->getAfterID())) { if (phutil_nonempty_string($pager->getAfterID())) {
$this->setExternalCursorString($pager->getAfterID()); $this->setExternalCursorString($pager->getAfterID());
} else if ($pager->getBeforeID()) { } else if ($pager->getBeforeID()) {
$this->setExternalCursorString($pager->getBeforeID()); $this->setExternalCursorString($pager->getBeforeID());