mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge branch 'master' into 2.4
This commit is contained in:
commit
dcf7df39d2
5 changed files with 52 additions and 17 deletions
|
@ -699,7 +699,7 @@ class AuthComponent extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the URL a use should be redirected to upon login.
|
* Get the URL a user should be redirected to upon login.
|
||||||
*
|
*
|
||||||
* Pass an URL in to set the destination a user should be redirected to upon
|
* Pass an URL in to set the destination a user should be redirected to upon
|
||||||
* logging in.
|
* logging in.
|
||||||
|
|
|
@ -213,7 +213,7 @@ class CakeSession {
|
||||||
* @return boolean True if variable is there
|
* @return boolean True if variable is there
|
||||||
*/
|
*/
|
||||||
public static function check($name = null) {
|
public static function check($name = null) {
|
||||||
if (!self::started() && !self::start()) {
|
if (!self::start()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (empty($name)) {
|
if (empty($name)) {
|
||||||
|
@ -223,9 +223,17 @@ class CakeSession {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Session id
|
* Returns the session id.
|
||||||
|
* Calling this method will not auto start the session. You might have to manually
|
||||||
|
* assert a started session.
|
||||||
*
|
*
|
||||||
* @param string $id
|
* Passing an id into it, you can also replace the session id if the session
|
||||||
|
* has not already been started.
|
||||||
|
* Note that depending on the session handler, not all characters are allowed
|
||||||
|
* within the session id. For example, the file session handler only allows
|
||||||
|
* characters in the range a-z A-Z 0-9 , (comma) and - (minus).
|
||||||
|
*
|
||||||
|
* @param string $id Id to replace the current session id
|
||||||
* @return string Session id
|
* @return string Session id
|
||||||
*/
|
*/
|
||||||
public static function id($id = null) {
|
public static function id($id = null) {
|
||||||
|
@ -254,7 +262,7 @@ class CakeSession {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to write new data to _SESSION, since PHP doesn't like us setting the _SESSION var itself
|
* Used to write new data to _SESSION, since PHP doesn't like us setting the _SESSION var itself.
|
||||||
*
|
*
|
||||||
* @param array $old Set of old variables => values
|
* @param array $old Set of old variables => values
|
||||||
* @param array $new New set of variable => value
|
* @param array $new New set of variable => value
|
||||||
|
@ -333,10 +341,10 @@ class CakeSession {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get / Set the userAgent
|
* Get / Set the user agent
|
||||||
*
|
*
|
||||||
* @param string $userAgent Set the userAgent
|
* @param string $userAgent Set the user agent
|
||||||
* @return void
|
* @return string Current user agent
|
||||||
*/
|
*/
|
||||||
public static function userAgent($userAgent = null) {
|
public static function userAgent($userAgent = null) {
|
||||||
if ($userAgent) {
|
if ($userAgent) {
|
||||||
|
@ -355,7 +363,7 @@ class CakeSession {
|
||||||
* @return mixed The value of the session variable
|
* @return mixed The value of the session variable
|
||||||
*/
|
*/
|
||||||
public static function read($name = null) {
|
public static function read($name = null) {
|
||||||
if (!self::started() && !self::start()) {
|
if (!self::start()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (is_null($name)) {
|
if (is_null($name)) {
|
||||||
|
@ -393,7 +401,7 @@ class CakeSession {
|
||||||
* @return boolean True if the write was successful, false if the write failed
|
* @return boolean True if the write was successful, false if the write failed
|
||||||
*/
|
*/
|
||||||
public static function write($name, $value = null) {
|
public static function write($name, $value = null) {
|
||||||
if (!self::started() && !self::start()) {
|
if (!self::start()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (empty($name)) {
|
if (empty($name)) {
|
||||||
|
@ -418,9 +426,7 @@ class CakeSession {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function destroy() {
|
public static function destroy() {
|
||||||
if (!self::started()) {
|
self::start();
|
||||||
self::start();
|
|
||||||
}
|
|
||||||
session_destroy();
|
session_destroy();
|
||||||
self::clear();
|
self::clear();
|
||||||
}
|
}
|
||||||
|
@ -620,7 +626,7 @@ class CakeSession {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected static function _checkValid() {
|
protected static function _checkValid() {
|
||||||
if (!self::started() && !self::start()) {
|
if (!self::start()) {
|
||||||
self::$valid = false;
|
self::$valid = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6555,7 +6555,9 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
));
|
));
|
||||||
$TestModel->saveAll($data, array('fieldList' => $fieldList));
|
$TestModel->saveAll($data, array('fieldList' => $fieldList));
|
||||||
|
|
||||||
$result = $TestModel->find('all');
|
$result = $TestModel->find('all', array(
|
||||||
|
'order' => 'Post.id ASC',
|
||||||
|
));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'Post' => array (
|
'Post' => array (
|
||||||
'id' => '4',
|
'id' => '4',
|
||||||
|
|
|
@ -6674,6 +6674,30 @@ class FormHelperTest extends CakeTestCase {
|
||||||
$this->assertEquals($result, $expected);
|
$this->assertEquals($result, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* testInputDateMaxYear method
|
||||||
|
*
|
||||||
|
* Let's say we want to only allow users born from 2006 to 2008 to register
|
||||||
|
* This being the first singup page, we still don't have any data
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testInputDateMaxYear() {
|
||||||
|
$this->Form->request->data = array();
|
||||||
|
$this->Form->create('User');
|
||||||
|
$result = $this->Form->input('birthday',
|
||||||
|
array(
|
||||||
|
'label' => false,
|
||||||
|
'div' => false,
|
||||||
|
'type' => 'date',
|
||||||
|
'dateFormat' => 'DMY',
|
||||||
|
'minYear' => 2006,
|
||||||
|
'maxYear' => 2008
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->assertContains('value="2008" selected="selected"', $result);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testTextArea method
|
* testTextArea method
|
||||||
*
|
*
|
||||||
|
|
|
@ -2280,8 +2280,8 @@ class FormHelper extends AppHelper {
|
||||||
*/
|
*/
|
||||||
protected function _dateTimeSelected($select, $fieldName, $attributes) {
|
protected function _dateTimeSelected($select, $fieldName, $attributes) {
|
||||||
if ((empty($attributes['value']) || $attributes['value'] === true) && $value = $this->value($fieldName)) {
|
if ((empty($attributes['value']) || $attributes['value'] === true) && $value = $this->value($fieldName)) {
|
||||||
if (is_array($value) && isset($value[$select])) {
|
if (is_array($value)) {
|
||||||
$attributes['value'] = $value[$select];
|
$attributes['value'] = isset($value[$select]) ? $value[$select] : null;
|
||||||
} else {
|
} else {
|
||||||
if (empty($value)) {
|
if (empty($value)) {
|
||||||
if (!$attributes['empty']) {
|
if (!$attributes['empty']) {
|
||||||
|
@ -2368,6 +2368,9 @@ class FormHelper extends AppHelper {
|
||||||
|
|
||||||
if ($attributes['value'] === null && $attributes['empty'] != true) {
|
if ($attributes['value'] === null && $attributes['empty'] != true) {
|
||||||
$attributes['value'] = time();
|
$attributes['value'] = time();
|
||||||
|
if (!empty($attributes['maxYear']) && $attributes['maxYear'] < date('Y')) {
|
||||||
|
$attributes['value'] = strtotime(date($attributes['maxYear'] . '-m-d'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($attributes['value'])) {
|
if (!empty($attributes['value'])) {
|
||||||
|
|
Loading…
Reference in a new issue