Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix yourls_api_stats() with filter==rand #2519

Merged
merged 1 commit into from Mar 25, 2019

Conversation

Projects
None yet
3 participants
@ozh
Copy link
Member

commented Mar 24, 2019

Fixes #2516

@@ -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;" );

This comment has been minimized.

Copy link
@LeoColomb

LeoColomb Mar 24, 2019

Member

What is the idea behind WHERE 1=1?

(introduced here)

This comment has been minimized.

Copy link
@dgw

dgw Mar 24, 2019

Member

It would make sense if this query also had a $where_filter (or whatever) value interpolated into it that might or might not contain additional conditions. Having it anyway is harmless (essentially zero effect on query execution time), but doesn't appear to serve any purpose in this particular case.

This comment has been minimized.

Copy link
@ozh

ozh Mar 25, 2019

Author Member

It has always been there (see in 2009...).

I guess it's either because at this time I couldn't dare writing an SQL clause without a WHERE, or because at this time there were supposed to be potential troubles omitting this WHERE, either with MySQL or other DB engines.

I think it's also for readability to clearly specify this query DOESNT have a WHERE clause

@dgw

dgw approved these changes Mar 24, 2019

@ozh ozh merged commit 6ae4a44 into master Mar 25, 2019

3 checks passed

Scrutinizer No new issues
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@LeoColomb LeoColomb deleted the issue2516 branch Mar 25, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.