From 2ac4c47a747b5971d967571933112edc0f45b89d Mon Sep 17 00:00:00 2001 From: mainframe98 Date: Thu, 12 Feb 2026 19:47:34 +0100 Subject: [PATCH] PHP 8.5: Fix projects used without a PHID set in unit test Summary: `PhabricatorProjectCoreTestCase` creates projects that it doesn't save to the database. As a result, they don't have a PHID. This causes issues because `::getPHID()` will return null instead, which in PHP 8.5 results in deprecation warnings. Closes T16496 Test Plan: Run this unit test on PHP 8.5 and see no 'ERROR 8192' anymore: arc unit src/applications/project/__tests__/PhabricatorProjectCoreTestCase.php Alternatively, for those in the stone age, add a null check to `PhabricatorProjectMembersPolicyRule` for `$object->getPHID()` on lines 34 & 70. (It's me, I'm in the stone age) Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T16496 Differential Revision: https://we.phorge.it/D26751 --- .../__tests__/PhabricatorProjectCoreTestCase.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/applications/project/__tests__/PhabricatorProjectCoreTestCase.php b/src/applications/project/__tests__/PhabricatorProjectCoreTestCase.php index 06f8263776..1d455a6af3 100644 --- a/src/applications/project/__tests__/PhabricatorProjectCoreTestCase.php +++ b/src/applications/project/__tests__/PhabricatorProjectCoreTestCase.php @@ -496,7 +496,10 @@ final class PhabricatorProjectCoreTestCase extends PhabricatorTestCase { $user2 = $this->createUser(); $user2->save(); - $project = PhabricatorProject::initializeNewProject($user1); + $project = PhabricatorProject::initializeNewProject($user1) + ->setName(pht('Test Project for %s', __FUNCTION__)) + ->save(); + $name = pht('Test Project %d', mt_rand()); $xactions = array(); @@ -596,6 +599,7 @@ final class PhabricatorProjectCoreTestCase extends PhabricatorTestCase { $slug2 = 'QuErYSlUgExTrA'; $project = PhabricatorProject::initializeNewProject($user); + $project->setPHID($project->generatePHID()); $xactions = array(); @@ -1184,10 +1188,13 @@ final class PhabricatorProjectCoreTestCase extends PhabricatorTestCase { $author = $this->generateNewTestUser(); $proj_a = PhabricatorProject::initializeNewProject($author) - ->setName('Policy A') + ->setName('Policy A'); + $proj_a->setPHID($proj_a->generatePHID()) ->save(); + $proj_b = PhabricatorProject::initializeNewProject($author) - ->setName('Policy B') + ->setName('Policy B'); + $proj_b->setPHID($proj_b->generatePHID()) ->save(); $user_none = $this->generateNewTestUser(); @@ -1671,6 +1678,7 @@ final class PhabricatorProjectCoreTestCase extends PhabricatorTestCase { $is_milestone = false) { $project = PhabricatorProject::initializeNewProject($user, $parent); + $project->setPHID($project->generatePHID()); $name = pht('Test Project %d', mt_rand()); -- 2.51.2