mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Merging fixes to trunk
Revision: [1773] adding fixes to PHP 5 model class Revision: [1772] Fixed errors in PHP model. Fixed parse error in CakeSession Class. Added stripslashes_deep function to basics.php Fixed errors in Dispatcher class. Revision: [1771] reverting changes in last commit Revision: [1770] Fixing save() in model Revision: [1769] correcting more errors that we are finding git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1774 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
842b97d622
commit
dd3de20200
11 changed files with 86 additions and 69 deletions
|
@ -753,6 +753,13 @@ function cache($path, $data = null, $expires = '+1 day', $target = 'cache')
|
|||
return $data;
|
||||
}
|
||||
|
||||
function stripslashes_deep($value)
|
||||
{
|
||||
$value = is_array($value) ?
|
||||
array_map('stripslashes_deep', $value) :
|
||||
stripslashes($value);
|
||||
return $value;
|
||||
}
|
||||
/**
|
||||
* Returns a translated string if one is found,
|
||||
* or the submitted message if not found.
|
||||
|
|
|
@ -248,14 +248,7 @@ class Dispatcher extends Object
|
|||
{
|
||||
if(!empty($_POST))
|
||||
{
|
||||
if(is_array($_POST))
|
||||
{
|
||||
$params['form'] = array_map('stripslashes', $_POST);
|
||||
}
|
||||
else
|
||||
{
|
||||
$params['form'] = stripcslashes($_POST);
|
||||
}
|
||||
$params['form'] = stripslashes_deep($_POST);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -272,14 +265,7 @@ class Dispatcher extends Object
|
|||
{
|
||||
if (ini_get('magic_quotes_gpc') == 1)
|
||||
{
|
||||
if(is_array($_GET))
|
||||
{
|
||||
$params['url'] = array_map('stripslashes', $_GET);
|
||||
}
|
||||
else
|
||||
{
|
||||
$params['url'] = stripcslashes($_GET);
|
||||
}
|
||||
$params['url'] = stripslashes_deep($_GET);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -431,6 +431,12 @@ class Scaffold extends Object {
|
|||
$newDate = $this->controllerClass->params['data'][$this->modelKey][$field['name'].'_year'].'-';
|
||||
$newDate .= $this->controllerClass->params['data'][$this->modelKey][$field['name'].'_month'].'-';
|
||||
$newDate .= $this->controllerClass->params['data'][$this->modelKey][$field['name'].'_day'].' ';
|
||||
unset($this->controllerClass->params['data'][$this->modelKey][$field['name'].'_year']);
|
||||
unset($this->controllerClass->params['data'][$this->modelKey][$field['name'].'_month']);
|
||||
unset($this->controllerClass->params['data'][$this->modelKey][$field['name'].'_day']);
|
||||
unset($this->controllerClass->params['data'][$this->modelKey][$field['name'].'_hour']);
|
||||
unset($this->controllerClass->params['data'][$this->modelKey][$field['name'].'_min']);
|
||||
unset($this->controllerClass->params['data'][$this->modelKey][$field['name'].'_meridian']);
|
||||
$this->controllerClass->params['data'][$this->modelKey][$field['name']] = $newDate;
|
||||
}
|
||||
else if( 'datetime' == $field['type'] && isset($this->controllerClass->params['data'][$this->modelKey][$field['name'].'_year'] ) )
|
||||
|
@ -444,6 +450,12 @@ class Scaffold extends Object {
|
|||
$newDate .= $this->controllerClass->params['data'][$this->modelKey][$field['name'].'_month'].'-';
|
||||
$newDate .= $this->controllerClass->params['data'][$this->modelKey][$field['name'].'_day'].' ';
|
||||
$newDate .= $hour.':'.$this->controllerClass->params['data'][$this->modelKey][$field['name'].'_min'].':00';
|
||||
unset($this->controllerClass->params['data'][$this->modelKey][$field['name'].'_year']);
|
||||
unset($this->controllerClass->params['data'][$this->modelKey][$field['name'].'_month']);
|
||||
unset($this->controllerClass->params['data'][$this->modelKey][$field['name'].'_day']);
|
||||
unset($this->controllerClass->params['data'][$this->modelKey][$field['name'].'_hour']);
|
||||
unset($this->controllerClass->params['data'][$this->modelKey][$field['name'].'_min']);
|
||||
unset($this->controllerClass->params['data'][$this->modelKey][$field['name'].'_meridian']);
|
||||
$this->controllerClass->params['data'][$this->modelKey][$field['name']] = $newDate;
|
||||
}
|
||||
else if( 'tinyint(1)' == $field['type'] )
|
||||
|
|
|
@ -309,7 +309,12 @@ class DboSource extends DataSource
|
|||
$values = array_values($model->data);
|
||||
}
|
||||
|
||||
if($this->execute('INSERT INTO '.$model->table.' ('.join(',', $fields).') VALUES ('.join(',', $values).')'))
|
||||
foreach ($values as $value)
|
||||
{
|
||||
$valueInsert[] = $this->value($value);
|
||||
}
|
||||
|
||||
if($this->execute('INSERT INTO '.$model->table.' ('.join(',', $fields).') VALUES ('.join(',', $valueInsert).')'))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -256,13 +256,13 @@ class DBO extends Object
|
|||
$out = null;
|
||||
foreach ($data as $key=>$item)
|
||||
{
|
||||
$out[$key] = $this->prepareValue($item);
|
||||
$out[$key] = $this->value($item);
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->prepareValue($data);
|
||||
return $this->value($data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -148,13 +148,13 @@ class DboMysql extends DboSource
|
|||
elseif (count($args) > 1 && strpos($args[0], 'findBy') === 0)
|
||||
{
|
||||
$field = Inflector::underscore(str_replace('findBy', '', $args[0]));
|
||||
$query = '`' . $args[2]->name . '`.`' . $field . '` = ' . $this->value($args[1][0]);
|
||||
$query = '`' . $args[2]->name . '.' . $field . '` = ' . $this->value($args[1][0]);
|
||||
return $args[2]->find($query);
|
||||
}
|
||||
elseif (count($args) > 1 && strpos($args[0], 'findAllBy') === 0)
|
||||
{
|
||||
$field = Inflector::underscore(str_replace('findAllBy', '', $args[0]));
|
||||
$query = '`' . $args[2]->name . '`.`' . $field . '` = ' . $this->value($args[1][0]);
|
||||
$query = '`' . $args[2]->name . '.' . $field . '` = ' . $this->value($args[1][0]);
|
||||
return $args[2]->findAll($query);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -848,7 +848,7 @@ class Model extends Object
|
|||
$values[] = $this->db->value($id);
|
||||
$values[] = $this->db->value($update);
|
||||
$values = join(',', $values);
|
||||
$newValues[] = '('.$values.')';
|
||||
$newValues[] = "({$values})";
|
||||
unset($values);
|
||||
}
|
||||
}
|
||||
|
@ -863,10 +863,10 @@ class Model extends Object
|
|||
$total = count($joinTable);
|
||||
for ($count = 0; $count < $total; $count++)
|
||||
{
|
||||
$this->db->query("DELETE FROM {$joinTable[$count]} WHERE $mainKey = '{$id}'");
|
||||
$this->db->execute("DELETE FROM {$joinTable[$count]} WHERE $mainKey = '{$id}'");
|
||||
if(!empty($newValue[$count]))
|
||||
{
|
||||
$this->db->query("INSERT INTO {$joinTable[$count]} ({$fields[$count]}) VALUES {$newValue[$count]}");
|
||||
$this->db->execute("INSERT INTO {$joinTable[$count]} ({$fields[$count]}) VALUES {$newValue[$count]}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1135,24 +1135,16 @@ class Model extends Object
|
|||
*/
|
||||
function findNeighbours ($conditions, $field, $value)
|
||||
{
|
||||
@list($prev) = Model::findAll($conditions . ' AND ' . $this->db->name($field) . ' < ' . $this->db->value($value), $field, $this->db->name($field) . ' DESC', 1);
|
||||
@list($next) = Model::findAll($conditions . ' AND ' . $this->db->name($field) . ' > ' . $this->db->value($value), $field, $this->db->name($field) . ' ASC', 1);
|
||||
@list($prev) = Model::findAll($conditions . ' AND ' . $field . ' < ' . $this->db->value($value), $field, $field . ' DESC', 1);
|
||||
@list($next) = Model::findAll($conditions . ' AND ' . $field . ' > ' . $this->db->value($value), $field, $field . ' ASC', 1);
|
||||
|
||||
if (isset($prev))
|
||||
if (!isset($prev))
|
||||
{
|
||||
$prev = $prev;
|
||||
$prev = null;
|
||||
}
|
||||
else
|
||||
if (!isset($next))
|
||||
{
|
||||
$prev = false;
|
||||
}
|
||||
if (isset($next))
|
||||
{
|
||||
$next = $next;
|
||||
}
|
||||
else
|
||||
{
|
||||
$next = false;
|
||||
$next = null;
|
||||
}
|
||||
return array('prev' => $prev, 'next' => $next);
|
||||
}
|
||||
|
|
|
@ -845,7 +845,7 @@ class Model extends Object
|
|||
$values[] = $this->db->value($id);
|
||||
$values[] = $this->db->value($update);
|
||||
$values = join(',', $values);
|
||||
$newValues[] = '('.$values.')';
|
||||
$newValues[] = "({$values})";
|
||||
unset($values);
|
||||
}
|
||||
}
|
||||
|
@ -860,10 +860,10 @@ class Model extends Object
|
|||
$total = count($joinTable);
|
||||
for ($count = 0; $count < $total; $count++)
|
||||
{
|
||||
$this->db->query("DELETE FROM {$joinTable[$count]} WHERE $mainKey = '{$id}'");
|
||||
$this->db->execute("DELETE FROM {$joinTable[$count]} WHERE $mainKey = '{$id}'");
|
||||
if(!empty($newValue[$count]))
|
||||
{
|
||||
$this->db->query("INSERT INTO {$joinTable[$count]} ({$fields[$count]}) VALUES {$newValue[$count]}");
|
||||
$this->db->execute("INSERT INTO {$joinTable[$count]} ({$fields[$count]}) VALUES {$newValue[$count]}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1132,24 +1132,16 @@ class Model extends Object
|
|||
*/
|
||||
function findNeighbours ($conditions, $field, $value)
|
||||
{
|
||||
@list($prev) = Model::findAll($conditions . ' AND ' . $this->db->name($field) . ' < ' . $this->db->value($value), $field, $this->db->name($field) . ' DESC', 1);
|
||||
@list($next) = Model::findAll($conditions . ' AND ' . $this->db->name($field) . ' > ' . $this->db->value($value), $field, $this->db->name($field) . ' ASC', 1);
|
||||
@list($prev) = Model::findAll($conditions . ' AND ' . $field . ' < ' . $this->db->value($value), $field, $field . ' DESC', 1);
|
||||
@list($next) = Model::findAll($conditions . ' AND ' . $field . ' > ' . $this->db->value($value), $field, $field . ' ASC', 1);
|
||||
|
||||
if (isset($prev))
|
||||
if (!isset($prev))
|
||||
{
|
||||
$prev = $prev;
|
||||
$prev = null;
|
||||
}
|
||||
else
|
||||
if (!isset($next))
|
||||
{
|
||||
$prev = false;
|
||||
}
|
||||
if (isset($next))
|
||||
{
|
||||
$next = $next;
|
||||
}
|
||||
else
|
||||
{
|
||||
$next = false;
|
||||
$next = null;
|
||||
}
|
||||
return array('prev' => $prev, 'next' => $next);
|
||||
}
|
||||
|
@ -1297,8 +1289,6 @@ class Model extends Object
|
|||
{
|
||||
return $this->db->name($this->name).'.'.$this->db->name($field);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the current record's ID
|
||||
*
|
||||
|
|
|
@ -240,7 +240,7 @@ class CakeSession extends Object
|
|||
{
|
||||
if(!empty($_SESSION))
|
||||
{
|
||||
$result = eval("return ".$_SESSION.";");
|
||||
$result = eval("return \$_SESSION;");
|
||||
return $result;
|
||||
}
|
||||
$this->_setError(2, "No Session vars set");
|
||||
|
|
|
@ -180,7 +180,7 @@ class AjaxHelper extends Helper
|
|||
|
||||
function linkToRemote ($title, $options = array(), $html_options = array())
|
||||
{
|
||||
trigger_error('Deprecated function: use AjaxHelper::link', E_USER_WARNING);
|
||||
//trigger_error('Deprecated function: use AjaxHelper::link', E_USER_WARNING);
|
||||
$href = '#';
|
||||
if (!empty($options['fallback']) && isset($options['fallback']))
|
||||
{
|
||||
|
|
|
@ -91,6 +91,31 @@ class JavascriptHelper extends Helper
|
|||
return $script;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape a string to be JavaScript friendly.
|
||||
*
|
||||
* List of escaped ellements:
|
||||
* + "\r\n" => '\n'
|
||||
* + "\r" => '\n'
|
||||
* + "\n" => '\n'
|
||||
* + '"' => '\"'
|
||||
* + "'" => "\\'"
|
||||
*
|
||||
* @param string $script String that needs to get escaped.
|
||||
* @return string Escaped string.
|
||||
*/
|
||||
function escapeString($string)
|
||||
{
|
||||
$escape = array(
|
||||
"\r\n" => '\n',
|
||||
"\r" => '\n',
|
||||
"\n" => '\n',
|
||||
'"' => '\"',
|
||||
"'" => "\\'"
|
||||
);
|
||||
|
||||
return str_replace(array_keys($escape), array_values($escape), $string);
|
||||
}
|
||||
/**
|
||||
* Attach an event to an element. Used with the Prototype library.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue