Huh.  Well maybe instead of using a floating point we should just use an
integer?  Floats are always a pain in the ass - it's unclear to me why we
used them.  Have to audit the code to see if there's any specific place
where we're treating it like a percentage...


On Tue, Jun 25, 2013 at 2:24 PM, Shad Laws <notifications@github.com> wrote:

> In modules/gallery/classes/Gallery/Model/Item.php:
>
> > @@ -27,7 +27,7 @@ public function __construct($id=null) {
> >      if (!$this->loaded()) {
> >        // Set reasonable defaults
> >        $this->created = time();
> > -      $this->rand_key = Random::percent();
> > +      $this->rand_key = sprintf("%f", Random::percent());  // sprintf to prevent things like 2.1E-6
>
> A float is a float is a float? Totally unreasonable assumption :-)
>
> Two things to consider:
>
>    - If it goes as 2.1E-6, the Model_Item validation will bomb (which is
>    how I noticed it). This can be rewritten, of course.
>    - Does MySQL like making comparisons with floats? In other words, if
>    we ask it to find < 0.1, will it find 0.0000021 and 2.1e-6?
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/gallery/gallery3/pull/430/files#r4878244>
> .
>