Correct Aphlict websocket URI construction after PHP8 compatibility changes

Summary:
See D21862. Ref T13700. D21862 affected notification server URI generation behavior when a notification server client is configured with:

  1. no "path" argument; and
  2. "cluster.instance" not set.

Condition (1) is not true default, and condition (2) is not true in my local environment, so it was easy for this to slip through the cracks. Apply the change suggested in D21862.

Also fix a couple other string-null issues I caught locally.

Test Plan: Generated notification server URIs under various simulated local conditions (no instance, path set) and everything seemed to be working correctly.

Maniphest Tasks: T13700

Differential Revision: https://secure.phabricator.com/D21875
This commit is contained in:
epriestley 2023-11-13 10:53:58 -08:00
parent 40b272fa51
commit 5720a38cfe
3 changed files with 4 additions and 4 deletions

View file

@ -164,7 +164,7 @@ final class PhabricatorCookies extends Phobject {
// Old cookies look like: /uri
// New cookies look like: timestamp,/uri
if (!strlen($cookie)) {
if (!phutil_nonempty_string($cookie)) {
return null;
}

View file

@ -40,7 +40,7 @@ final class PhabricatorAuthSetExternalController
$text = PhabricatorAuthMessage::loadMessageText(
$viewer,
PhabricatorAuthLinkMessageType::MESSAGEKEY);
if (!strlen($text)) {
if (!phutil_nonempty_string($text)) {
$text = pht(
'You can link your %s account to an external account to '.
'allow you to log in more easily in the future. To continue, choose '.

View file

@ -147,7 +147,7 @@ final class PhabricatorNotificationServerRef
if ($to_path === null || !strlen($to_path)) {
$to_path = '';
} else {
$to_path = '/'.ltrim($to_path, '/');
$to_path = ltrim($to_path, '/');
}
$base_path = $this->getPath();
@ -156,7 +156,7 @@ final class PhabricatorNotificationServerRef
} else {
$base_path = rtrim($base_path, '/');
}
$full_path = $base_path.$to_path;
$full_path = $base_path.'/'.$to_path;
$uri = id(new PhutilURI('http://'.$this->getHost()))
->setProtocol($this->getProtocol())