Forums / Bug Reports / [Done 2.0.0] removing pointless memory expansion: $value = $val and notice alert

[Done 2.0.0] removing pointless memory expansion: $value = $val and notice alert

Locked

Started by djmaze on 27 May 2008, 1:40 PM · Views: 1,994

Results 1 to 1 of 1
This thread is locked. New replies are disabled.
27 May 2008, 1:40 PM
#1
djmaze avatar

djmaze

New Zenner

Join Date:
Apr 2004
Location:
Netherlands
Posts:
6
Plugin Contributions:
0

[Done 2.0.0] removing pointless memory expansion: $value = $val and notice alert

Somehow i keep finding bugs all over the place, but no worries. I will post fixes here once a while ;)

includes/functions/sessions.php
Notice: Object of class queryFactoryResult could not be converted to int in a_file.php on line 227

Sure it's a notice and you might think "who cares", but did you know this returns 0 (false) although _sess_write() was succesfull and therefore tells PHP the session wasn't written?

fixes:

  1. removed the useless memory expansion: $value = $val
  2. fixed the notice
    function _sess_write($key, $value) {
      global $db;
      if (!is_object($db)) {
        //PHP 5.2.0 bug workaround ...
        $db = new queryFactory();
        $db->connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE, USE_PCONNECT, false);
      }

      global $SESS_LIFE;

      $expiry = time() + $SESS_LIFE;

      $qid = "select count(*) as total
              from " . TABLE_SESSIONS . "
              where sesskey = '" . zen_db_input($key) . "'";

      $result = $db->Execute($qid);

      if ($result->fields['total'] > 0) {
        $sql = "update " . TABLE_SESSIONS . "
                set expiry = '" . zen_db_input($expiry) . "', value = '" . zen_db_input($value) . "'
                where sesskey = '" . zen_db_input($key) . "'";

        $result = $db->Execute($sql);

      } else {
        $sql = "insert into " . TABLE_SESSIONS . "
                values ('" . zen_db_input($key) . "', '" . zen_db_input($expiry) . "', '" .
                         zen_db_input($value) . "')";

        $result = $db->Execute($sql);

      }
	  return (!empty($result) && !empty($result->resource));
    }