Opened 15 years ago
Closed 15 years ago
#974 closed Defect (fixed)
notify.php gives error if nothing to notify - bug in underlying db functions
Reported by: | Nicolas | Owned by: | davea |
---|---|---|---|
Priority: | Minor | Milestone: | Undetermined |
Component: | Web - Project | Version: | |
Keywords: | Cc: |
Description
yoyo reported getting this in the log of a new project, with no user subscribed to get delayed forum/PM notifications:
PHP Notice: Undefined variable: x in /home/boincadm/projects/rnaworld/html/inc/db_conn.inc on line 90 PHP Warning: Invalid argument supplied for foreach() in /home/boincadm/projects/rnaworld/html/ops/notify.php on line 69
The problem is that if a query in enum_general
returns 0 rows, the local variable $x
inside that function is never set at all, so it returns NULL. The following patch makes it return an empty array instead:
-
html/inc/db_conn.inc
83 83 function enum_general($classname, $query) { 84 84 $result = $this->do_query($query); 85 85 if (!$result) return null; 86 $x = array(); 86 87 while ($obj = mysql_fetch_object($result, $classname)) { 87 88 $x[] = $obj; 88 89 }
Note: See
TracTickets for help on using
tickets.
(In [20178]) - web DB code: fix PHP warning when enumeration returns nothing.