@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix call to undefined HarbormasterBuildMessageRestartTransaction::isFailed()

Summary:
The method `HarbormasterBuildMessageRestartTransaction::isFailed()` does not exist.

While there is a variety of classes that offer a public `isFailed()` method (`HarbormasterBuildStatus`, `HarbormasterBuildableStatus`, `HarbormasterBuild`, `HarbormasterBuildTarget`) which could have been meant instead (the git history provides no hints as this code has always been broken), the error message explicitly refers to a Build. Thus replace `!$this->isFailed()` with `!$build->isFailed()`.

Test Plan:
Run static code analysis; Read/grep the code.

Also, have a repository with at least an already-working Harbormaster Build Plan, and enable the option Restartable = "If Failed", and try to restart a failed build. After the patch it does not crash anymore.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Tags: #almanac_drydock_harbormaster

Differential Revision: https://we.phorge.it/D25749

+7 -9
+7 -9
src/applications/harbormaster/xaction/build/HarbormasterBuildMessageRestartTransaction.php
··· 141 141 142 142 $failed_restartable = HarbormasterBuildPlanBehavior::RESTARTABLE_IF_FAILED; 143 143 $is_failed = ($option_key === $failed_restartable); 144 - if ($is_failed) { 145 - if (!$this->isFailed()) { 146 - throw new HarbormasterMessageException( 147 - pht('Only Restartable if Failed'), 148 - pht( 149 - 'This build can not be restarted because the build plan is '. 150 - 'configured to prevent the build from restarting unless it '. 151 - 'has failed, and it has not failed.')); 152 - } 144 + if ($is_failed && !$build->isFailed()) { 145 + throw new HarbormasterMessageException( 146 + pht('Only Restartable if Failed'), 147 + pht( 148 + 'This build can not be restarted because the build plan is '. 149 + 'configured to prevent the build from restarting unless it '. 150 + 'has failed, and it has not failed.')); 153 151 } 154 152 155 153 }