@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.

Conduit: Fix PHP 8.1 "preg_replace(null)" exception in phriction.history

Summary:
Passing null to `preg_match()` is deprecated since PHP 8.1.

```
ERROR 8192: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated at [/var/www/html/phorge/phorge/src/infrastructure/util/PhabricatorSlug.php:17]
```

Closes T16425

Test Plan:
* PHP 8.1+
* Go to http://phorge.localhost/conduit/method/phriction.history/ and press the "Call Method" button:

Reviewers: O1 Blessed Committers, mainframe98

Reviewed By: O1 Blessed Committers, mainframe98

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T16425

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

+11 -7
+11 -7
src/applications/phriction/conduit/PhrictionHistoryConduitAPIMethod.php
··· 38 38 39 39 protected function execute(ConduitAPIRequest $request) { 40 40 $slug = $request->getValue('slug'); 41 - $doc = id(new PhrictionDocumentQuery()) 42 - ->setViewer($request->getUser()) 43 - ->withSlugs(array(PhabricatorSlug::normalize($slug))) 44 - ->executeOne(); 45 - if (!$doc) { 41 + $document = null; 42 + 43 + if ($slug !== null) { 44 + $document = id(new PhrictionDocumentQuery()) 45 + ->setViewer($request->getUser()) 46 + ->withSlugs(array(PhabricatorSlug::normalize($slug))) 47 + ->executeOne(); 48 + } 49 + if (!$document) { 46 50 throw new ConduitException('ERR-BAD-DOCUMENT'); 47 51 } 48 52 49 53 $content = id(new PhrictionContent())->loadAllWhere( 50 54 'documentID = %d ORDER BY version DESC', 51 - $doc->getID()); 55 + $document->getID()); 52 56 53 57 $results = array(); 54 58 foreach ($content as $version) { 55 59 $results[] = $this->buildDocumentContentDictionary( 56 - $doc, 60 + $document, 57 61 $version); 58 62 } 59 63