Add a few entries to a database module
Make sure to include ##more## in your template so that you can see the more icon.
Click on "view as list"
Change the "Sort by" column and make sure that the first entry is different to the default. (clicking "Descending" should work)
Click on any of the "more" icons
It takes you to the correct page with the entry details
It takes to a page with details of some random entry.
Because of this issue all the databases on moodle.org are completely useless, such as Moodle Jobs, Moodle Buzz etc
For example http://moodle.org/mod/data/view.php?d=50 , try accessing any package from that url.