From a893c2542eb07c799eb534e23e97c1488000895d Mon Sep 17 00:00:00 2001 From: ozh Date: Thu, 20 Apr 2017 22:01:09 +0200 Subject: [PATCH] Less extract(), less crap, more clarity :wc: --- includes/functions-html.php | 17 ++++++++++++++++- yourls-infos.php | 7 +++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/includes/functions-html.php b/includes/functions-html.php index b4861ea..ba2087e 100644 --- a/includes/functions-html.php +++ b/includes/functions-html.php @@ -193,7 +193,22 @@ function yourls_html_addnew( $url = '', $keyword = '' ) { * @return string Result */ function yourls_html_tfooter( $params = array() ) { - extract( $params ); // extract $search_text, $page, $search_in ... + // Manually extract all parameters from the array. We prefer doing it this way, over using extract(), + // to make things clearer and more explicit about what var is used. + $search = $params['search']; + $search_text = $params['search_text']; + $search_in = $params['search_in']; + $sort_by = $params['sort_by']; + $sort_order = $params['sort_order']; + $page = $params['page']; + $perpage = $params['perpage']; + $click_filter = $params['click_filter']; + $click_limit = $params['click_limit']; + $total_pages = $params['total_pages']; + $date_filter = $params['date_filter']; + $date_first = $params['date_first']; + $date_second = $params['date_second']; + ?> diff --git a/yourls-infos.php b/yourls-infos.php index 4873263..4ce9a82 100644 --- a/yourls-infos.php +++ b/yourls-infos.php @@ -143,10 +143,13 @@ if( yourls_do_log_redirect() ) { // Get $list_of_days, $list_of_months, $list_of_years reset( $dates ); if( $dates ) { - extract( yourls_build_list_of_days( $dates ) ); + $_lists = yourls_build_list_of_days( $dates ); + $list_of_days = $_lists['list_of_days']; + $list_of_months = $_lists['list_of_months']; + $list_of_years = $_lists['list_of_years']; + unset($_lists); } - // *** Last 24 hours : array of $last_24h[ $hour ] = number of click *** $query = "SELECT DATE_FORMAT(DATE_ADD(`click_time`, INTERVAL " . YOURLS_HOURS_OFFSET . " HOUR), '%H %p') AS `time`, -- 2.42.0