diff options
author | Bharat Mediratta <bharat@menalto.com> | 2010-02-08 15:38:59 -0800 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2010-02-08 15:38:59 -0800 |
commit | 9ca521c71021b43f13950d246a15f6f0da0b7989 (patch) | |
tree | b2435238db3231761efc9245c4627214c9c595db /modules/image_block | |
parent | 6dfab72922bf20104d6032eb292d59c6bd6578ba (diff) | |
parent | 008174859dc25dade593abdf4ce670bc6c7ef332 (diff) |
Merge branch 'master' of github.com:gallery/gallery3
Diffstat (limited to 'modules/image_block')
-rw-r--r-- | modules/image_block/helpers/image_block_block.php | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/modules/image_block/helpers/image_block_block.php b/modules/image_block/helpers/image_block_block.php index 185df850..82c92f19 100644 --- a/modules/image_block/helpers/image_block_block.php +++ b/modules/image_block/helpers/image_block_block.php @@ -26,7 +26,13 @@ class image_block_block_Core { $block = ""; switch ($block_id) { case "random_image": - $item = item::random_query(array(array("type", "!=", "album")))->find_all(1)->current(); + // The random_query approach is flawed and doesn't always return a + // result when there actually is one. Retry a *few* times. + // @todo Consider another fallback if further optimizations are necessary. + $attempts = 0; + do { + $item = item::random_query(array(array("type", "!=", "album")))->find_all(1)->current(); + } while (!$item && $attempts++ < 3); if ($item && $item->loaded()) { $block = new Block(); $block->css_id = "g-image-block"; |