pamelanye / libstats

Automatically exported from code.google.com/p/libstats
GNU General Public License v2.0
1 stars 0 forks source link

Error Checking on Reports with No Results #12

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Do a report with a timeframe that will yield no results.
2. Get PHP warning errors

What is the expected output? What do you see instead?
Shouldn't show errors, but just a blank table. Errors are usually the
following (line numbers may be different):

Notice: Undefined offset: 0 in
C:\xampplite\htdocs\libstats\reports\ByInitials.php on line 43

Warning: array_keys() expects parameter 1 to be array, null given in
C:\xampplite\htdocs\libstats\reports\ByInitials.php on line 43

Warning: Cannot modify header information - headers already sent by (output
started at C:\xampplite\htdocs\libstats\reports\ByInitials.php:43) in
C:\xampplite\htdocs\libstats\ControllerFunctions.php on line 135

What version of the product are you using? On what operating system?
1.0.6 plus reports fix. WinXP with XAMPP 1.7.3 Lite.

Please provide any additional information below.
Suggest more error checking on the returned results. I'm using the
following code at line 45:

if (PEAR::isError($result["data"])) {
    //custom util function. use your own error logging here
    //dumpToFile($result["data"]->getMessage());
} else {
    if (count($result['data']) > 0) $result['metadata'] =
array_keys($result['data'][0]);
    return $result;
}

Also, for some reports, I've found the following bit of code necessary to
prevent further processing of empty results and thus more errors. At about
line 65:

if (!$rInfo['reportResults']["data"]) {
    print "<br />No Results!<br /><br />";
    return;
}

Original issue reported on code.google.com by greenwoo...@gmail.com on 15 Apr 2010 at 2:24

GoogleCodeExporter commented 8 years ago
As we use LibStats more, we're also seeing this null date input error.   Has 
anyone engineering a fix?   I'll try but not being a PHP guy, I'm afraid the 
learning curve will be steep.   Any suggestions or assistance is welcome.

Gary

Original comment by gary...@gmail.com on 29 Jun 2011 at 10:08