We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30585
    • 833 Posts
    Hi folks,

    I got a bunch of warnings in the manager error log about a division by zero caused by the BigBrother extra. I searched the forums, but nothing addresses this.

    Here's the warning:
    [2013-11-24 23:09:28] (ERROR @ /hsphere/local/home/path/mysite.com/core/components/bigbrother/processors/mgr/report/metas.class.php : 72) PHP warning: Division by zero


    Here's what's on line 72-79 of the metas.class.php file.
    $progression = round(($value * 100 / $compare) - 100, 1);
                    if($progression > 0){
                        $progression = '+ '.$progression;
                        $cls = 'up';
                    } elseif($progression < 0){
                        $progression = str_replace('-','- ', $progression);
                        $cls = 'down';
                    }
    


    Any idea how to fix this?

    I'm running Revo 2.2.10 on LAMP
      A MODx Fanatic
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Looks like the $compare value is 0. Apparently some return values are 0. Note how the loop through the report values processes each returned value of the report returned by Google:

      foreach($this->ga->report['totalsForAllResults'] as $key => $v){
                  if( isset( $this->results[$key] ) ){
                      $cls = '';
                      $value = $this->results[$key]['value'];
                      $compare = intval( $v );
                      $progression = round(($value * 100 / $compare) - 100, 1);
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 30585
        • 833 Posts
        Thanks Susan.

        For some reason, I'm no longer getting the percentage stats in the dashboard. I can see the trend curves, but no data beneath.
          A MODx Fanatic
          • 3749
          • 24,544 Posts
          You might try this:

          foreach($this->ga->report['totalsForAllResults'] as $key => $v){
              if( isset( $this->results[$key] ) ){
                  $cls = '';
                  $value = $this->results[$key]['value'];
                  $compare = intval( $v );
                  if ($compare != 0) {
                      $progression = round(($value * 100 / $compare) - 100, 1);
                  }


          I'm not sure how that will affect the output, but it would avoid the error.

          This might be better:

          foreach($this->ga->report['totalsForAllResults'] as $key => $v){
              if( isset( $this->results[$key] ) ){
                  $cls = '';
                  $value = $this->results[$key]['value'];
                  $compare = intval( $v );
                  $compare = ($compare == 0) ? .01 : $compare;
                  $progression = round(($value * 100 / $compare) - 100, 1);
                  
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting