Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 3 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Commits on Oct 27, 2013
@dregad dregad Fix data type mismatch when filtering by date
Follow-up on commit 1a417b1 which did
not cover all possible cases for the error.

We now consistently store the 'filter by date' property as a boolean,
and rely on gpc_string_to_bool() to ensure any string we get (e.g. 1,
'on', 'true') is properly converted to boolean before comparing. We
therefore no longer need the ternary operator in view_all_set.php. We
use 'on'/'off' when encoding the filter only.

Fixes #16516
380b5de
@dregad dregad Whitespace b02a50e
@dregad dregad Fix 'Sticky' property reset to 'No' when applying filter
Fixes #16540
bdb6e9a
Showing with 34 additions and 31 deletions.
  1. +14 −6 core/filter_api.php
  2. +20 −25 view_all_set.php
View
20 core/filter_api.php
@@ -177,7 +177,10 @@ function filter_get_url( $p_custom_filter ) {
}
if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_STICKY] ) ) {
- $t_query[] = filter_encode_field_and_value( FILTER_PROPERTY_STICKY, $p_custom_filter[FILTER_PROPERTY_STICKY] );
+ $t_query[] = filter_encode_field_and_value(
+ FILTER_PROPERTY_STICKY,
+ $p_custom_filter[FILTER_PROPERTY_STICKY] ? 'on' : 'off'
+ );
}
if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_VERSION] ) ) {
@@ -221,7 +224,10 @@ function filter_get_url( $p_custom_filter ) {
}
if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_FILTER_BY_DATE] ) ) {
- $t_query[] = filter_encode_field_and_value( FILTER_PROPERTY_FILTER_BY_DATE, $p_custom_filter[FILTER_PROPERTY_FILTER_BY_DATE] );
+ $t_query[] = filter_encode_field_and_value(
+ FILTER_PROPERTY_FILTER_BY_DATE,
+ $p_custom_filter[FILTER_PROPERTY_FILTER_BY_DATE] ? 'on' : 'off'
+ );
# The start and end dates are only applicable if filter by date is set.
if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_START_DAY] ) ) {
@@ -2879,9 +2885,11 @@ function filter_draw_selection_area2( $p_page_number, $p_for_screen = true, $p_e
<td class="small-caption" id="sticky_issues_filter_target">
<?php
$t_sticky_filter_state = gpc_string_to_bool( $t_filter[FILTER_PROPERTY_STICKY] );
- print( $t_sticky_filter_state ? lang_get( 'yes' ) : lang_get( 'no' ) );
- ?>
- <input type="hidden" name="sticky_issues" value="<?php echo $t_sticky_filter_state ? 'on' : 'off';?>" />
+ print( $t_sticky_filter_state ? lang_get( 'yes' ) : lang_get( 'no' ) );
+ ?>
+ <input type="hidden" name="<?php
+ echo FILTER_PROPERTY_STICKY; ?>" value="<?php
+ echo $t_sticky_filter_state ? 'on' : 'off'; ?>" />
</td>
<td class="small-caption" colspan="2" id="highlight_changed_filter_target">
<?php
@@ -3877,7 +3885,7 @@ function print_filter_do_filter_by_date( $p_hide_checkbox = false ) {
<label>
<input type="checkbox" id="use_date_filters" name="<?php
echo FILTER_PROPERTY_FILTER_BY_DATE ?>"<?php
- check_checked( $t_filter[FILTER_PROPERTY_FILTER_BY_DATE], 'on' ) ?> />
+ check_checked( gpc_string_to_bool( $t_filter[FILTER_PROPERTY_FILTER_BY_DATE] ), true ) ?> />
<?php echo lang_get( 'use_date_filters' )?>
</label>
</td>
View
45 view_all_set.php
@@ -238,6 +238,7 @@
$f_per_page = gpc_get_int( FILTER_PROPERTY_ISSUES_PER_PAGE, -1 );
$f_highlight_changed = gpc_get_int( FILTER_PROPERTY_HIGHLIGHT_CHANGED, config_get( 'default_show_changed' ) );
$f_sticky_issues = gpc_get_bool( FILTER_PROPERTY_STICKY );
+
# sort direction
$f_sort_d = gpc_get_string( FILTER_PROPERTY_SORT_FIELD_NAME, '' );
$f_dir_d = gpc_get_string( FILTER_PROPERTY_SORT_DIRECTION, '' );
@@ -247,6 +248,7 @@
$f_dir_1 = gpc_get_string( FILTER_PROPERTY_SORT_DIRECTION . '_1', '' );
# date values
+$f_do_filter_by_date = gpc_get_bool( FILTER_PROPERTY_FILTER_BY_DATE );
$f_start_month = gpc_get_int( FILTER_PROPERTY_START_MONTH, date( 'm' ) );
$f_end_month = gpc_get_int( FILTER_PROPERTY_END_MONTH, date( 'm' ) );
$f_start_day = gpc_get_int( FILTER_PROPERTY_START_DAY, 1 );
@@ -254,7 +256,6 @@
$f_start_year = gpc_get_int( FILTER_PROPERTY_START_YEAR, date( 'Y' ) );
$f_end_year = gpc_get_int( FILTER_PROPERTY_END_YEAR, date( 'Y' ) );
$f_search = gpc_get_string( FILTER_PROPERTY_SEARCH, '' );
-$f_do_filter_by_date = gpc_get_bool( FILTER_PROPERTY_FILTER_BY_DATE );
$f_view_state = gpc_get_int( FILTER_PROPERTY_VIEW_STATE, META_FILTER_ANY );
$f_tag_string = gpc_get_string( FILTER_PROPERTY_TAG_STRING, '' );
@@ -360,9 +361,6 @@
$f_type = 1;
}
-$f_do_filter_by_date = $f_do_filter_by_date ? 'on' : 'off';
-$f_sticky_issues = $f_sticky_issues ? 'on' : 'off';
-
if ( $f_type < 0 ) {
print_header_redirect( 'view_all_bug_page.php' );
}
@@ -571,30 +569,27 @@
$tc_setting_arr = filter_ensure_valid_filter( $t_setting_arr );
-/**
- * Remove any statuses that should be excluded by the hide_status field
- */
+# Remove any statuses that should be excluded by the hide_status field
if( $f_view_type == "advanced" ) {
- if( $tc_setting_arr[FILTER_PROPERTY_HIDE_STATUS][0] > 0 ) {
- $t_statuses = MantisEnum::getValues( config_get( 'status_enum_string' ) );
- foreach( $t_statuses as $t_key=>$t_val ) {
- if( $t_val < $tc_setting_arr[FILTER_PROPERTY_HIDE_STATUS][0] ) {
- $t_keep_statuses[$t_key] = $t_val;
- }
- }
- $tc_setting_arr[FILTER_PROPERTY_STATUS] = $t_keep_statuses;
- }
+ if( $tc_setting_arr[FILTER_PROPERTY_HIDE_STATUS][0] > 0 ) {
+ $t_statuses = MantisEnum::getValues( config_get( 'status_enum_string' ) );
+ foreach( $t_statuses as $t_key=>$t_val ) {
+ if( $t_val < $tc_setting_arr[FILTER_PROPERTY_HIDE_STATUS][0] ) {
+ $t_keep_statuses[$t_key] = $t_val;
+ }
+ }
+ $tc_setting_arr[FILTER_PROPERTY_STATUS] = $t_keep_statuses;
+ }
}
-/**
- * If a status is selected in the status and the hide status field, remove it from
- * hide status
- */
+
+# If a status is selected in the status and the hide_status field,
+# remove it from hide status
if( $f_view_type == "simple" && $tc_setting_arr[FILTER_PROPERTY_HIDE_STATUS][0] > 0 ) {
- foreach( $tc_setting_arr[FILTER_PROPERTY_STATUS] as $t_key => $t_val ) {
- if( $tc_setting_arr[FILTER_PROPERTY_STATUS][$t_key] == $tc_setting_arr[FILTER_PROPERTY_HIDE_STATUS][0] ) {
- unset( $tc_setting_arr[FILTER_PROPERTY_HIDE_STATUS][0] );
- }
- }
+ foreach( $tc_setting_arr[FILTER_PROPERTY_STATUS] as $t_key => $t_val ) {
+ if( $tc_setting_arr[FILTER_PROPERTY_STATUS][$t_key] == $tc_setting_arr[FILTER_PROPERTY_HIDE_STATUS][0] ) {
+ unset( $tc_setting_arr[FILTER_PROPERTY_HIDE_STATUS][0] );
+ }
+ }
}
$t_settings_serialized = serialize( $tc_setting_arr );

No commit comments for this range

Something went wrong with that request. Please try again.