Skip to content

Commit cf40069

Browse files
committed
Addressing some PHP8 incompatibilities - Misc. Applications
Summary: Browsing through all other non-prototype applications and using them a bit to track down PHP8 incompatibilities. Test Plan: I tried basic usage of the following applications which found & fixed: - Almanac, creating resources, networks, services, etc. - Drydock, creating blue prints - Pholio mocks - Setting up TOTP MFA - Phame blog and post - Creating default Space - Creating and signing a legalpad document - Creating a conpherence room Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Differential Revision: https://secure.phabricator.com/D21868
1 parent 0b6e758 commit cf40069

File tree

15 files changed

+31
-24
lines changed

15 files changed

+31
-24
lines changed

src/applications/almanac/controller/AlmanacPropertyEditController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function handleRequest(AphrontRequest $request) {
1616
$cancel_uri = $object->getURI();
1717
$property_key = $request->getStr('key');
1818

19-
if (!strlen($property_key)) {
19+
if (!phutil_nonempty_string($property_key)) {
2020
return $this->buildPropertyKeyResponse($cancel_uri, null);
2121
} else {
2222
$error = null;

src/applications/auth/controller/mfa/PhabricatorAuthFactorProviderViewController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ private function buildPropertiesView(
8383

8484

8585
$custom_enroll = $provider->getEnrollMessage();
86-
if (strlen($custom_enroll)) {
86+
if ($custom_enroll !== null && strlen($custom_enroll)) {
8787
$view->addSectionHeader(
8888
pht('Custom Enroll Message'),
8989
PHUIPropertyListView::ICON_SUMMARY);

src/applications/auth/factor/PhabricatorAuthFactor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ final protected function loadMFASyncToken(
414414
$sync_token = null;
415415

416416
$sync_key = $request->getStr($this->getMFASyncTokenFormKey());
417-
if (strlen($sync_key)) {
417+
if (phutil_nonempty_string($sync_key)) {
418418
$sync_key_digest = PhabricatorHash::digestWithNamedKey(
419419
$sync_key,
420420
PhabricatorAuthMFASyncTemporaryTokenType::DIGEST_KEY);

src/applications/auth/storage/PhabricatorAuthChallenge.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ public static function newChallengeResponsesFromRequest(
5757
assert_instances_of($challenges, __CLASS__);
5858

5959
$token_list = $request->getStr(self::HTTPKEY);
60+
if ($token_list === null) {
61+
return;
62+
}
6063
$token_list = explode(' ', $token_list);
6164

6265
$token_map = array();

src/applications/conpherence/query/ConpherenceThreadQuery.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ protected function loadPage() {
135135
}
136136

137137
protected function buildGroupClause(AphrontDatabaseConnection $conn_r) {
138-
if ($this->participantPHIDs !== null || strlen($this->fulltext)) {
138+
if ($this->participantPHIDs !== null
139+
|| ($this->fulltext !== null && strlen($this->fulltext))) {
139140
return qsprintf($conn_r, 'GROUP BY thread.id');
140141
} else {
141142
return $this->buildApplicationSearchGroupClause($conn_r);
@@ -152,7 +153,7 @@ protected function buildJoinClauseParts(AphrontDatabaseConnection $conn) {
152153
id(new ConpherenceParticipant())->getTableName());
153154
}
154155

155-
if (strlen($this->fulltext)) {
156+
if ($this->fulltext !== null && strlen($this->fulltext)) {
156157
$joins[] = qsprintf(
157158
$conn,
158159
'JOIN %T idx ON idx.threadPHID = thread.phid',
@@ -234,7 +235,7 @@ protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
234235
$this->participantPHIDs);
235236
}
236237

237-
if (strlen($this->fulltext)) {
238+
if ($this->fulltext !== null && strlen($this->fulltext)) {
238239
$where[] = qsprintf(
239240
$conn,
240241
'MATCH(idx.corpus) AGAINST (%s IN BOOLEAN MODE)',

src/applications/conpherence/query/ConpherenceThreadSearchEngine.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ protected function renderResultList(
106106
$engines = array();
107107

108108
$fulltext = $query->getParameter('fulltext');
109-
if (strlen($fulltext) && $conpherences) {
109+
if ($fulltext !== null && strlen($fulltext) && $conpherences) {
110110
$context = $this->loadContextMessages($conpherences, $fulltext);
111111

112112
$author_phids = array();
@@ -151,7 +151,7 @@ protected function renderResultList(
151151
$icon = id(new PHUIIconView())
152152
->setIcon($icon_name);
153153

154-
if (!strlen($fulltext)) {
154+
if ($fulltext === null || !strlen($fulltext)) {
155155
$item = id(new PHUIObjectItemView())
156156
->setObjectName($conpherence->getMonogram())
157157
->setHeader($title)

src/applications/diviner/query/DivinerBookQuery.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ protected function buildWhereClause(AphrontDatabaseConnection $conn) {
133133
$this->phids);
134134
}
135135

136-
if (strlen($this->nameLike)) {
136+
if ($this->nameLike !== null && strlen($this->nameLike)) {
137137
$where[] = qsprintf(
138138
$conn,
139139
'name LIKE %~',
@@ -147,7 +147,7 @@ protected function buildWhereClause(AphrontDatabaseConnection $conn) {
147147
$this->names);
148148
}
149149

150-
if (strlen($this->namePrefix)) {
150+
if ($this->namePrefix !== null && strlen($this->namePrefix)) {
151151
$where[] = qsprintf(
152152
$conn,
153153
'name LIKE %>',

src/applications/metamta/engine/PhabricatorMailEmailEngine.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function newMessage() {
9191
$parts = array();
9292

9393
$encrypt_uri = $mail->getMustEncryptURI();
94-
if (!strlen($encrypt_uri)) {
94+
if ($encrypt_uri === null || !strlen($encrypt_uri)) {
9595
$encrypt_phid = $mail->getRelatedPHID();
9696
if ($encrypt_phid) {
9797
$encrypt_uri = urisprintf(
@@ -100,7 +100,7 @@ public function newMessage() {
100100
}
101101
}
102102

103-
if (strlen($encrypt_uri)) {
103+
if ($encrypt_uri !== null && strlen($encrypt_uri)) {
104104
$parts[] = pht(
105105
'This secure message is notifying you of a change to this object:');
106106
$parts[] = PhabricatorEnv::getProductionURI($encrypt_uri);
@@ -242,7 +242,8 @@ private function newReplyToEmailAddress() {
242242
}
243243

244244
// If we don't have a display name, fill in a default.
245-
if (!strlen($reply_address->getDisplayName())) {
245+
$reply_display_name = $reply_address->getDisplayName();
246+
if ($reply_display_name === null || !strlen($reply_display_name)) {
246247
$reply_address->setDisplayName(PlatformSymbols::getPlatformServerName());
247248
}
248249

@@ -313,7 +314,7 @@ private function newEmailSubject() {
313314
// a generic one.
314315
if ($must_encrypt) {
315316
$encrypt_subject = $mail->getMustEncryptSubject();
316-
if (!strlen($encrypt_subject)) {
317+
if ($encrypt_subject === null || !strlen($encrypt_subject)) {
317318
$encrypt_subject = pht('Object Updated');
318319
}
319320
$subject[] = $encrypt_subject;
@@ -497,7 +498,7 @@ private function newEmailAddress($address, $name = null) {
497498
$object = id(new PhutilEmailAddress())
498499
->setAddress($address);
499500

500-
if (strlen($name)) {
501+
if ($name !== null && strlen($name)) {
501502
$object->setDisplayName($name);
502503
}
503504

@@ -507,7 +508,7 @@ private function newEmailAddress($address, $name = null) {
507508
public function newDefaultEmailAddress() {
508509
$raw_address = PhabricatorEnv::getEnvConfig('metamta.default-address');
509510

510-
if (!strlen($raw_address)) {
511+
if ($raw_address == null || !strlen($raw_address)) {
511512
$domain = $this->newMailDomain();
512513
$raw_address = "noreply@{$domain}";
513514
}
@@ -527,7 +528,7 @@ public function newVoidEmailAddress() {
527528

528529
private function newMailDomain() {
529530
$domain = PhabricatorEnv::getEnvConfig('metamta.reply-handler-domain');
530-
if (strlen($domain)) {
531+
if ($domain !== null && strlen($domain)) {
531532
return $domain;
532533
}
533534

src/applications/metamta/exception/PhabricatorMetaMTAReceivedMailProcessingException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public function __construct($status_code /* ... */) {
1414
$this->statusCode = $args[0];
1515

1616
$args = array_slice($args, 1);
17-
call_user_func_array(array('parent', '__construct'), $args);
17+
call_user_func_array(array(parent::class, '__construct'), $args);
1818
}
1919

2020
}

src/applications/passphrase/view/PassphraseCredentialControl.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ protected function renderInput() {
5050
// credential. Populate it into the menu to allow them to save the form
5151
// without making any changes.
5252
$current_phid = $this->getValue();
53-
if (strlen($current_phid) && empty($options_map[$current_phid])) {
53+
if ($current_phid !== null && strlen($current_phid)
54+
&& empty($options_map[$current_phid])) {
55+
5456
$viewer = $this->getViewer();
5557

5658
$current_name = null;

0 commit comments

Comments
 (0)