Skip to content

Commit

Permalink
use exceptions instead of $trigger_errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mantis committed Apr 6, 2013
1 parent fbb5e95 commit ca388c2
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions core/version_api.php
Expand Up @@ -124,11 +124,10 @@ public function __get( $p_name ) {
* if the version can't be found. If the second parameter is
* false, return false if the version can't be found.
* @param int $p_version_id
* @param bool $p_trigger_errors
* @return array
* @throws MantisBT\Exception\Issue\Version\VersionNotFound
*/
function version_cache_row( $p_version_id, $p_trigger_errors = true ) {
function version_cache_row( $p_version_id ) {
global $g_cache_versions;

$c_version_id = (int)$p_version_id;
Expand All @@ -143,13 +142,7 @@ function version_cache_row( $p_version_id, $p_trigger_errors = true ) {
$row = db_fetch_array( $result );

if( !$row ) {
$g_cache_versions[$c_version_id] = false;

if( $p_trigger_errors ) {
throw new MantisBT\Exception\Issue\Version\VersionNotFound( $p_version_id );
} else {
return false;
}
throw new MantisBT\Exception\Issue\Version\VersionNotFound( $p_version_id );
}

$g_cache_versions[$c_version_id] = $row;
Expand All @@ -165,7 +158,12 @@ function version_cache_row( $p_version_id, $p_trigger_errors = true ) {
* @return bool
*/
function version_exists( $p_version_id ) {
return version_cache_row( $p_version_id, false ) !== false;
try {
version_cache_row( $p_version_id );
} catch ( MantisBT\Exception\Issue\Version\VersionNotFound $e ) {
return false;
}
return true;
}

/**
Expand Down

0 comments on commit ca388c2

Please sign in to comment.