TIP: Use Markdown or, <pre> for multi line code blocks / <code> for inline code.
These forums are read-only and for archival purposes only!
Please join our new forums at discourse.kohanaframework.org
Codebench throws "Division by zero" Warning - ErrorException
  • Hi there,

    today I played around a bit with the Codebench (KO 3.0.7). I tried a few different ways of getting the timespan between two dates - And somehow this code here leads to an "ErrorException [ Warning ]: Division by zero":

    public static function newspan($start, $end = NULL)
    {
    $startdate = new DateTime($start);
    $enddate = new DateTime($end);
    return $startdate->diff($enddate)->format('%Y');
    }


    Funny thing is, the warning is ONLY thrown by that method...
    image

    Is this a known Bug? I just wanted to check, before posting this as ticket :)
  • Funny! The method is so fast on your machine that it doesn't even register a time! [File an issue](http://dev.kohanaframework.org/projects/kohana3/issues), please.
  • Alright, will do this afternoon (stuck on my gsm for the next hours)!
    I was wondering why the date helper doesn't use the datetime object more often... Just like in the Date::span method...

    I'll try to fix the "division by zero" error on my machine and give an update ...

    [edit]
    Ticket postet: http://dev.kohanaframework.org/issues/3229
  • Sorry for bumping this old thread but I also got division by error lately (3.0.8) using profiler. I don't know if it is related to codebench but if it is then it is already solved last month.

    Sometimes it appears, sometimes not. It appears when I have database queries on the profiler but I have to check it again tonight.

    The error appears on the view and not in the module.
  • Could you post your exception + stacktrace?
  • I'll post it tomorrow. Hope I can reproduce it again (Yesterday I can reproduce by just refreshing several times)
  • I have reproduced the error 2 days ago and also last night.

    Here is the stack trace: http://blog.lysender.com/samples/kohana-error-divzero.html
    And the source html just in case my site goes down: http://lysender.pastebin.com/caB3f1uE

    System:

    Kohana 3.0.8
    Linux
    PHP 5.2.14
    Apache/2.2.16 (Unix) DAV/2 PHP/5.2.14
    On a laptop

    the stats.php in APPPATH/views/profiler/stats.php is taken from SYSPATH/views/profiler/stats.php except that I removed the inclusion of style.css, instead I include that css on my template header. I'm sure about it since I run diff before I take the stack trace.

    The error appears like once every 3-5 refresh with or without db calls in both Firefox and Google Chrome.
  • @lysender, that's actually a different problem. That's the Kohana profiler not the codebench module. Can you please open an issue so this gets fixed in the next release?
  • Ah, sorry for that. Okay I'll open an issue.
  • I'm sorry to bump this thread too but I've got the same problem that Lysender (profiler/stats).

    Kohana 3.0.8 & Kohana 3.0.9
    Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny9

    EDIT: (My account is disabled on Kohana Development. Can not access (even changing the password).
    Can someone let me in. Many thanks) => OK My fault
  • I am also getting this error w/KO3.2, ErrorException [ Warning ]: Division by zero, but only when I turn profiling on in the database config.

    2012-02-07 19:08:19 --- ERROR: ErrorException [ 2 ]: Division by zero ~ SYSPATH/views/profiler/stats.php [ 50 ]

    2012-02-07 19:08:19 --- STRACE: ErrorException [ 2 ]: Division by zero ~ SYSPATH/views/profiler/stats.php [ 50 ]

    0 /web/sites/webquest/appleseed/kohana/system/views/profiler/stats.php(50): Kohana_Core::error_handler('/web/sites/webq...', Array)

    1 /web/sites/webquest/appleseed/kohana/system/classes/kohana/view.php(61): include('/web/sites/webq...')

    2 /web/sites/webquest/appleseed/kohana/system/classes/kohana/view.php(343): Kohana_View::capture()

    3 /web/sites/webquest/appleseed/kohana/system/classes/kohana/view.php(228): Kohana_View->render()

    4 /web/sites/webquest/appleseed/application/classes/controller/base.php(49): Kohana_View->__toString()

    5 [internal function]: Controller_Base->after(Object(Controller_Welcome))

    6 /web/sites/webquest/appleseed/kohana/system/classes/kohana/request/client/internal.php(121): ReflectionMethod->invoke(Object(Request))

    7 /web/sites/webquest/appleseed/kohana/system/classes/kohana/request/client.php(64): Kohana_Request_Client_Internal->execute_request(Object(Request))

    8 /web/sites/webquest/appleseed/kohana/system/classes/kohana/request.php(1138): Kohana_Request_Client->execute()

    9 /web/sites/webquest/appleseed/web-root/index.php(109): Kohana_Request->execute()

    10 {main}

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion