Commit: a4630841643fe47352a20de31271b43089bb56d8 Author: Sobak <[email protected]> Sun, 18 May 2014 07:04:50 +0200 Parents: 571c3f010dda96b93887f66ea9a7c5e72611a7cf Branches: master
Link: http://git.php.net/?p=web/bugs.git;a=commitdiff;h=a4630841643fe47352a20de31271b43089bb56d8 Log: Omit empty parameters in URL Changed paths: M www/index.php M www/search.php Diff: diff --git a/www/index.php b/www/index.php index 967fcbd..044f2bc 100644 --- a/www/index.php +++ b/www/index.php @@ -89,7 +89,7 @@ to a random open bug.</p> <p>Common searches</p> <ul> <?php - $base_default = "{$site_method}://{$site_url}/search.php?boolean=0&limit=30&order_by=id&direction=DESC&cmd=display&status=Open&bug_age=0&bug_updated=0"; + $base_default = "{$site_method}://{$site_url}/search.php?limit=30&order_by=id&direction=DESC&cmd=display&status=Open"; $searches = array( 'Most recent open bugs (all)' => '&bug_type=All', diff --git a/www/search.php b/www/search.php index 0eafc33..c0ec9c1 100644 --- a/www/search.php +++ b/www/search.php @@ -1,6 +1,6 @@ <?php -// Start session +// Start session session_start(); // Obtain common includes @@ -59,32 +59,45 @@ if (isset($_GET['cmd']) && $_GET['cmd'] == 'display') } } - $link_params = - '&search_for=' . urlencode($search_for) . - '&project=' . urlencode($project) . - '&php_os=' . urlencode($php_os) . - "&php_os_not=$php_os_not" . - '&author_email='. urlencode($author_email) . - '&bug_type=' . urlencode($bug_type) . - "&boolean=$boolean_search" . - "&bug_age=$bug_age" . - "&bug_updated=$bug_updated" . - "&order_by=$order_by" . - "&direction=$direction" . - "&limit=$limit" . - '&phpver=' . urlencode($phpver) . - '&cve_id=' . urlencode($cve_id) . - "&cve_id_not=$cve_id_not" . - '&patch=' . urlencode($patch) . - '&pull=' . urlencode($pull) . - '&assign=' . urlencode($assign); - + $link_params = [ + 'search_for' => urlencode($search_for), + 'project' => urlencode($project), + 'php_os' => urlencode($php_os), + 'php_os_not' => $php_os_not, + 'author_mail' => urlencode($author_email), + 'bug_type' => urlencode($bug_type), + 'boolean' => $boolean_search, + 'bug_age' => $bug_age, + 'bug_updated' => $bug_updated, + 'order_by' => $order_by, + 'direction' => $direction, + 'limit' => $limit, + 'phpver' => urlencode($phpver), + 'cve_id' => urlencode($cve_id), + 'cve_id_not' => $cve_id_not, + 'patch' => urlencode($patch), + 'pull' => urlencode($pull), + 'assign' => urlencode($assign) + ]; + if ($is_security_developer) { - $link_params .= "&private=$private"; + $link_params[] = ['private' => $private]; + } + + // Remove empty URL parameters + foreach ($link_params as $index => $param) { + if (empty($param)) + unset($link_params[$index]); + } + + // Create link params string + $link_params_string = ''; + foreach ($link_params as $index => $param) { + $link_params_string .= "&$index=$param"; } - $link = "search.php?cmd=display{$package_name_string}{$package_nname_string}{$link_params}"; - $clean_link = "search.php?cmd=display{$link_params}"; + $link = "search.php?cmd=display{$package_name_string}{$package_nname_string}{$link_params_string}"; + $clean_link = "search.php?cmd=display{$link_params_string}"; if (isset($_GET['showmenu'])) { $link .= '&showmenu=1'; -- PHP Webmaster List Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
