Opened 14 years ago

Closed 14 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

     
    8383    function enum_general($classname, $query) {
    8484        $result = $this->do_query($query);
    8585        if (!$result) return null;
     86        $x = array();
    8687        while ($obj = mysql_fetch_object($result, $classname)) {
    8788            $x[] = $obj;
    8889        }

Change History (1)

comment:1 Changed 14 years ago by davea

Resolution: fixed
Status: newclosed

(In [20178]) - web DB code: fix PHP warning when enumeration returns nothing.

From Nicolas. fixes #974

  • client: tiny code shuffle
Note: See TracTickets for help on using tickets.