Skip to content

Commit 85f51c5

Browse files
committed
Fix PHP 8.1 "str_replace(null)" exception in DivinerAtomRef
Summary: Passing null instead of a string or array to `str_replace()` deprecated since PHP 8.1. Thus do not create a title array with a `null` entry in `DivinerFindController` when there is no `$query_text`, later to be read via `$this->titles` in `DivinerAtomRef`. ``` ERROR 8192: str_replace(): Passing null to parameter freebsd#3 ($subject) of type array|string is deprecated at [/var/www/html/phorge/phorge/src/applications/diviner/atom/DivinerAtomRef.php:205] #0 str_replace(string, string, NULL) called at [<phorge>/src/applications/diviner/atom/DivinerAtomRef.php:205] freebsd#1 DivinerAtomRef::normalizeTitleString(NULL) called at [<phorge>/src/applications/diviner/query/DivinerAtomQuery.php:344] ``` Credits to valerio.bozzolan for finding the right spot in the code. Closes T15911 Test Plan: Go to http://phorge.localhost/diviner/find/ (not passing a `name` URI parameter), optionally with D25768 applied to avoid another exception Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15911 Differential Revision: https://we.phorge.it/D25769
1 parent 39237c0 commit 85f51c5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/applications/diviner/controller/DivinerFindController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ public function handleRequest(AphrontRequest $request) {
5858

5959
if (!$atoms) {
6060
$title_query = clone $query;
61-
$title_query->withTitles(array($query_text));
61+
if (phutil_nonempty_string($query_text)) {
62+
$title_query->withTitles(array($query_text));
63+
}
6264
$atoms = $title_query->execute();
6365
}
6466

0 commit comments

Comments
 (0)