@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
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix PHP 8.1 null parameter exceptions which block rendering the "Browse Projects" overlay dialog

Summary:
`strlen()` was used in Phabricator to check if a generic value is a non-empty string.
This behavior is deprecated since PHP 8.1. Phorge adopts `phutil_nonempty_string()` as a replacement.

Note: this may highlight other absurd input values that might be worth correcting
instead of just ignoring. If phutil_nonempty_string() throws an exception in your
instance, report it to Phorge to evaluate and fix that specific corner case.

Similarly, passing `null` to the `$haystack` parameter of `strpos()` is deprecated in PHP 8.1.

Similarly, passing `null` to the `$string` parameter of `ltrim()` is deprecated in PHP 8.1.

Closes part of T15335

Test Plan: Applied these four changes in Phorge (plus the one change in D25180 in Arcanist) and the `Browse Projects` overlay dialog finally rendered in web browser and listed existing projects.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15335

Differential Revision: https://we.phorge.it/D25179

+10 -4
+4 -2
src/applications/project/typeahead/PhabricatorProjectDatasource.php
··· 21 21 $raw_query = $this->getRawQuery(); 22 22 23 23 // Allow users to type "#qa" or "qa" to find "Quality Assurance". 24 - $raw_query = ltrim($raw_query, '#'); 24 + if ($raw_query !== null) { 25 + $raw_query = ltrim($raw_query, '#'); 26 + } 25 27 $tokens = self::tokenizeString($raw_query); 26 28 27 29 $query = id(new PhabricatorProjectQuery()) ··· 142 144 $proj_result->addAttribute($proj->getDisplayIconName()); 143 145 144 146 $description = idx($descriptions, $phid); 145 - if (strlen($description)) { 147 + if (phutil_nonempty_string($description)) { 146 148 $summary = PhabricatorMarkupEngine::summarizeSentence($description); 147 149 $proj_result->addAttribute($summary); 148 150 }
+1 -1
src/applications/typeahead/datasource/PhabricatorTypeaheadCompositeDatasource.php
··· 28 28 29 29 // We only need to do a prefix phase query if there's an actual query 30 30 // string. If the user didn't type anything, nothing can possibly match it. 31 - if (strlen($this->getRawQuery())) { 31 + if (phutil_nonempty_string($this->getRawQuery())) { 32 32 $phases[] = self::PHASE_PREFIX; 33 33 } 34 34
+5 -1
src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
··· 464 464 // We're looking for a "(" so that a string like "members(q" is identified 465 465 // and parsed as a function call. This allows us to start generating 466 466 // results immediately, before the user fully types out "members(quack)". 467 - return (strpos($token, '(') !== false); 467 + if ($token) { 468 + return (strpos($token, '(') !== false); 469 + } else { 470 + return false; 471 + } 468 472 } 469 473 470 474