Skip to content

Commit

Permalink
Fix yourls_api_stats() with filter==rand
Browse files Browse the repository at this point in the history
  • Loading branch information
ozh committed Mar 24, 2019
1 parent f9e9c03 commit bd6e132
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -571,11 +571,11 @@ function yourls_get_stats( $filter = 'top', $limit = 10, $start = 0 ) {

switch( $filter ) {
case 'bottom':
$sort_by = 'clicks';
$sort_by = '`clicks`';
$sort_order = 'asc';
break;
case 'last':
$sort_by = 'timestamp';
$sort_by = '`timestamp`';
$sort_order = 'desc';
break;
case 'rand':
Expand All @@ -585,7 +585,7 @@ function yourls_get_stats( $filter = 'top', $limit = 10, $start = 0 ) {
break;
case 'top':
default:
$sort_by = 'clicks';
$sort_by = '`clicks`';
$sort_order = 'desc';
break;
}
Expand All @@ -596,7 +596,7 @@ function yourls_get_stats( $filter = 'top', $limit = 10, $start = 0 ) {
if ( $limit > 0 ) {

$table_url = YOURLS_DB_TABLE_URL;
$results = $ydb->fetchObjects( "SELECT * FROM `$table_url` WHERE 1=1 ORDER BY `$sort_by` $sort_order LIMIT $start, $limit;" );
$results = $ydb->fetchObjects( "SELECT * FROM `$table_url` WHERE 1=1 ORDER BY $sort_by $sort_order LIMIT $start, $limit;" );

$return = array();
$i = 1;
Expand Down Expand Up @@ -1063,7 +1063,7 @@ function yourls_upgrade_is_needed() {
// Check if YOURLS_VERSION exist && match value stored in YOURLS_DB_TABLE_OPTIONS, update DB if required
if( $currentver < YOURLS_VERSION )
yourls_update_option( 'version', YOURLS_VERSION );

return false;
}

Expand Down

0 comments on commit bd6e132

Please sign in to comment.