Skip to content

Commit

Permalink
Remove use of error_parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
mantis committed Jul 30, 2011
1 parent 986ad11 commit c850440
Show file tree
Hide file tree
Showing 41 changed files with 98 additions and 199 deletions.
9 changes: 3 additions & 6 deletions adm_config_set.php
Expand Up @@ -57,8 +57,7 @@
$f_value = gpc_get_string( 'value' );

if ( is_blank( $f_config_option ) ) {
error_parameters( 'config_option' );
throw new MantisBT\Exception\Empty_Field();
throw new MantisBT\Exception\Empty_Field( 'config_option' );
}

access_ensure_global_level( config_get( 'set_configuration_threshold' ) );
Expand All @@ -70,14 +69,12 @@
# make sure that configuration option specified is a valid one.
$t_not_found_value = '***CONFIG OPTION NOT FOUND***';
if ( config_get_global( $f_config_option, $t_not_found_value ) === $t_not_found_value ) {
error_parameters( $f_config_option );
throw new MantisBT\Exception\Config_Opt_Not_Found();
throw new MantisBT\Exception\Config_Opt_Not_Found( $f_config_option );
}

# make sure that configuration option specified can be stored in the database
if ( !config_can_set_in_database( $f_config_option ) ) {
error_parameters( $f_config_option );
throw new MantisBT\Exception\Config_Opt_Cant_Be_Set_In_Db();
throw new MantisBT\Exception\Config_Opt_Cant_Be_Set_In_Db( $f_config_option );
}

if ( $f_type === 'default' ) {
Expand Down
3 changes: 1 addition & 2 deletions bug_actiongroup_add_note_inc.php
Expand Up @@ -99,8 +99,7 @@ function action_add_note_validate( $p_bug_id ) {
$f_bugnote_text = gpc_get_string( 'bugnote_text' );

if ( is_blank( $f_bugnote_text ) ) {
error_parameters( lang_get( 'bugnote' ) );
throw new MantisBT\Exception\Empty_Field();
throw new MantisBT\Exception\Empty_Field( lang_get( 'bugnote' ) );
}

$t_add_bugnote_threshold = config_get( 'add_bugnote_threshold' );
Expand Down
3 changes: 1 addition & 2 deletions bug_relationship_add.php
Expand Up @@ -81,8 +81,7 @@

# bug is not read-only...
if ( bug_is_readonly( $f_src_bug_id ) ) {
error_parameters( $f_src_bug_id );
throw new MantisBT\Exception\Bug_Read_Only_Action_Denied();
throw new MantisBT\Exception\Bug_Read_Only_Action_Denied( $f_src_bug_id );
}

# user can access to the related bug at least as viewer...
Expand Down
3 changes: 1 addition & 2 deletions bug_relationship_delete.php
Expand Up @@ -78,8 +78,7 @@

# bug is not read-only...
if ( bug_is_readonly( $f_bug_id ) ) {
error_parameters( $f_bug_id );
throw new MantisBT\Exception\Bug_Read_Only_Action_Denied();
throw new MantisBT\Exception\Bug_Read_Only_Action_Denied( $f_bug_id );
}

# retrieve the destination bug of the relationship
Expand Down
3 changes: 1 addition & 2 deletions bug_reminder.php
Expand Up @@ -72,8 +72,7 @@
}

if ( bug_is_readonly( $f_bug_id ) ) {
error_parameters( $f_bug_id );
throw new MantisBT\Exception\Bug_Read_Only_Action_Denied();
throw new MantisBT\Exception\Bug_Read_Only_Action_Denied( $f_bug_id );
}

access_ensure_bug_level( config_get( 'bug_reminder_threshold' ), $f_bug_id );
Expand Down
3 changes: 1 addition & 2 deletions bug_reminder_page.php
Expand Up @@ -60,8 +60,7 @@
}

if ( bug_is_readonly( $f_bug_id ) ) {
error_parameters( $f_bug_id );
throw new MantisBT\Exception\Bug_Read_Only_Action_Denied();
throw new MantisBT\Exception\Bug_Read_Only_Action_Denied( $f_bug_id );
}

access_ensure_bug_level( config_get( 'bug_reminder_threshold' ), $f_bug_id );
Expand Down
3 changes: 1 addition & 2 deletions bug_report.php
Expand Up @@ -156,8 +156,7 @@
$t_def['type'] == CUSTOM_FIELD_TYPE_LIST ||
$t_def['type'] == CUSTOM_FIELD_TYPE_MULTILIST ||
$t_def['type'] == CUSTOM_FIELD_TYPE_RADIO ) ) {
error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) );
throw new MantisBT\Exception\Empty_Field();
throw new MantisBT\Exception\Empty_Field( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) );
}
if ( !custom_field_validate( $t_id, gpc_get_custom_field( "custom_field_$t_id", $t_def['type'], NULL ) ) ) {
throw new MantisBT\Exception\Custom_Field_Invalid_Value( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ));
Expand Down
3 changes: 1 addition & 2 deletions bug_report_page.php
Expand Up @@ -93,8 +93,7 @@

# master bug is not read-only...
if ( bug_is_readonly( $f_master_bug_id ) ) {
error_parameters( $f_master_bug_id );
throw new MantisBT\Exception\Bug_Read_Only_Action_Denied();
throw new MantisBT\Exception\Bug_Read_Only_Action_Denied( $f_master_bug_id );
}

$t_bug = bug_get( $f_master_bug_id, true );
Expand Down
12 changes: 4 additions & 8 deletions bug_update.php
Expand Up @@ -83,8 +83,7 @@
# Check if the bug is in a read-only state and whether the current user has
# permission to update read-only bugs.
if ( bug_is_readonly( $f_bug_id ) ) {
error_parameters( $f_bug_id );
throw new MantisBT\Exception\Bug_Read_Only_Action_Denied();
throw new MantisBT\Exception\Bug_Read_Only_Action_Denied( $f_bug_id );
}

$t_updated_bug = clone $t_existing_bug;
Expand Down Expand Up @@ -203,8 +202,7 @@
if ( $t_existing_bug->category_id !== $t_updated_bug->category_id ) {
if ( $t_updated_bug->category_id === 0 &&
!config_get( 'allow_no_category' ) ) {
error_parameters( lang_get( 'category' ) );
throw new MantisBT\Exception\Empty_Field();
throw new MantisBT\Exception\Empty_Field( lang_get( 'category' ) );
}
}

Expand Down Expand Up @@ -245,8 +243,7 @@
if ( $t_cf_def[$t_cf_require_check] ) {
# A value for the custom field was expected however
# no value was given by the user.
error_parameters( lang_get_defaulted( custom_field_get_field( $t_cf_id, 'name' ) ) );
throw new MantisBT\Exception\Empty_Field();
throw new MantisBT\Exception\Empty_Field( lang_get_defaulted( custom_field_get_field( $t_cf_id, 'name' ) ) );
} else {
# The custom field isn't compulsory and the user did
# not supply a value. Therefore we can just ignore this
Expand Down Expand Up @@ -298,8 +295,7 @@
access_ensure_bug_level( config_get( 'add_bugnote_threshold' ), $f_bug_id );
if ( !$t_bug_note->note &&
!config_get( 'time_tracking_without_note' ) ) {
error_parameters( lang_get( 'bugnote' ) );
throw new MantisBT\Exception\Empty_Field();
throw new MantisBT\Exception\Empty_Field( lang_get( 'bugnote' ) );
}
if ( $t_bug_note->view_state !== config_get( 'default_bugnote_view_status' ) ) {
access_ensure_bug_level( config_get( 'set_view_status_threshold' ), $f_bug_id );
Expand Down
3 changes: 1 addition & 2 deletions bug_update_advanced_page.php
Expand Up @@ -87,8 +87,7 @@
}

if ( bug_is_readonly( $f_bug_id ) ) {
error_parameters( $f_bug_id );
throw new MantisBT\Exception\Bug_Read_Only_Action_Denied();
throw new MantisBT\Exception\Bug_Read_Only_Action_Denied( $f_bug_id );
}

access_ensure_bug_level( config_get( 'update_bug_threshold' ), $f_bug_id );
Expand Down
6 changes: 2 additions & 4 deletions bugnote_add.php
Expand Up @@ -67,8 +67,7 @@
}

if ( bug_is_readonly( $t_bug->id ) ) {
error_parameters( $t_bug->id );
throw new MantisBT\Exception\Bug_Read_Only_Action_Denied();
throw new MantisBT\Exception\Bug_Read_Only_Action_Denied( $t_bug->id );
}

access_ensure_bug_level( config_get( 'add_bugnote_threshold' ), $t_bug->id );
Expand All @@ -81,8 +80,7 @@
// if $f_time_tracking is not 0 and the time tracking feature is enabled.
$t_bugnote_id = bugnote_add( $t_bug->id, $f_bugnote_text, $f_time_tracking, $f_private, BUGNOTE );
if ( !$t_bugnote_id ) {
error_parameters( lang_get( 'bugnote' ) );
throw new MantisBT\Exception\Empty_Field();
throw new MantisBT\Exception\Empty_Field( lang_get( 'bugnote' ) );
}

# Handle the reassign on feedback feature. Note that this feature generally
Expand Down
3 changes: 1 addition & 2 deletions bugnote_edit_page.php
Expand Up @@ -93,8 +93,7 @@

# Check if the bug is readonly
if ( bug_is_readonly( $t_bug_id ) ) {
error_parameters( $t_bug_id );
throw new MantisBT\Exception\Bug_Read_Only_Action_Denied();
throw new MantisBT\Exception\Bug_Read_Only_Action_Denied( $t_bug_id );
}

$t_bugnote_text = string_textarea( bugnote_get_text( $f_bugnote_id ) );
Expand Down
3 changes: 1 addition & 2 deletions bugnote_set_view_state.php
Expand Up @@ -71,8 +71,7 @@
# Check if the bug is readonly
$t_bug_id = bugnote_get_field( $f_bugnote_id, 'bug_id' );
if ( bug_is_readonly( $t_bug_id ) ) {
error_parameters( $t_bug_id );
throw new MantisBT\Exception\Bug_Read_Only_Action_Denied();
throw new MantisBT\Exception\Bug_Read_Only_Action_Denied( $t_bug_id );
}

# Check if the current user is allowed to change the view state of this bugnote
Expand Down
3 changes: 1 addition & 2 deletions bugnote_update.php
Expand Up @@ -73,8 +73,7 @@
# Check if the bug is readonly
$t_bug_id = bugnote_get_field( $f_bugnote_id, 'bug_id' );
if ( bug_is_readonly( $t_bug_id ) ) {
error_parameters( $t_bug_id );
throw new MantisBT\Exception\Bug_Read_Only_Action_Denied();
throw new MantisBT\Exception\Bug_Read_Only_Action_Denied( $t_bug_id );
}

$f_bugnote_text = trim( $f_bugnote_text ) . "\n\n";
Expand Down
3 changes: 1 addition & 2 deletions changelog_page.php
Expand Up @@ -147,8 +147,7 @@ function print_project_header_changelog ( $p_project_name ) {
$f_version_id = version_get_id( $f_version, $t_project_id );

if ( $f_version_id === false ) {
error_parameters( $f_version );
throw new MantisBT\Exception\Version_Not_Found();
throw new MantisBT\Exception\Version_Not_Found( $f_version );
}
}

Expand Down
24 changes: 8 additions & 16 deletions core/bug_api.php
Expand Up @@ -219,8 +219,7 @@ function bug_cache_row( $p_bug_id, $p_trigger_errors = false ) {
$g_cache_bug[$c_bug_id] = false;

if( $p_trigger_errors ) {
error_parameters( $p_bug_id );
throw new MantisBT\Exception\Bug_Not_Found();
throw new MantisBT\Exception\Bug_Not_Found( $p_bug_id );
} else {
return false;
}
Expand Down Expand Up @@ -377,22 +376,19 @@ private function bug_get_bugnote_count() {
function validate( $p_update_extended = true) {
# Summary cannot be blank
if( is_blank( $this->summary ) ) {
error_parameters( lang_get( 'summary' ) );
throw new MantisBT\Exception\Empty_Field();
throw new MantisBT\Exception\Empty_Field( lang_get( 'summary' ) );
}

if( $p_update_extended ) {
# Description field cannot be empty
if( is_blank( $this->description ) ) {
error_parameters( lang_get( 'description' ) );
throw new MantisBT\Exception\Empty_Field();
throw new MantisBT\Exception\Empty_Field( lang_get( 'description' ) );
}
}

# Make sure a category is set
if( 0 == $this->category_id && !config_get( 'allow_no_category' ) ) {
error_parameters( lang_get( 'category' ) );
throw new MantisBT\Exception\Empty_Field();
throw new MantisBT\Exception\Empty_Field( lang_get( 'category' ) );
}

if( !is_blank( $this->duplicate_id ) && ( $this->duplicate_id != 0 ) && ( $this->id == $this->duplicate_id ) ) {
Expand Down Expand Up @@ -781,8 +777,7 @@ function bug_text_cache_row( $p_bug_id, $p_trigger_errors = true ) {
$g_cache_bug_text[$c_bug_id] = false;

if( $p_trigger_errors ) {
error_parameters( $p_bug_id );
throw new MantisBT\Exception\Bug_Not_Found();
throw new MantisBT\Exception\Bug_Not_Found( $p_bug_id );
} else {
return false;
}
Expand Down Expand Up @@ -834,8 +829,7 @@ function bug_exists( $p_bug_id ) {
*/
function bug_ensure_exists( $p_bug_id ) {
if( !bug_exists( $p_bug_id ) ) {
error_parameters( $p_bug_id );
throw new MantisBT\Exception\Bug_Not_Found();
throw new MantisBT\Exception\Bug_Not_Found( $p_bug_id );
}
}

Expand Down Expand Up @@ -1257,8 +1251,7 @@ function bug_get_field( $p_bug_id, $p_field_name ) {
if( isset( $t_bug_data->{$p_field_name} ) ) {
return $t_bug_data->{$p_field_name};
} else {
error_parameters( $p_field_name );
throw new MantisBT\Exception\DB_Field_Not_Found();
throw new MantisBT\Exception\DB_Field_Not_Found( $p_field_name );
return '';
}
}
Expand All @@ -1277,8 +1270,7 @@ function bug_get_text_field( $p_bug_id, $p_field_name ) {
if( isset( $row[$p_field_name] ) ) {
return $row[$p_field_name];
} else {
error_parameters( $p_field_name );
throw new MantisBT\Exception\DB_Field_Not_Found();
throw new MantisBT\Exception\DB_Field_Not_Found( $p_field_name );
return '';
}
}
Expand Down
6 changes: 2 additions & 4 deletions core/bugnote_api.php
Expand Up @@ -152,8 +152,7 @@ function bugnote_add( $p_bug_id, $p_bugnote_text, $p_time_tracking = '0:00', $p_

if( ON == $t_time_tracking_enabled && $c_time_tracking > 0 ) {
if( is_blank( $p_bugnote_text ) && OFF == $t_time_tracking_without_note ) {
error_parameters( lang_get( 'bugnote' ) );
throw new MantisBT\Exception\Empty_Field();
throw new MantisBT\Exception\Empty_Field( lang_get( 'bugnote' ) );
}
$c_type = TIME_TRACKING;
} else if( is_blank( $p_bugnote_text ) ) {
Expand Down Expand Up @@ -606,8 +605,7 @@ function bugnote_stats_get_project_array( $p_project_id, $p_from, $p_to, $p_cost
$c_from = strtotime( $p_from );

if ( $c_to === false || $c_from === false ) {
error_parameters( array( $p_form, $p_to ) );
throw new MantisBT\Exception\Generic();
throw new MantisBT\Exception\Generic( array( $p_form, $p_to ) );
}

if( !is_blank( $c_from ) ) {
Expand Down
7 changes: 3 additions & 4 deletions core/category_api.php
Expand Up @@ -126,8 +126,7 @@ function category_add( $p_project_id, $p_name ) {
$c_project_id = db_prepare_int( $p_project_id );

if( is_blank( $p_name ) ) {
error_parameters( lang_get( 'category' ) );
throw new MantisBT\Exception\Empty_Field();
throw new MantisBT\Exception\Empty_Field( lang_get( 'category' ) );
}

category_ensure_unique( $p_project_id, $p_name );
Expand All @@ -149,8 +148,8 @@ function category_add( $p_project_id, $p_name ) {
*/
function category_update( $p_category_id, $p_name, $p_assigned_to ) {
if( is_blank( $p_name ) ) {
error_parameters( lang_get( 'category' ) );
throw new MantisBT\Exception\Empty_Field();
error_parameters( );
throw new MantisBT\Exception\Empty_Field( lang_get( 'category' ) );
}

$t_old_category = category_get_row( $p_category_id );
Expand Down
4 changes: 1 addition & 3 deletions core/classes/MantisDatabase/PDO/PDO.class.php
Expand Up @@ -37,9 +37,7 @@ public function connect($dsn, $dbhost, $dbuser, $dbpass, $dbname, array $dboptio
$driverstatus = $this->driver_installed();

if ($driverstatus !== true) {
error_parameters( 0, 'PHP Support for database is not enabled' );
throw new MantisBT\Exception\DB_Connect_Failed();

throw new MantisBT\Exception\DB_Connect_Failed( 'PHP Support for database is not enabled' );
//throw new MantisDatabaseException('DatabaseDriverProblem', $driverstatus);
}

Expand Down
21 changes: 18 additions & 3 deletions core/classes/MantisError.class.php
Expand Up @@ -109,7 +109,7 @@ public static function display_errors( $p_no_header = false ) {
}

$t_oblen = ob_get_length();
if( error_handled() && $t_oblen > 0 ) {
if( self::error_handled() && $t_oblen > 0 ) {
$t_old_contents = ob_get_contents();
}

Expand Down Expand Up @@ -368,15 +368,30 @@ public static function error_alternate_class() {
return 'class="row-2"';
}
}


/**
* Set additional info parameters to be used when displaying the next error
* This function takes a variable number of parameters
*
* When writing internationalized error strings, note that you can change the
* order of parameters in the string. See the PHP manual page for the
* sprintf() function for more details.
* @access public
* @return null
*/
public static function error_parameters( $p_args ) {
self::$_parameters = $p_args;
}

public static function error_proceed_url( $p_url ) {
self::$_proceed_url = $p_url();
}


/**
* Check if we have handled an error during this page
* Return true if an error has been handled, false otherwise
* @return bool
*/
public static function error_handled() {
return self::$_handled;
}
Expand Down
3 changes: 1 addition & 2 deletions core/classes/MantisUser.class.php
Expand Up @@ -70,8 +70,7 @@ function user_cache_row( $p_user_id, $p_trigger_errors = true ) {
return $row;
} else {
if( $p_trigger_errors ) {
error_parameters( (integer)$p_user_id );
throw new MantisBT\Exception\User_By_ID_Not_Found();
throw new MantisBT\Exception\User_By_ID_Not_Found( $p_user_id );
}

return false;
Expand Down

0 comments on commit c850440

Please sign in to comment.