From dbcc4472493af6cde1074046bc06cfeaf93cb1fe Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Wed, 4 Sep 2024 14:45:50 +0200 Subject: [PATCH] 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 [/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 --- .../conduit/DiffusionHistoryQueryConduitAPIMethod.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/applications/diffusion/conduit/DiffusionHistoryQueryConduitAPIMethod.php b/src/applications/diffusion/conduit/DiffusionHistoryQueryConduitAPIMethod.php index 0c5e24e0e0..c132447148 100644 --- a/src/applications/diffusion/conduit/DiffusionHistoryQueryConduitAPIMethod.php +++ b/src/applications/diffusion/conduit/DiffusionHistoryQueryConduitAPIMethod.php @@ -24,7 +24,7 @@ final class DiffusionHistoryQueryConduitAPIMethod 'commit' => 'required string', 'against' => 'optional string', 'path' => 'required string', - 'offset' => 'required int', + 'offset' => 'optional int', 'limit' => 'required int', 'needDirectChanges' => 'optional bool', 'needChildChanges' => 'optional bool', @@ -109,7 +109,7 @@ final class DiffusionHistoryQueryConduitAPIMethod $repository = $drequest->getRepository(); $commit_hash = $request->getValue('commit'); $path = $request->getValue('path'); - $offset = $request->getValue('offset'); + $offset = $request->getValue('offset', 0); $limit = $request->getValue('limit'); $path = DiffusionPathIDQuery::normalizePath($path);