1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-25 16:22:43 +01:00

Fix a PHP 8.1 deprecated use of preg_match with a NULL argument

Summary:
These calls are preventing users to browse subversion/mercurial repositories in PHP 8.1+.
Indeed, a similar bug affecting git repositories was already addressed in another commit
(rP6b8ec50148909938850b5acfd11725ae23a8e31b). This commit harmonize both DiffusionSvnRequest
and DiffusionMercurialRequest with DiffusionGitRequest

Fix T15607

Test Plan:
- Sign in
- Open a diffusion SVN/Mercurial repository
- You should not get a RuntimeException concerning this preg_match call

Reviewers: O1 Blessed Committers, Sten, valerio.bozzolan

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

Subscribers: Sten, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15607

Differential Revision: https://we.phorge.it/D25397
This commit is contained in:
bob 2023-08-17 10:16:24 +02:00
parent 9fa9aa30b9
commit a5d8b2d5cf
2 changed files with 6 additions and 2 deletions

View file

@ -3,6 +3,9 @@
final class DiffusionMercurialRequest extends DiffusionRequest {
protected function isStableCommit($symbol) {
if ($symbol === null) {
return false;
}
return preg_match('/^[a-f0-9]{40}\z/', $symbol);
}
@ -10,11 +13,9 @@ final class DiffusionMercurialRequest extends DiffusionRequest {
if ($this->branch) {
return $this->branch;
}
if ($this->repository) {
return $this->repository->getDefaultBranch();
}
throw new Exception(pht('Unable to determine branch!'));
}

View file

@ -3,6 +3,9 @@
final class DiffusionSvnRequest extends DiffusionRequest {
protected function isStableCommit($symbol) {
if ($symbol === null) {
return false;
}
return preg_match('/^[1-9]\d*\z/', $symbol);
}