Menu

#23 Patch for random_song_ids() to always get 10 songs

open-accepted
None
5
2005-03-25
2005-01-02
David Ward
No

This patch should resolve the issues of both bug 811042
and bug 764947.

It also should be good enough to resolve the potential
DOS with the FIXME comment in the function.

Instead of picking the first and last song id (two
queries) and randomly selecting 'valid' numbers between
them (more queries) it uses one mysql query with an
rand() orderby. With a db of 15000 songs this appears
to be quite fast, so I don't think performance will be
an issue.

There is also a simple fix in this patch that makes
sure that the number of seconds displayed for the song
length is always 2 digits (the leading 0 was missing
-- 2:6 instead of 2:06).

Discussion

  • David Ward

    David Ward - 2005-01-02

    Random song list on index page should show 10 songs

     
  • Philip Lowman

    Philip Lowman - 2005-03-25
    • status: open --> open-accepted
     
  • Philip Lowman

    Philip Lowman - 2005-03-25

    Logged In: YES
    user_id=78148

    thanks for the patch. I tried it out and it works great for
    fixing both issues. I can't remember why I wasn't using
    ORDER BY RAND() in the first place and the SQL to limit the
    selection to allowed songs.

     
  • Philip Lowman

    Philip Lowman - 2005-03-25
    • assigned_to: nobody --> plowman
     

Log in to post a comment.