mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge branch 'master' into 2.4
Conflicts: lib/Cake/Utility/File.php
This commit is contained in:
commit
79ad8ab95a
7 changed files with 67 additions and 22 deletions
|
@ -3097,7 +3097,11 @@ class Model extends Object implements CakeEventListener {
|
|||
/**
|
||||
* Returns a resultset for a given SQL statement. Custom SQL queries should be performed with this method.
|
||||
*
|
||||
* @param string $sql,... SQL statement
|
||||
* @param string $sql SQL statement
|
||||
* @param boolean|array $params Either a boolean to control query caching or an array of parameters
|
||||
* for use with prepared statement placeholders.
|
||||
* @param boolean $cache If $params is provided, a boolean flag for enabling/disabled
|
||||
* query caching.
|
||||
* @return mixed Resultset array or boolean indicating success / failure depending on the query executed
|
||||
* @link http://book.cakephp.org/2.0/en/models/retrieving-your-data.html#model-query
|
||||
*/
|
||||
|
|
|
@ -880,7 +880,7 @@ class CakeTimeTest extends CakeTestCase {
|
|||
$date = new DateTime('+1 hour', new DateTimeZone('America/New_York'));
|
||||
$result = $this->Time->fromString($date, 'UTC');
|
||||
$date->setTimezone(new DateTimeZone('UTC'));
|
||||
$expected = $date->getTimestamp() + $date->getOffset();
|
||||
$expected = $date->format('U') + $date->getOffset();
|
||||
|
||||
$this->assertWithinMargin($expected, $result, 1);
|
||||
|
||||
|
@ -905,7 +905,7 @@ class CakeTimeTest extends CakeTestCase {
|
|||
Configure::write('Config.timezone', date_default_timezone_get());
|
||||
$date = new DateTime('2013-04-09');
|
||||
$result = $this->Time->fromString($date);
|
||||
$this->assertEquals($result, $date->getTimestamp());
|
||||
$this->assertEquals($result, $date->format('U'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -433,16 +433,24 @@ class FileTest extends CakeTestCase {
|
|||
$TmpFile = new File($tmpFile);
|
||||
$this->assertFalse(file_exists($tmpFile));
|
||||
|
||||
$fragments = array('CakePHP\'s', ' test suite', ' was here ...', '');
|
||||
$fragments = array('CakePHP\'s', ' test suite', ' was here ...');
|
||||
$data = null;
|
||||
$size = 0;
|
||||
foreach ($fragments as $fragment) {
|
||||
$r = $TmpFile->append($fragment);
|
||||
$this->assertTrue($r);
|
||||
$this->assertTrue(file_exists($tmpFile));
|
||||
$data = $data . $fragment;
|
||||
$this->assertEquals($data, file_get_contents($tmpFile));
|
||||
$newSize = $TmpFile->size();
|
||||
$this->assertTrue($newSize > $size);
|
||||
$size = $newSize;
|
||||
$TmpFile->close();
|
||||
}
|
||||
|
||||
$TmpFile->append('');
|
||||
$this->assertEquals($data, file_get_contents($tmpFile));
|
||||
$TmpFile->close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -748,7 +748,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
'type' => 'float',
|
||||
'null' => false,
|
||||
'default' => null,
|
||||
'length' => null
|
||||
'length' => 10
|
||||
)));
|
||||
|
||||
$this->Form->create('Contact');
|
||||
|
@ -1200,7 +1200,8 @@ class FormHelperTest extends CakeTestCase {
|
|||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Form->hidden('UserForm.stuff');
|
||||
$expected = array('input' => array(
|
||||
$expected = array(
|
||||
'input' => array(
|
||||
'type' => 'hidden', 'name' => 'data[UserForm][stuff]',
|
||||
'id' => 'UserFormStuff'
|
||||
));
|
||||
|
@ -1256,6 +1257,30 @@ class FormHelperTest extends CakeTestCase {
|
|||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test secured inputs with custom names.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSecuredInputCustomName() {
|
||||
$this->Form->request['_Token'] = array('key' => 'testKey');
|
||||
$this->assertEquals(array(), $this->Form->fields);
|
||||
|
||||
$this->Form->input('text_input', array(
|
||||
'name' => 'data[Option][General.default_role]',
|
||||
));
|
||||
$expected = array('Option.General.default_role');
|
||||
$this->assertEquals($expected, $this->Form->fields);
|
||||
|
||||
$this->Form->input('select_box', array(
|
||||
'name' => 'data[Option][General.select_role]',
|
||||
'type' => 'select',
|
||||
'options' => array(1, 2),
|
||||
));
|
||||
$expected = array('Option.General.default_role', 'Option.General.select_role');
|
||||
$this->assertEquals($expected, $this->Form->fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that the correct keys are added to the field hash index
|
||||
*
|
||||
|
@ -1841,7 +1866,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
'label' => array('for'),
|
||||
'Balance',
|
||||
'/label',
|
||||
'input' => array('name', 'type' => 'number', 'maxlength' => 8, 'id'),
|
||||
'input' => array('name', 'type' => 'number', 'id'),
|
||||
'/div',
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
|
|
@ -325,9 +325,9 @@ class CakeTime {
|
|||
) {
|
||||
$clone = clone $dateString;
|
||||
$clone->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||
$date = (int)$clone->getTimestamp() + $clone->getOffset();
|
||||
$date = (int)$clone->format('U') + $clone->getOffset();
|
||||
} elseif ($dateString instanceof DateTime) {
|
||||
$date = (int)$dateString->getTimeStamp();
|
||||
$date = (int)$dateString->format('U');
|
||||
} else {
|
||||
$date = strtotime($dateString);
|
||||
}
|
||||
|
|
|
@ -570,7 +570,7 @@ class File {
|
|||
*
|
||||
* For 5.3 onwards its possible to clear cache for just a single file. Passing true
|
||||
* will clear all the stat cache.
|
||||
*
|
||||
*
|
||||
* @param boolean $all Clear all cache or not
|
||||
* @return void
|
||||
*/
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
*
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package Cake.View.Helper
|
||||
* @package Cake.View.Helper
|
||||
* @since CakePHP(tm) v 0.10.0.1076
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
|
@ -1242,13 +1242,10 @@ class FormHelper extends AppHelper {
|
|||
$options['type'] !== 'select'
|
||||
);
|
||||
if ($autoLength &&
|
||||
in_array($options['type'], array('text', 'email', 'tel', 'url'))
|
||||
in_array($options['type'], array('text', 'email', 'tel', 'url', 'search'))
|
||||
) {
|
||||
$options['maxlength'] = $fieldDef['length'];
|
||||
}
|
||||
if ($autoLength && $fieldDef['type'] === 'float') {
|
||||
$options['maxlength'] = array_sum(explode(',', $fieldDef['length'])) + 1;
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
|
@ -2018,7 +2015,7 @@ class FormHelper extends AppHelper {
|
|||
empty($attributes['disabled']) &&
|
||||
(!empty($attributes['multiple']) || $hasOptions)
|
||||
) {
|
||||
$this->_secure(true);
|
||||
$this->_secure(true, $this->_secureFieldName($attributes));
|
||||
}
|
||||
$select[] = $this->Html->useTag($tag, $attributes['name'], array_diff_key($attributes, array('name' => null, 'value' => null)));
|
||||
}
|
||||
|
@ -2831,16 +2828,27 @@ class FormHelper extends AppHelper {
|
|||
$result['required'] = true;
|
||||
}
|
||||
|
||||
$fieldName = null;
|
||||
if (!empty($options['name'])) {
|
||||
$this->_secure($secure, $this->_secureFieldName($options));
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the field name for use with _secure().
|
||||
*
|
||||
* Parses the name attribute to create a dot separated name value for use
|
||||
* in secured field hash.
|
||||
*
|
||||
* @param array $options An array of options possibly containing a name key.
|
||||
* @return string|null
|
||||
*/
|
||||
protected function _secureFieldName($options) {
|
||||
if (isset($options['name'])) {
|
||||
preg_match_all('/\[(.*?)\]/', $options['name'], $matches);
|
||||
if (isset($matches[1])) {
|
||||
$fieldName = $matches[1];
|
||||
return $matches[1];
|
||||
}
|
||||
}
|
||||
|
||||
$this->_secure($secure, $fieldName);
|
||||
return $result;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue