Skip to content

Commit

Permalink
Fix #11812: Unknown project errors
Browse files Browse the repository at this point in the history
This fix updates the project_api to allow project_get_name to pass the
trigger_errors parameter up to project_cache_row, so that pages like
configuration report won't stop working if there is one bad row.  This
also fixes the error triggered by project_cache_row so that it sets the
project ID string parameter before triggering the error.
  • Loading branch information
amyreese committed Apr 19, 2010
1 parent 00a114d commit 956fe6b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion adm_config_report.php
Expand Up @@ -166,7 +166,7 @@ function print_config_value_as_string( $p_type, $p_value ) {
<?php echo ($v_user_id == 0) ? lang_get( 'all_users' ) : string_display_line( user_get_name( $v_user_id ) ) ?>
</td>
<td class="center">
<?php echo string_display_line( project_get_name( $v_project_id ) ) ?>
<?php echo string_display_line( project_get_name( $v_project_id, false ) ) ?>
</td>
<td>
<?php echo string_display_line( $v_config_id ) ?>
Expand Down
14 changes: 8 additions & 6 deletions core/project_api.php
Expand Up @@ -99,6 +99,7 @@ function project_cache_row( $p_project_id, $p_trigger_errors = true ) {
$g_cache_project_missing[(int) $p_project_id] = true;

if( $p_trigger_errors ) {
error_parameters( $p_project_id );
trigger_error( ERROR_PROJECT_NOT_FOUND, ERROR );
} else {
return false;
Expand Down Expand Up @@ -438,25 +439,26 @@ function project_get_all_rows() {
}

# Return the specified field of the specified project
function project_get_field( $p_project_id, $p_field_name ) {
$row = project_get_row( $p_project_id );
function project_get_field( $p_project_id, $p_field_name, $p_trigger_errors = true ) {
$row = project_get_row( $p_project_id, $p_trigger_errors );

if( isset( $row[$p_field_name] ) ) {
return $row[$p_field_name];
} else {
} else if ( $p_trigger_errors ) {
error_parameters( $p_field_name );
trigger_error( ERROR_DB_FIELD_NOT_FOUND, WARNING );
return '';
}

return '';
}

# Return the name of the project
# Handles ALL_PROJECTS by returning the internationalized string for All Projects
function project_get_name( $p_project_id ) {
function project_get_name( $p_project_id, $p_trigger_errors = true ) {
if( ALL_PROJECTS == $p_project_id ) {
return lang_get( 'all_projects' );
} else {
return project_get_field( $p_project_id, 'name' );
return project_get_field( $p_project_id, 'name', $p_trigger_errors );
}
}

Expand Down

0 comments on commit 956fe6b

Please sign in to comment.