Fixed BuildFactory::getBuildById. Issue #162.
This commit is contained in:
parent
3b3557b8b5
commit
2bbdd8c393
|
@ -13,18 +13,16 @@ use PHPCensor\Model\Build;
|
|||
class BuildFactory
|
||||
{
|
||||
/**
|
||||
* @param $buildId
|
||||
* @param integer $buildId
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @return Build
|
||||
* @return Build|null
|
||||
*/
|
||||
public static function getBuildById($buildId)
|
||||
{
|
||||
$build = Factory::getStore('Build')->getById($buildId);
|
||||
|
||||
if (empty($build)) {
|
||||
throw new \Exception('Build ID ' . $buildId . ' does not exist.');
|
||||
return null;
|
||||
}
|
||||
|
||||
return self::getBuild($build);
|
||||
|
|
|
@ -62,13 +62,9 @@ class BuildController extends Controller
|
|||
$severity = null;
|
||||
}
|
||||
|
||||
try {
|
||||
$build = BuildFactory::getBuildById($buildId);
|
||||
} catch (\Exception $ex) {
|
||||
$build = null;
|
||||
}
|
||||
$build = BuildFactory::getBuildById($buildId);
|
||||
|
||||
if (empty($build)) {
|
||||
if (!$build) {
|
||||
throw new NotFoundException(Lang::get('build_x_not_found', $buildId));
|
||||
}
|
||||
|
||||
|
@ -246,7 +242,7 @@ class BuildController extends Controller
|
|||
$copy = BuildFactory::getBuildById($buildId);
|
||||
$project = b8\Store\Factory::getStore('Project')->getByPrimaryKey($copy->getProjectId());
|
||||
|
||||
if (empty($copy) || $project->getArchived()) {
|
||||
if (!$copy || $project->getArchived()) {
|
||||
throw new NotFoundException(Lang::get('build_x_not_found', $buildId));
|
||||
}
|
||||
|
||||
|
@ -271,7 +267,7 @@ class BuildController extends Controller
|
|||
|
||||
$build = BuildFactory::getBuildById($buildId);
|
||||
|
||||
if (empty($build)) {
|
||||
if (!$build) {
|
||||
throw new NotFoundException(Lang::get('build_x_not_found', $buildId));
|
||||
}
|
||||
|
||||
|
@ -348,10 +344,10 @@ class BuildController extends Controller
|
|||
|
||||
public function ajaxMeta($buildId)
|
||||
{
|
||||
$build = BuildFactory::getBuildById($buildId);
|
||||
$key = $this->getParam('key', null);
|
||||
$build = BuildFactory::getBuildById($buildId);
|
||||
$key = $this->getParam('key', null);
|
||||
$numBuilds = $this->getParam('num_builds', 1);
|
||||
$data = null;
|
||||
$data = null;
|
||||
|
||||
if ($key && $build) {
|
||||
$data = $this->buildStore->getMeta($key, $build->getProjectId(), $buildId, $build->getBranch(), $numBuilds);
|
||||
|
|
|
@ -96,9 +96,8 @@ class BuildWorker
|
|||
|
||||
$this->logger->addInfo('Received build #'.$jobData['build_id'].' from Beanstalkd');
|
||||
|
||||
try {
|
||||
$build = BuildFactory::getBuildById($jobData['build_id']);
|
||||
} catch (\Exception $ex) {
|
||||
$build = BuildFactory::getBuildById($jobData['build_id']);
|
||||
if (!$build) {
|
||||
$this->logger->addWarning('Build #' . $jobData['build_id'] . ' does not exist in the database.');
|
||||
$this->pheanstalk->delete($job);
|
||||
continue;
|
||||
|
|
Loading…
Reference in a new issue