Merging fixes and enhancements into trunk.

Revision: [2076]
Correcting a few more bugs found in the CakeSession class

Revision: [2075]
Adding fix fro Ticket #417

Revision: [2074]
Corrected name of method

Revision: [2073]
Added patch submitted by lemp on IRC channel

Revision: [2072]
Added fix for Ticket #418.
Bug fix added for session_destroy();

Revision: [2071]
Updated DboSource::conditions() with regex discussed in IRC channel.
Added --return delimiter to allow returning the value of an array key without
the string being wrapped by $this->Model->value();

It is used like:
    $this->Model->find(array('Model.field' => '--return STRING'))

Revision: [2070]
Changed the DboSource::condition().
New syntax has been added.
By default all conditions are joined using AND.
    array('Model.field' => ' = value','Model.field' => ' > value');
    `Model`.`field` = 'value' AND `Model`.`field` = 'value'

To change this you would add a space CONDITIONAL space to the array key
Incorrect: array('Model.field' => ' = value','OR Model.field' => ' > value');
Correct: array('Model.field' => ' = value',' OR Model.field' => ' > value');

would produce
    `Model`.`field` = 'value' OR `Model`.`field` = 'value'

Change where also made the the value of the key space OPERATION space is now needed.
Incorrect: array('Model.field' => '= value';
Correct: array('Model.field' => ' = value';

git-svn-id: https://svn.cakephp.org/repo/trunk/cake@2077 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2006-02-20 22:19:21 +00:00
parent 4af9614115
commit 27c5a4919a
5 changed files with 101 additions and 57 deletions

View file

@ -6,4 +6,4 @@
// +---------------------------------------------------------------------------------------------------+ //
///////////////////////////////////////////////////////////////////////////////////////////////////////////
0.10.8.2069
0.10.8.2077

View file

@ -379,6 +379,10 @@ class Controller extends Object
$args = func_get_args();
$errors = call_user_func_array(array(&$this, 'validateErrors'), $args);
if ($errors === false)
{
return 0;
}
return count($errors);
}

View file

@ -1045,8 +1045,14 @@ class DboSource extends DataSource
elseif (is_array($conditions))
{
$out = array();
$count = 0;
$operator = null;
foreach ($conditions as $key => $value)
{
if($count > 0)
{
$operator = ' AND ';
}
if (is_array($value))
{
$data = $key . ' IN (';
@ -1060,30 +1066,50 @@ class DboSource extends DataSource
{
$data = ' '. $value;
}
elseif (preg_match('/(?P<expression>LIKE\\x20|=\\x20|>\\x20|<\\x20|<=\\x20|>=\\x20|<>\\x20)(?P<value>.*)/i', $value, $match))
elseif (preg_match('/^(\\x20(?P<operator>[\\w]+|<=?|>=?|<>|!?=)\\x20)?(?P<value>.*)/i', $value, $match))
{
$data = $this->name($key) . ' '.$match['expression'].' '. $this->value($match['value']);
if (preg_match('/(?P<conditional>\\x20[\\w]*\\x20)/', $key, $regs))
{
$operator = $regs['conditional'];
$key = preg_replace('/'.$regs['conditional'].'/', '', $key);
}
if (strpos($match['value'], '--return') === 0)
{
$match['value'] = str_replace('--return', '', $match['value']);
$data = $this->name($key) . ' '.$match['operator'].' '. $match['value'];
}
else
{
$data = $this->name($key) . ' '.$match['operator'].' '. $this->value($match['value']);
}
}
else
{
if (($value != '{$__cakeID__$}') && ($value != '{$__cakeForeignKey__$}'))
{
$value = $this->value($value);
}
$data = $this->name($key) . '=';
if (strpos($value, '--return') === 0)
{
$value = str_replace('--return', '', $value);
}
elseif (($value != '{$__cakeID__$}') && ($value != '{$__cakeForeignKey__$}'))
{
$value = $this->value($value);
}
if ($value === null)
{
$data .= 'null';
}
else
{
$data .= $value;
}
$data = $this->name($key) . ' = ';
if ($value === null)
{
$data .= 'null';
}
else
{
$data .= $value;
}
}
$out[] = $data;
$count++;
$out[] = $operator.$data;
}
return ' WHERE ' . join(' AND ', $out);
return ' WHERE ' . join('', $out);
}
else
{

View file

@ -125,10 +125,7 @@ class CakeSession extends Object
$this->security = CAKE_SECURITY;
session_write_close();
if (!isset($_SESSION))
{
$this->__initSession();
}
$this->__initSession();
session_cache_limiter("must-revalidate");
session_start();
@ -364,28 +361,35 @@ class CakeSession extends Object
switch (CAKE_SESSION_SAVE)
{
case 'cake':
ini_set('session.use_trans_sid', 0);
ini_set('url_rewriter.tags', '');
ini_set('session.serialize_handler', 'php');
ini_set('session.use_cookies', 1);
ini_set('session.name', CAKE_SESSION_COOKIE);
ini_set('session.cookie_lifetime', $this->cookieLifeTime);
ini_set('session.cookie_path', $this->path);
ini_set('session.gc_probability', 1);
ini_set('session.auto_start', 0);
ini_set('session.save_path', TMP.'sessions');
if(!isset($_SESSION))
{
ini_set('session.use_trans_sid', 0);
ini_set('url_rewriter.tags', '');
ini_set('session.serialize_handler', 'php');
ini_set('session.use_cookies', 1);
ini_set('session.name', CAKE_SESSION_COOKIE);
ini_set('session.cookie_lifetime', $this->cookieLifeTime);
ini_set('session.cookie_path', $this->path);
ini_set('session.gc_probability', 1);
ini_set('session.auto_start', 0);
ini_set('session.save_path', TMP.'sessions');
}
break;
case 'database':
ini_set('session.use_trans_sid', 0);
ini_set('url_rewriter.tags', '');
ini_set('session.save_handler', 'user');
ini_set('session.serialize_handler', 'php');
ini_set('session.use_cookies', 1);
ini_set('session.name', CAKE_SESSION_COOKIE);
ini_set('session.cookie_lifetime', $this->cookieLifeTime);
ini_set('session.cookie_path', $this->path);
ini_set('session.gc_probability', 1);
ini_set('session.auto_start', 0);
if(!isset($_SESSION))
{
ini_set('session.use_trans_sid', 0);
ini_set('url_rewriter.tags', '');
ini_set('session.save_handler', 'user');
ini_set('session.serialize_handler', 'php');
ini_set('session.use_cookies', 1);
ini_set('session.name', CAKE_SESSION_COOKIE);
ini_set('session.cookie_lifetime', $this->cookieLifeTime);
ini_set('session.cookie_path', $this->path);
ini_set('session.gc_probability', 1);
ini_set('session.auto_start', 0);
}
session_set_save_handler(array('CakeSession', '__open'),
array('CakeSession', '__close'),
array('CakeSession', '__read'),
@ -394,19 +398,7 @@ class CakeSession extends Object
array('CakeSession', '__gc'));
break;
case 'php':
ini_set('session.use_trans_sid', 0);
ini_set('session.name', CAKE_SESSION_COOKIE);
ini_set('session.cookie_lifetime', $this->cookieLifeTime);
ini_set('session.cookie_path', $this->path);
ini_set('session.gc_probability', 1);
break;
default :
$config = CONFIGS.CAKE_SESSION_SAVE.'.php';
if(is_file($config))
{
require($config);
}
else
if(!isset($_SESSION))
{
ini_set('session.use_trans_sid', 0);
ini_set('session.name', CAKE_SESSION_COOKIE);
@ -415,6 +407,27 @@ class CakeSession extends Object
ini_set('session.gc_probability', 1);
}
break;
default:
if(!isset($_SESSION))
{
$config = CONFIGS.CAKE_SESSION_SAVE.'.php';
if(is_file($config))
{
require_once($config);
}
}
else
{
if(!isset($_SESSION))
{
ini_set('session.use_trans_sid', 0);
ini_set('session.name', CAKE_SESSION_COOKIE);
ini_set('session.cookie_lifetime', $this->cookieLifeTime);
ini_set('session.cookie_path', $this->path);
ini_set('session.gc_probability', 1);
}
}
break;
}
}
@ -509,7 +522,8 @@ class CakeSession extends Object
$newSessid = session_id();
$file = $sessionpath.DS."sess_$oldSessionId";
@unlink($file);
$this->_initSession();
@session_destroy($oldSessionId);
$this->__initSession();
session_id($newSessid);
session_start();
}

View file

@ -376,7 +376,7 @@ class AclCLI {
);";
$this->db->query($sql);
fwrite($this->stdout, "Creating access request objects table (acos)...\n");
fwrite($this->stdout, "Creating access request objects table (aros)...\n");
$sql2 = "CREATE TABLE `aros` (
`id` int(11) NOT NULL auto_increment,
`user_id` int(11) default NULL,