Subscribe

Bug with pData.class.php

  1. 2009-08-31 16:31:26 PDT
    I found a small bug on line 127 of pData.class.php
    It only causes a problem on some systems though (I think its down to the level of PHP error reporting)

    function AddPoint($Value,$Serie="Serie1",$Description="")
    {
    if (is_array($Value) && count($Value) == 1)
    $Value = $Value[0];

    $ID = 0;
    for($i=0;$i<=count($this->Data);$i++)
    // GT Fix - added isset($this->Data[$i]) && to if statement below
    // otherwise you get Notice: Uninitialized string offset: 0 in /home/citri/public_html/moodle/blocks/mis_gateway/lib/pchart/pChart/pData.class.php on line 127
    { if(isset($this->Data[$i]) && isset($this->Data[$i][$Serie])) { $ID = $i+1; } }

    if ( count($Value) == 1 )
    {
    $this->Data[$ID][$Serie] = $Value;
    if ( $Description != "" )
    $this->Data[$ID]["Name"] = $Description;
    elseif (!isset($this->Data[$ID]["Name"]))
    $this->Data[$ID]["Name"] = $ID;
    }
    else
    {
    foreach($Value as $key => $Val)
    {
    $this->Data[$ID][$Serie] = $Val;
    if (!isset($this->Data[$ID]["Name"]))
    $this->Data[$ID]["Name"] = $ID;
    $ID++;
    }
    }
    }
  2. 2009-09-10 11:01:42 PDT
    That's the same problem as this one: https://sourceforge.net/forum/forum.php?thread_id=3314907&forum_id=822590

    The following changes should fix it. In /pChart/pData.class, change: (~line 55)
    $this->Data = "";
    to
    $this->Data = array();

    That should fix the error. While you're there, you may as well do the same for $this->DataDescription, initialize it with an array(). (~line 56)
Jump To:
< Previous | 1 | Next >

Add a Reply

This forum does not allow anonymous participation.

Log in to add a reply. Not registered? Create an account to participate and receive email updates when replies are posted to this topic.