mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-10 14:51:06 +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:
parent
c415622923
commit
00a20d3cdc
9 changed files with 21 additions and 10 deletions
|
@ -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()));
|
||||
|
|
|
@ -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 '.
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -290,6 +290,10 @@ final class PhabricatorPolicyQuery
|
|||
}
|
||||
|
||||
public static function isSpecialPolicy($identifier) {
|
||||
if ($identifier === null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (self::isObjectPolicy($identifier)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -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}";
|
||||
}
|
||||
|
||||
|
|
|
@ -605,7 +605,7 @@ abstract class PhabricatorApplicationTransaction
|
|||
}
|
||||
|
||||
if (!is_array($old)) {
|
||||
if (!strlen($old)) {
|
||||
if ($old === '' || $old === null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Reference in a new issue