Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ca388c2

Browse files
committedApr 6, 2013
use exceptions instead of $trigger_errors
1 parent fbb5e95 commit ca388c2

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed
 

‎core/version_api.php

+8-10
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,10 @@ public function __get( $p_name ) {
124124
* if the version can't be found. If the second parameter is
125125
* false, return false if the version can't be found.
126126
* @param int $p_version_id
127-
* @param bool $p_trigger_errors
128127
* @return array
129128
* @throws MantisBT\Exception\Issue\Version\VersionNotFound
130129
*/
131-
function version_cache_row( $p_version_id, $p_trigger_errors = true ) {
130+
function version_cache_row( $p_version_id ) {
132131
global $g_cache_versions;
133132

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

145144
if( !$row ) {
146-
$g_cache_versions[$c_version_id] = false;
147-
148-
if( $p_trigger_errors ) {
149-
throw new MantisBT\Exception\Issue\Version\VersionNotFound( $p_version_id );
150-
} else {
151-
return false;
152-
}
145+
throw new MantisBT\Exception\Issue\Version\VersionNotFound( $p_version_id );
153146
}
154147

155148
$g_cache_versions[$c_version_id] = $row;
@@ -165,7 +158,12 @@ function version_cache_row( $p_version_id, $p_trigger_errors = true ) {
165158
* @return bool
166159
*/
167160
function version_exists( $p_version_id ) {
168-
return version_cache_row( $p_version_id, false ) !== false;
161+
try {
162+
version_cache_row( $p_version_id );
163+
} catch ( MantisBT\Exception\Issue\Version\VersionNotFound $e ) {
164+
return false;
165+
}
166+
return true;
169167
}
170168

171169
/**

0 commit comments

Comments
 (0)
Please sign in to comment.