Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mantisbt/mantisbt
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: dd66cd8cdcb9
Choose a base ref
...
head repository: mantisbt/mantisbt
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e312d2285043
Choose a head ref
  • 5 commits
  • 3 files changed
  • 1 contributor

Commits on Mar 18, 2013

  1. Fix #15592: application error 0 in adm_config_report.php

    This was due to a missing type cast in call to check_selected(). The
    for loop was replaced by a call to print_option_list_from_array(), to
    avoid code duplication.
    dregad committed Mar 18, 2013

    Verified

    This commit was signed with the committer’s verified signature.
    elseym Simon Waibl
    Copy the full SHA
    2d9f1d6 View commit details
  2. adm_config_report.php: don't post filter data on config rows buttons

    This is handled through cookie
    dregad committed Mar 18, 2013
    Copy the full SHA
    6bcc30e View commit details
  3. Copy the full SHA
    dea0f71 View commit details

Commits on Mar 27, 2013

  1. Config report: retrieval of saved project filter does not work

    When retrieving a saved filter from the cookie in adm_config_report.php
    the saved project id is not reflected in the filter's selection list:
    'All Projects' is always selected instead of the actual project. This
    value should only be picked as default when the project id does not
    exist.
    
    This is due to a missing negation in the check for project's existence.
    
    Fixes  #15691
    dregad committed Mar 27, 2013
    Copy the full SHA
    b55fc0d View commit details
  2. LOG_DATABASE causes 'Array to string conversion' system notice

    This is due to using $p_msg instead of $s_msg in log_event() at line 93.
    
    Fixes #15685
    dregad committed Mar 27, 2013
    Copy the full SHA
    e312d22 View commit details
Showing with 93 additions and 87 deletions.
  1. +89 −84 adm_config_report.php
  2. +3 −2 core/database_api.php
  3. +1 −1 core/logging_api.php
173 changes: 89 additions & 84 deletions adm_config_report.php
Original file line number Diff line number Diff line change
@@ -73,6 +73,7 @@

function get_config_type( $p_type ) {
global $t_config_types;

if( array_key_exists( $p_type, $t_config_types ) ) {
return $t_config_types[$p_type];
} else {
@@ -101,7 +102,7 @@ function print_config_value_as_string( $p_type, $p_value, $p_for_display = true
return;
case CONFIG_TYPE_COMPLEX:
$t_value = @unserialize( $p_value );
if ( $t_value === false ) {
if( $t_value === false ) {
$t_corrupted = true;
}
break;
@@ -110,7 +111,7 @@ function print_config_value_as_string( $p_type, $p_value, $p_for_display = true
break;
}

if ( $t_corrupted ) {
if( $t_corrupted ) {
$t_output = $p_for_display ? lang_get( 'configuration_corrupted' ) : '';
} else {
$t_output = var_export( $t_value, true );
@@ -131,6 +132,7 @@ function print_option_list_from_array( $p_array, $p_filter_value ) {
}
}


# Get filter values
$t_filter_save = gpc_get_bool( 'save' );
$t_filter_default = gpc_get_bool( 'default_filter_button', false );
@@ -172,7 +174,7 @@ function print_option_list_from_array( $p_array, $p_filter_value ) {
$t_filter_project_value = $t_cookie_contents[1];
$t_filter_config_value = $t_cookie_contents[2];

if( $t_filter_project_value != META_FILTER_NONE && project_exists( $t_filter_project_value ) ) {
if( $t_filter_project_value != META_FILTER_NONE && !project_exists( $t_filter_project_value ) ) {
$t_filter_project_value = ALL_PROJECTS;
}
}
@@ -200,7 +202,7 @@ function print_option_list_from_array( $p_array, $p_filter_value ) {
} else {
$t_users_list = array();
}
while ( $row = db_fetch_array( $t_result ) ) {
while( $row = db_fetch_array( $t_result ) ) {
$t_user_id = $row['user_id'];
$t_users_list[$t_user_id] = user_get_name( $t_user_id );
}
@@ -221,7 +223,7 @@ function print_option_list_from_array( $p_array, $p_filter_value ) {
$t_result = db_query_bound( $query );
$t_projects_list[META_FILTER_NONE] = '[' . lang_get( 'any' ) . ']';
$t_projects_list[ALL_PROJECTS] = lang_get( 'all_projects' );
while ( $row = db_fetch_array( $t_result ) ) {
while( $row = db_fetch_array( $t_result ) ) {
extract( $row, EXTR_PREFIX_ALL, 'v' );
$t_projects_list[$v_project_id] = $v_project_name;
}
@@ -236,7 +238,7 @@ function print_option_list_from_array( $p_array, $p_filter_value ) {
# Make sure the filter value exists in the list
$t_configs_list[$t_filter_config_value] = $t_filter_config_value;
}
while ( $row = db_fetch_array( $t_result ) ) {
while( $row = db_fetch_array( $t_result ) ) {
extract( $row, EXTR_PREFIX_ALL, 'v' );
$t_configs_list[$v_config_id] = $v_config_id;
}
@@ -266,7 +268,7 @@ function print_option_list_from_array( $p_array, $p_filter_value ) {
<!-- FILTER FORM -->
<div id="config-filter-div" class="table-container">

<form name="filter_form" method="post">
<form id="filter_form" method="post">
<?php # CSRF protection not required here - form does not result in modifications ?>
<input type="hidden" name="save" value="1" />

@@ -324,6 +326,7 @@ function print_option_list_from_array( $p_array, $p_filter_value ) {
</form>
</div>

<!-- CONFIGURATIONS LIST -->
<div>
<div id="adm-config-div" class="table-container" style="display: table">
<h2><?php echo lang_get( 'database_configuration' ) ?></h2>
@@ -336,17 +339,18 @@ function print_option_list_from_array( $p_array, $p_filter_value ) {
<th><?php echo lang_get( 'configuration_option_type' ) ?></th>
<th><?php echo lang_get( 'configuration_option_value' ) ?></th>
<th><?php echo lang_get( 'access_level' ) ?></th>
<?php if ( $t_read_write_access ): ?>
<?php if( $t_read_write_access ) { ?>
<th><?php echo lang_get( 'actions' ) ?></th>
<?php endif; ?>
<?php } ?>
</tr>

<?php
# Pre-generate a form security token to avoid performance issues when the
# db contains a large number of configurations
$t_form_security_token = form_security_token( 'adm_config_delete' );
# Pre-generate a form security token to avoid performance issues when the
# db contains a large number of configurations
$t_form_security_token = form_security_token( 'adm_config_delete' );

while ( $row = db_fetch_array( $result ) ) {
extract( $row, EXTR_PREFIX_ALL, 'v' );
while( $row = db_fetch_array( $result ) ) {
extract( $row, EXTR_PREFIX_ALL, 'v' );

?>
<!-- Repeated Info Rows -->
@@ -359,79 +363,84 @@ function print_option_list_from_array( $p_array, $p_filter_value ) {
<td ><?php echo string_display_line( get_config_type( $v_type ) ) ?></td>
<td style="overflow-x:auto;"><?php print_config_value_as_string( $v_type, $v_value ) ?></td>
<td ><?php echo get_enum_element( 'access_levels', $v_access_reqd ) ?></td>
<?php if ( $t_read_write_access ): ?>
<td >
<?php
if (
config_can_delete( $v_config_id )
&& access_has_global_level( config_get( 'set_configuration_threshold' ) )
) {
# Update button (will populate edit form at page bottom)
print_button(
'#config_set_form',
lang_get( 'edit_link' ),
array(
'filter_user_id' => $t_filter_user_value,
'filter_project_id' => $t_filter_project_value,
'filter_config_id' => $t_filter_config_value,
'user_id' => $v_user_id,
'project_id' => $v_project_id,
'config_option' => $v_config_id,
'type' => $v_type,
'value' => $v_value,
),
OFF
);

# Delete button
print_button(
'adm_config_delete.php',
lang_get( 'delete_link' ),
array(
'user_id' => $v_user_id,
'project_id' => $v_project_id,
'config_option' => $v_config_id,
),
$t_form_security_token
);
} else {
echo '&#160;';
}
?>
<?php
if( $t_read_write_access ) {
?>
<td class="center">
<?php
if( config_can_delete( $v_config_id ) ) {
# Update button (will populate edit form at page bottom)
print_button(
'#config_set_form',
lang_get( 'edit_link' ),
array(
'user_id' => $v_user_id,
'project_id' => $v_project_id,
'config_option' => $v_config_id,
'type' => $v_type,
'value' => $v_value,
),
OFF
);

# Delete button
print_button(
'adm_config_delete.php',
lang_get( 'delete_link' ),
array(
'user_id' => $v_user_id,
'project_id' => $v_project_id,
'config_option' => $v_config_id,
),
$t_form_security_token
);
} else {
echo '&#160;';
}
?>
</td>
<?php endif; ?>
<?php
} # end if config_can_delete
?>
</tr>
<?php
} # end for loop
} # end while loop
?>
</table>
</div>
</div>

<?php
# Only display the edit form if user is authorized to change configuration
if ( $t_read_write_access ) { ?>
if( $t_read_write_access ) {
?>

<!-- Config Set Form -->

<div id="config-edit-div" class="form-container">
<!-- Config Set Form -->
<form id="config_set_form" method="post" action="adm_config_set.php">
<fieldset>
<legend><span><?php echo lang_get( 'set_configuration_option' ) ?></span></legend>
<?php echo form_security_field( 'adm_config_set' ) ?>
<form id="config_set_form" method="post" action="adm_config_set.php">
<fieldset>
<?php echo form_security_field( 'adm_config_set' ) ?>

<!-- Username -->
<div class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
<label for="config-user-id"><span><?php echo lang_get( 'username' ) ?></span></label>
<span class="select">
<select id="config-user-id" name="user_id">
<option value="<?php echo ALL_USERS; ?>"
<?php check_selected( $t_edit_user_id, ALL_USERS ) ?>>
<?php echo lang_get( 'all_users' ); ?>
</option>
<?php print_user_option_list( 0 ) ?>
</select>
</span>
<span class="label-style"></span>
</div>
<!-- Title -->
<legend><span>
<?php echo lang_get( 'set_configuration_option' ) ?>
</span></legend>

<!-- Username -->
<div class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
<label for="config-user-id"><span><?php echo lang_get( 'username' ) ?></span></label>
<span class="select">
<select id="config-user-id" name="user_id">
<option value="<?php echo ALL_USERS; ?>"
<?php check_selected( $t_edit_user_id, ALL_USERS ) ?>>
<?php echo lang_get( 'all_users' ); ?>
</option>
<?php print_user_option_list( $t_edit_user_id ) ?>
</select>
</span>
<span class="label-style"></span>
</div>

<!-- Project -->
<div class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
@@ -442,7 +451,7 @@ function print_option_list_from_array( $p_array, $p_filter_value ) {
<?php check_selected( $t_edit_project_id, ALL_PROJECTS ); ?>>
<?php echo lang_get( 'all_projects' ); ?>
</option>
<?php print_project_option_list( ALL_PROJECTS, false ) ?>
<?php print_project_option_list( $t_edit_project_id, false ) ?>
</select>
</span>
<span class="label-style"></span>
@@ -464,13 +473,7 @@ function print_option_list_from_array( $p_array, $p_filter_value ) {
<label for="config-type"><span><?php echo lang_get( 'configuration_option_type' ) ?></span></label>
<span class="select">
<select id="config-type" name="type">
<?php
foreach( $t_config_types as $t_key => $t_type ) {
echo '<option value="' . $t_key . '" ';
check_selected( $t_key, $t_edit_type );
echo ">$t_type</option>";
}
?>
<?php print_option_list_from_array( $t_config_types, $t_edit_type ); ?>
</select>
</span>
<span class="label-style"></span>
@@ -491,7 +494,9 @@ function print_option_list_from_array( $p_array, $p_filter_value ) {
<span class="submit-button"><input type="submit" name="config_set" class="button" value="<?php echo lang_get( 'set_configuration_option' ) ?>" /></span>
</fieldset>
</form>
</div><?php
</div>

<?php
} # end user can change config

html_page_bottom();
5 changes: 3 additions & 2 deletions core/database_api.php
Original file line number Diff line number Diff line change
@@ -367,8 +367,9 @@ function db_query_bound( $p_query, $arr_parms = null, $p_limit = -1, $p_offset =
$i++;
}
}
log_event( LOG_DATABASE, array( $p_query, $t_elapsed), debug_backtrace() );
array_push( $g_queries_array, array( $p_query, $t_elapsed ) );
$t_log_msg = array( $p_query, $t_elapsed );
log_event( LOG_DATABASE, $t_log_msg, debug_backtrace() );
array_push( $g_queries_array, $t_log_msg );
} else {
array_push( $g_queries_array, array( '', $t_elapsed ) );
}
2 changes: 1 addition & 1 deletion core/logging_api.php
Original file line number Diff line number Diff line change
@@ -90,7 +90,7 @@ function log_event( $p_level, $p_msg, $p_backtrace = null ) {
$t_now = date( config_get_global( 'complete_date_format' ) );
$t_level = $g_log_levels[$p_level];

$t_plugin_event = '[' . $t_level . '] ' . $p_msg;
$t_plugin_event = '[' . $t_level . '] ' . $s_msg;
if( function_exists( 'event_signal' ) )
event_signal( 'EVENT_LOG', array( $t_plugin_event ) );