@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator

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

+21 -10
+1 -1
src/applications/auth/provider/PhabricatorOAuth1AuthProvider.php
··· 21 21 $config = $this->getProviderConfig(); 22 22 $adapter->setConsumerKey($config->getProperty(self::PROPERTY_CONSUMER_KEY)); 23 23 $secret = $config->getProperty(self::PROPERTY_CONSUMER_SECRET); 24 - if (strlen($secret)) { 24 + if (phutil_nonempty_string($secret)) { 25 25 $adapter->setConsumerSecret(new PhutilOpaqueEnvelope($secret)); 26 26 } 27 27 $adapter->setCallbackURI(PhabricatorEnv::getURI($this->getLoginURI()));
+2 -2
src/applications/cache/management/PhabricatorCacheManagementPurgeWorkflow.php
··· 27 27 $is_all = $args->getArg('all'); 28 28 $key_list = $args->getArg('caches'); 29 29 30 - if ($is_all && strlen($key_list)) { 30 + if ($is_all && phutil_nonempty_string($key_list)) { 31 31 throw new PhutilArgumentUsageException( 32 32 pht( 33 33 'Specify either "--all" or "--caches", not both.')); 34 - } else if (!$is_all && !strlen($key_list)) { 34 + } else if (!$is_all && !phutil_nonempty_string($key_list)) { 35 35 throw new PhutilArgumentUsageException( 36 36 pht( 37 37 'Select caches to purge with "--all" or "--caches". Available '.
+5 -2
src/applications/daemon/event/PhabricatorDaemonEventListener.php
··· 63 63 // TODO: This is a bit awkward for historical reasons, clean it up after 64 64 // removing Conduit. 65 65 $message = $event->getValue('message'); 66 + 66 67 $context = $event->getValue('context'); 67 - if (strlen($context) && $context !== $message) { 68 - $message = "({$context}) {$message}"; 68 + if (phutil_nonempty_scalar($context)) { 69 + if ($context !== $message) { 70 + $message = "({$context}) {$message}"; 71 + } 69 72 } 70 73 71 74 $type = $event->getValue('type');
+2 -2
src/applications/drydock/management/DrydockManagementLeaseWorkflow.php
··· 41 41 } 42 42 43 43 $until = $args->getArg('until'); 44 - if (strlen($until)) { 44 + if (phutil_nonempty_string($until)) { 45 45 $until = strtotime($until); 46 46 if ($until <= 0) { 47 47 throw new PhutilArgumentUsageException( ··· 52 52 } 53 53 54 54 $attributes_file = $args->getArg('attributes'); 55 - if (strlen($attributes_file)) { 55 + if (phutil_nonempty_string($attributes_file)) { 56 56 if ($attributes_file == '-') { 57 57 echo tsprintf( 58 58 "%s\n",
+4
src/applications/policy/query/PhabricatorPolicyQuery.php
··· 290 290 } 291 291 292 292 public static function isSpecialPolicy($identifier) { 293 + if ($identifier === null) { 294 + return true; 295 + } 296 + 293 297 if (self::isObjectPolicy($identifier)) { 294 298 return true; 295 299 }
+1 -1
src/applications/repository/storage/PhabricatorRepository.php
··· 193 193 194 194 public function getMonogram() { 195 195 $callsign = $this->getCallsign(); 196 - if (strlen($callsign)) { 196 + if (phutil_nonempty_string($callsign)) { 197 197 return "r{$callsign}"; 198 198 } 199 199
+1 -1
src/applications/transactions/storage/PhabricatorApplicationTransaction.php
··· 605 605 } 606 606 607 607 if (!is_array($old)) { 608 - if (!strlen($old)) { 608 + if ($old === '' || $old === null) { 609 609 return true; 610 610 } 611 611
+4
src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php
··· 256 256 } 257 257 258 258 protected function decodeValue($value) { 259 + if ($value === null) { 260 + return array(); 261 + } 262 + 259 263 $value = json_decode($value); 260 264 if (!is_array($value)) { 261 265 $value = array();
+1 -1
src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php
··· 369 369 370 370 $this->setLimit($limit + 1); 371 371 372 - if (strlen($pager->getAfterID())) { 372 + if (phutil_nonempty_string($pager->getAfterID())) { 373 373 $this->setExternalCursorString($pager->getAfterID()); 374 374 } else if ($pager->getBeforeID()) { 375 375 $this->setExternalCursorString($pager->getBeforeID());