1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-05 06:07:32 +02:00

Bugtracker #4357 - reduce re-use of DB objects to avoid corruption

This commit is contained in:
e107steved
2008-05-25 15:32:06 +00:00
parent 3d8ac48c3e
commit 395422059d
2 changed files with 11 additions and 9 deletions

View File

@@ -2,7 +2,7 @@
//EXAMPLE: {EXTENDED=user_gender.value.5} will show the value of the extended field user_gender for user #5 //EXAMPLE: {EXTENDED=user_gender.value.5} will show the value of the extended field user_gender for user #5
include(e_LANGUAGEDIR.e_LANGUAGE."/lan_user_extended.php"); include(e_LANGUAGEDIR.e_LANGUAGE."/lan_user_extended.php");
$parms = explode(".", $parm); $parms = explode(".", $parm);
global $currentUser, $sql, $tp, $loop_uid, $e107, $imode, $sc_style; global $currentUser, $tp, $loop_uid, $e107, $imode, $sc_style;
if(isset($loop_uid) && intval($loop_uid) == 0) { return ""; } if(isset($loop_uid) && intval($loop_uid) == 0) { return ""; }
$key = $parms[0].".".$parms[1]; $key = $parms[0].".".$parms[1];
$sc_style['USER_EXTENDED']['pre'] = (isset($sc_style['USER_EXTENDED'][$key]['pre']) ? $sc_style['USER_EXTENDED'][$key]['pre'] : ""); $sc_style['USER_EXTENDED']['pre'] = (isset($sc_style['USER_EXTENDED'][$key]['pre']) ? $sc_style['USER_EXTENDED'][$key]['pre'] : "");
@@ -96,9 +96,10 @@ if ($parms[1] == 'value')
// check for db_lookup type // check for db_lookup type
case EUF_DB_FIELD : case EUF_DB_FIELD :
$tmp = explode(",",$ueStruct["user_".$parms[0]]['user_extended_struct_values']); $tmp = explode(",",$ueStruct["user_".$parms[0]]['user_extended_struct_values']);
if($sql->db_Select($tmp[0],"{$tmp[1]}, {$tmp[2]}","{$tmp[1]} = '{$uVal}'")) $sql_ue = new db; // Use our own DB object to avoid conflicts
if($sql_ue->db_Select($tmp[0],"{$tmp[1]}, {$tmp[2]}","{$tmp[1]} = '{$uVal}'"))
{ {
$row = $sql->db_Fetch(); $row = $sql_ue->db_Fetch();
$ret_data = $row[$tmp[2]]; $ret_data = $row[$tmp[2]];
} }
else else
@@ -106,7 +107,7 @@ if ($parms[1] == 'value')
$ret_data = FALSE; $ret_data = FALSE;
} }
break; break;
case EUF_DATE ; //check for 0000-00-00 in date field case EUF_DATE : //check for 0000-00-00 in date field
if($uVal == "0000-00-00") { $uVal = ""; } if($uVal == "0000-00-00") { $uVal = ""; }
$ret_data = $uVal; $ret_data = $uVal;
break; break;

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_handlers/user_extended_class.php,v $ | $Source: /cvs_backup/e107_0.8/e107_handlers/user_extended_class.php,v $
| $Revision: 1.11 $ | $Revision: 1.12 $
| $Date: 2008-04-06 21:38:02 $ | $Date: 2008-05-25 15:31:58 $
| $Author: e107steved $ | $Author: e107steved $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -443,16 +443,17 @@ class e107_user_extended
{ {
return $ueStruct; return $ueStruct;
} }
global $sql, $tp; global $tp;
$ret = array(); $ret = array();
$parms = ""; $parms = "";
if($orderby != "") if($orderby != "")
{ {
$parms = "1 ORDER BY ".$tp -> toDB($orderby, true); $parms = "1 ORDER BY ".$tp -> toDB($orderby, true);
} }
if($sql->db_Select('user_extended_struct','*',$parms)) $sql_ue = new db; // Use our own db to avoid interference with other objects
if($sql_ue->db_Select('user_extended_struct','*',$parms))
{ {
while($row = $sql->db_Fetch()) while($row = $sql_ue->db_Fetch())
{ {
$ret['user_'.$row['user_extended_struct_name']] = $row; $ret['user_'.$row['user_extended_struct_name']] = $row;
} }