summaryrefslogtreecommitdiff
path: root/modules/gallery/models/item.php
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2010-12-15 14:57:00 -0800
committerBharat Mediratta <bharat@menalto.com>2010-12-15 14:57:00 -0800
commitcd48b89f3166e7fa732b5cb06d33fba018af9127 (patch)
tree9ad981df0d736dc186463aac4676fdba2bc232b8 /modules/gallery/models/item.php
parent45c63f4d118bfc99924edb8685442035349af6db (diff)
Consolidate all the random code into a random helper that offers:
random::hash() random::string() random::percent() random::int() So that we don't have lots of different ways to get random values all over the code. Follow-on to #1527.
Diffstat (limited to 'modules/gallery/models/item.php')
-rw-r--r--modules/gallery/models/item.php6
1 files changed, 3 insertions, 3 deletions
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index b6713fc3..ad577066 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -28,7 +28,7 @@ class Item_Model_Core extends ORM_MPTT {
if (!$this->loaded()) {
// Set reasonable defaults
$this->created = time();
- $this->rand_key = ((float)mt_rand()) / (float)mt_getrandmax();
+ $this->rand_key = random::percent();
$this->thumb_dirty = 1;
$this->resize_dirty = 1;
$this->sort_column = "created";
@@ -390,7 +390,7 @@ class Item_Model_Core extends ORM_MPTT {
if (file_exists($this->resize_path()) ||
file_exists($this->thumb_path())) {
$pi = pathinfo($this->name);
- $this->name = $pi["filename"] . "-" . mt_rand() . "." . $pi["extension"];
+ $this->name = $pi["filename"] . "-" . random::int() . "." . $pi["extension"];
parent::save();
}
@@ -512,7 +512,7 @@ class Item_Model_Core extends ORM_MPTT {
->or_where("slug", "=", $this->slug)
->close()
->find()->id) {
- $rand = mt_rand();
+ $rand = random::int();
if ($base_ext) {
$this->name = "$base_name-$rand.$base_ext";
} else {