From 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 13 Nov 2023 10:53:58 -0800 Subject: [PATCH] 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 --- src/applications/auth/constants/PhabricatorCookies.php | 2 +- .../auth/controller/PhabricatorAuthSetExternalController.php | 2 +- .../notification/client/PhabricatorNotificationServerRef.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/applications/auth/constants/PhabricatorCookies.php b/src/applications/auth/constants/PhabricatorCookies.php index 31bdf3704c..f85f1fc997 100644 --- a/src/applications/auth/constants/PhabricatorCookies.php +++ b/src/applications/auth/constants/PhabricatorCookies.php @@ -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; } diff --git a/src/applications/auth/controller/PhabricatorAuthSetExternalController.php b/src/applications/auth/controller/PhabricatorAuthSetExternalController.php index 8b0a44b9dc..2a8bbda7df 100644 --- a/src/applications/auth/controller/PhabricatorAuthSetExternalController.php +++ b/src/applications/auth/controller/PhabricatorAuthSetExternalController.php @@ -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 '. diff --git a/src/applications/notification/client/PhabricatorNotificationServerRef.php b/src/applications/notification/client/PhabricatorNotificationServerRef.php index 7788bacaaf..f3a49afc9f 100644 --- a/src/applications/notification/client/PhabricatorNotificationServerRef.php +++ b/src/applications/notification/client/PhabricatorNotificationServerRef.php @@ -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()) -- 2.11.4.GIT