Skip to content

Commit a5d8b2d

Browse files
committed
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
1 parent 9fa9aa3 commit a5d8b2d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/applications/diffusion/request/DiffusionMercurialRequest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@
33
final class DiffusionMercurialRequest extends DiffusionRequest {
44

55
protected function isStableCommit($symbol) {
6+
if ($symbol === null) {
7+
return false;
8+
}
69
return preg_match('/^[a-f0-9]{40}\z/', $symbol);
710
}
811

912
public function getBranch() {
1013
if ($this->branch) {
1114
return $this->branch;
1215
}
13-
1416
if ($this->repository) {
1517
return $this->repository->getDefaultBranch();
1618
}
17-
1819
throw new Exception(pht('Unable to determine branch!'));
1920
}
2021

src/applications/diffusion/request/DiffusionSvnRequest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
final class DiffusionSvnRequest extends DiffusionRequest {
44

55
protected function isStableCommit($symbol) {
6+
if ($symbol === null) {
7+
return false;
8+
}
69
return preg_match('/^[1-9]\d*\z/', $symbol);
710
}
811

0 commit comments

Comments
 (0)