mirror of
https://github.com/e107inc/e107.git
synced 2025-08-02 12:48:26 +02:00
Check variable type during toDB() test. Optimized toDB() for non-string types.
This commit is contained in:
@@ -486,12 +486,14 @@ class e_parse extends e_parser
|
|||||||
*/
|
*/
|
||||||
public function toDB($data = null, $nostrip =false, $no_encode = false, $mod = false, $parm = null)
|
public function toDB($data = null, $nostrip =false, $no_encode = false, $mod = false, $parm = null)
|
||||||
{
|
{
|
||||||
if($data === null)
|
$variableType = gettype($data);
|
||||||
|
|
||||||
|
if(($variableType !== 'string' && $variableType !== 'array' ) || $data === '0')
|
||||||
{
|
{
|
||||||
return null;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($data))
|
if ($variableType === 'array')
|
||||||
{
|
{
|
||||||
$ret = array();
|
$ret = array();
|
||||||
|
|
||||||
@@ -505,16 +507,12 @@ class e_parse extends e_parser
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (MAGIC_QUOTES_GPC == true && $nostrip == false)
|
if (MAGIC_QUOTES_GPC == true && $nostrip == false)
|
||||||
{
|
{
|
||||||
$data = stripslashes($data);
|
$data = stripslashes($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(intval($data) === $data || $data === '0') // simple integer.
|
|
||||||
{
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
$core_pref = e107::getConfig();
|
$core_pref = e107::getConfig();
|
||||||
|
|
||||||
if ($mod !== 'pReFs') //XXX We're not saving prefs.
|
if ($mod !== 'pReFs') //XXX We're not saving prefs.
|
||||||
|
@@ -457,7 +457,7 @@ while($row = $sql->fetch())
|
|||||||
$parm = varset($var['parm']);
|
$parm = varset($var['parm']);
|
||||||
|
|
||||||
$result = $this->tp->toDB($var['input'], false, false, $mode, $parm);
|
$result = $this->tp->toDB($var['input'], false, false, $mode, $parm);
|
||||||
$this->assertEquals($var['expected'], $result, 'Test #'.$k." failed.". print_r($this->tp->getRemoved(),true));
|
$this->assertSame($var['expected'], $result, 'Test #'.$k." failed.". print_r($this->tp->getRemoved(),true));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user