Skip to content

Commit f2eab8f

Browse files
committed
Patch: validate linked bug only on construction
1 parent 28ac806 commit f2eab8f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

entities/Patch.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ static function factory(ProjGroup $group, string $url, $type,
182182
$commits[0]['message']);
183183

184184
$issue_url = $p->getIssueURL();
185+
if (!$issue_url)
186+
throw new ValidationException('Patch does not have a bug associated');
187+
185188
if (!strstr($issue_url, $m[1]))
186189
throw new ValidationException(
187190
"Referenced issue #$m[1] doesn't match the specified issue URL: " .
@@ -278,14 +281,12 @@ public function getPRURL() {
278281
return $pr ? $pr->url() : null;
279282
}
280283

281-
public function getIssueURL() : string {
284+
public function getIssueURL() : ?string {
282285
if ($this->type != PATCH_BUGFIX)
283-
return '';
286+
return null;
284287

285288
$bug = db_fetch_bug_user($this->group->year, $this->getSubmitter());
286-
if ($bug === null)
287-
throw new ValidationException('Patch does not have a bug associated');
288-
return $bug->issue_url;
289+
return $bug === null ? null : $bug->issue_url;
289290
}
290291

291292
/// returns (login, name, email)*

0 commit comments

Comments
 (0)