mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
Make sure offset
is an integer
Summary: Older git versions allowed the `--skip` to get empty string as value and interpreted that to an int. We were sending `null` in some places where we wanted a `0`, so it all worked out. Since https://git.kernel.org/pub/scm/git/git.git/commit/revision.c?id=71a1e94821666909b7b2bd62a36244c601f8430e git fails when provided empty string for an integer. See Q124 and T15783. Test Plan: Have recent git version (that fails with `--skip ''`, navigate to `/diffusion/1/history/master/`) - see history. Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: aklapper, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Differential Revision: https://we.phorge.it/D25575
This commit is contained in:
parent
603c877fa0
commit
0d9ca2589f
2 changed files with 9 additions and 2 deletions
|
@ -17,6 +17,13 @@ final class ConduitAPIRequest extends Phobject {
|
|||
return coalesce(idx($this->params, $key), $default);
|
||||
}
|
||||
|
||||
public function getIntValue($key, $default = 'undefined_magic_text') {
|
||||
if ($default === 'undefined_magic_text' && !$this->getValueExists($key)) {
|
||||
throw new Exception(pht('Required int param not provided: %s', $key));
|
||||
}
|
||||
return (int)$this->getValue($key, $default);
|
||||
}
|
||||
|
||||
public function getValueExists($key) {
|
||||
return array_key_exists($key, $this->params);
|
||||
}
|
||||
|
|
|
@ -51,8 +51,8 @@ final class DiffusionHistoryQueryConduitAPIMethod
|
|||
$path = null;
|
||||
}
|
||||
|
||||
$offset = $request->getValue('offset');
|
||||
$limit = $request->getValue('limit');
|
||||
$offset = $request->getIntValue('offset');
|
||||
$limit = $request->getIntValue('limit', 100);
|
||||
|
||||
if (phutil_nonempty_string($against_hash)) {
|
||||
$commit_range = "{$against_hash}..{$commit_hash}";
|
||||
|
|
Loading…
Reference in a new issue