Skip to content

Commit 10025b3

Browse files
committed
Add 'type' param to Source_FilterOption_Permalink()
This allows parameters' initalization in Source_Generate_Filter() to specifically handle integers (before this, all parameters were treated as strings, with special handling for the 2 date fields). Fixes #207
1 parent 3dbec81 commit 10025b3

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

Source/Source.FilterAPI.php

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -282,21 +282,22 @@ function Source_Process_FilterOption( $key, $option ) {
282282
function Source_Generate_Filter() {
283283
# Get form inputs
284284
$f_repo_type = Source_FilterOption_Permalink( 'repo_type', true );
285-
$f_repo_id = Source_FilterOption_Permalink( 'repo_id', true );
285+
$f_repo_id = Source_FilterOption_Permalink( 'repo_id', true, 'int' );
286286
$f_branch = Source_FilterOption_Permalink( 'branch', true );
287287
$f_file_action = Source_FilterOption_Permalink( 'file_action', true );
288288
$f_ported = Source_FilterOption_Permalink( 'ported', true );
289289

290290
$f_revision = Source_FilterOption_Permalink( 'revision' );
291291
$f_author = Source_FilterOption_Permalink( 'author' );
292-
$f_user_id = Source_FilterOption_Permalink( 'user_id' );
293-
$f_bug_id = Source_FilterOption_Permalink( 'bug_id' );
292+
$f_user_id = Source_FilterOption_Permalink( 'user_id', false, 'int' );
293+
$f_bug_id = Source_FilterOption_Permalink( 'bug_id', false, 'int' );
294+
294295

295296
$f_filename = Source_FilterOption_Permalink( 'filename' );
296297
$f_message = Source_FilterOption_Permalink( 'message' );
297298

298-
$f_date_start = Source_FilterOption_Permalink( 'date_start' );
299-
$f_date_end = Source_FilterOption_Permalink( 'date_end' );
299+
$f_date_start = Source_FilterOption_Permalink( 'date_start', false, 'date' );
300+
$f_date_end = Source_FilterOption_Permalink( 'date_end', false, 'date' );
300301

301302
# Get permalink
302303
$t_permalink = Source_FilterOption_Permalink();
@@ -361,7 +362,7 @@ function Source_Date_Validate( $p_string, $p_end_of_day=false ) {
361362
}
362363
}
363364

364-
function Source_FilterOption_Permalink( $p_string=null, $p_array=false ) {
365+
function Source_FilterOption_Permalink( $p_string=null, $p_array=false, $p_type='string' ) {
365366
static $s_permalink = '';
366367

367368
if ( is_null( $p_string ) ) {
@@ -371,7 +372,11 @@ function Source_FilterOption_Permalink( $p_string=null, $p_array=false ) {
371372
}
372373

373374
if ( $p_array ) {
374-
$t_input = gpc_get_string_array( $p_string, array() );
375+
if( $p_type == 'int') {
376+
$t_input = gpc_get_int_array( $p_string, array() );
377+
} else {
378+
$t_input = gpc_get_string_array( $p_string, array() );
379+
}
375380
$t_input_clean = array();
376381

377382
if ( is_array( $t_input ) && count( $t_input ) > 0 ) {
@@ -384,10 +389,18 @@ function Source_FilterOption_Permalink( $p_string=null, $p_array=false ) {
384389
}
385390

386391
} else {
387-
$t_input_clean = gpc_get_string( $p_string, null );
388-
389-
if ( $p_string == 'date_start' || $p_string == 'date_end' ) {
390-
$t_input_clean = Source_Date_Validate( $p_string, $p_string == 'date_end' );
392+
switch( $p_type ) {
393+
case 'int':
394+
$t_input_clean = gpc_get_int( $p_string, 0 );
395+
if( $t_input_clean == 0) {
396+
$t_input_clean = null;
397+
}
398+
break;
399+
case 'date':
400+
$t_input_clean = Source_Date_Validate( $p_string, $p_string == 'date_end' );
401+
break;
402+
default:
403+
$t_input_clean = gpc_get_string( $p_string, null );
391404
}
392405

393406
if ( !is_blank( $t_input_clean ) ) {

0 commit comments

Comments
 (0)