1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-13 09:06:14 +01:00

Fix error in Mercurial when no offset is specified

Summary:
When viewing the history of a Mercurial diffusion repository the server return a 500. This is
because a function call to array_slice requires the offset to be set to an integer. So when it is
not specified it can be set to 0 as a default.

The error is as follows:

```
ERROR 8192: array_slice(): Passing null to parameter #2 ($offset) of type int is deprecated at [/usr/local/www/phorge/src/applications/diffusion/conduit/DiffusionHistoryQueryConduitAPIMethod.php:167]; PHP message: arcanist(head=master, ref.master=3cb117684f4e), phorge(head=master, ref.master=4bf5c452eb28); PHP message:   #0 array_slice(array, NULL) called at [<phorge>/src/applications/diffusion/conduit/DiffusionHistoryQueryConduitAPIMethod.php:167]
```

Test Plan: The history tab should not return a 500 when not specifying an offset

Reviewers: O1 Blessed Committers, valerio.bozzolan, speck

Reviewed By: O1 Blessed Committers, valerio.bozzolan, speck

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

Differential Revision: https://we.phorge.it/D25673
This commit is contained in:
Andre Klapper 2024-09-04 14:45:50 +02:00 committed by Jeffrey Gelens
parent 7429da91d2
commit dbcc447249

View file

@ -24,7 +24,7 @@ final class DiffusionHistoryQueryConduitAPIMethod
'commit' => 'required string', 'commit' => 'required string',
'against' => 'optional string', 'against' => 'optional string',
'path' => 'required string', 'path' => 'required string',
'offset' => 'required int', 'offset' => 'optional int',
'limit' => 'required int', 'limit' => 'required int',
'needDirectChanges' => 'optional bool', 'needDirectChanges' => 'optional bool',
'needChildChanges' => 'optional bool', 'needChildChanges' => 'optional bool',
@ -109,7 +109,7 @@ final class DiffusionHistoryQueryConduitAPIMethod
$repository = $drequest->getRepository(); $repository = $drequest->getRepository();
$commit_hash = $request->getValue('commit'); $commit_hash = $request->getValue('commit');
$path = $request->getValue('path'); $path = $request->getValue('path');
$offset = $request->getValue('offset'); $offset = $request->getValue('offset', 0);
$limit = $request->getValue('limit'); $limit = $request->getValue('limit');
$path = DiffusionPathIDQuery::normalizePath($path); $path = DiffusionPathIDQuery::normalizePath($path);