summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/gallery/helpers/item.php5
-rw-r--r--modules/image_block/helpers/image_block_block.php2
2 files changed, 2 insertions, 5 deletions
diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php
index 43c93225..bbbe1058 100644
--- a/modules/gallery/helpers/item.php
+++ b/modules/gallery/helpers/item.php
@@ -209,17 +209,14 @@ class item_Core {
/**
* Return a query to get a random Item_Model, with optional filters
- *
- * @param array (optional) where tuple
*/
- static function random_query($where=null) {
+ static function random_query() {
// Pick a random number and find the item that's got nearest smaller number.
// This approach works best when the random numbers in the system are roughly evenly
// distributed so this is going to be more efficient with larger data sets.
return ORM::factory("item")
->viewable()
->where("rand_key", "<", ((float)mt_rand()) / (float)mt_getrandmax())
- ->merge_where($where)
->order_by("rand_key", "DESC");
}
} \ No newline at end of file
diff --git a/modules/image_block/helpers/image_block_block.php b/modules/image_block/helpers/image_block_block.php
index 51ccc4a0..da6e8782 100644
--- a/modules/image_block/helpers/image_block_block.php
+++ b/modules/image_block/helpers/image_block_block.php
@@ -31,7 +31,7 @@ class image_block_block_Core {
// @todo Consider another fallback if further optimizations are necessary.
$attempts = 0;
do {
- $item = item::random_query(array(array("type", "!=", "album")))->find_all(1)->current();
+ $item = item::random_query()->where("type", "!=", "album")->find_all(1)->current();
} while (!$item && $attempts++ < 3);
if ($item && $item->loaded()) {
$block = new Block();