mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Merge branch 'master' into 2.4
Conflicts: lib/Cake/Model/Model.php lib/Cake/VERSION.txt
This commit is contained in:
commit
5c83bc177d
5 changed files with 59 additions and 45 deletions
|
@ -24,11 +24,7 @@ before_script:
|
|||
- sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'CREATE SCHEMA test2;' -U postgres -d cakephp_test; fi"
|
||||
- sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'CREATE SCHEMA test3;' -U postgres -d cakephp_test; fi"
|
||||
- chmod -R 777 ./app/tmp
|
||||
- echo "var net = require('net');
|
||||
var server = net.createServer();
|
||||
server.listen(80, 'localhost');
|
||||
console.log('TCP server listening on port 80 at localhost.');" > app/tmp/socket.js
|
||||
- sudo node ./app/tmp/socket.js &
|
||||
- sudo apt-get install lighttpd
|
||||
- pear channel-discover pear.cakephp.org
|
||||
- pear install --alldeps cakephp/CakePHP_CodeSniffer
|
||||
- phpenv rehash
|
||||
|
|
|
@ -643,11 +643,11 @@ class Model extends Object implements CakeEventListener {
|
|||
*
|
||||
* If `$id` is an array it can be used to pass several options into the model.
|
||||
*
|
||||
* - id - The id to start the model on.
|
||||
* - table - The table to use for this model.
|
||||
* - ds - The connection name this model is connected to.
|
||||
* - name - The name of the model eg. Post.
|
||||
* - alias - The alias of the model, this is used for registering the instance in the `ClassRegistry`.
|
||||
* - `id`: The id to start the model on.
|
||||
* - `table`: The table to use for this model.
|
||||
* - `ds`: The connection name this model is connected to.
|
||||
* - `name`: The name of the model eg. Post.
|
||||
* - `alias`: The alias of the model, this is used for registering the instance in the `ClassRegistry`.
|
||||
* eg. `ParentThread`
|
||||
*
|
||||
* ### Overriding Model's __construct method.
|
||||
|
@ -1202,7 +1202,7 @@ class Model extends Object implements CakeEventListener {
|
|||
}
|
||||
|
||||
/**
|
||||
* Normalize Xml::toArray() to use in Model::save()
|
||||
* Normalize `Xml::toArray()` to use in `Model::save()`
|
||||
*
|
||||
* @param array $xml XML as array
|
||||
* @return array
|
||||
|
@ -1602,9 +1602,9 @@ class Model extends Object implements CakeEventListener {
|
|||
* If a boolean, indicates whether or not to validate before saving.
|
||||
* If an array, can have following keys:
|
||||
*
|
||||
* - `validate`: Set to true/false to enable or disable validation.
|
||||
* - `fieldList`: An array of fields you want to allow for saving.
|
||||
* - `callbacks`: Set to false to disable callbacks. Using 'before' or 'after'
|
||||
* - validate: Set to true/false to enable or disable validation.
|
||||
* - fieldList: An array of fields you want to allow for saving.
|
||||
* - callbacks: Set to false to disable callbacks. Using 'before' or 'after'
|
||||
* will enable only those callbacks.
|
||||
* - `counterCache`: Boolean to control updating of counter caches (if any)
|
||||
*
|
||||
|
@ -1984,7 +1984,7 @@ class Model extends Object implements CakeEventListener {
|
|||
}
|
||||
|
||||
/**
|
||||
* Helper method for Model::updateCounterCache(). Checks the fields to be updated for
|
||||
* Helper method for `Model::updateCounterCache()`. Checks the fields to be updated for
|
||||
*
|
||||
* @param array $data The fields of the record that will be updated
|
||||
* @return array Returns updated foreign key values, along with an 'old' key containing the old
|
||||
|
@ -2019,12 +2019,12 @@ class Model extends Object implements CakeEventListener {
|
|||
*
|
||||
* #### Options
|
||||
*
|
||||
* - validate: Set to false to disable validation, true to validate each record before saving,
|
||||
* - `validate`: Set to false to disable validation, true to validate each record before saving,
|
||||
* 'first' to validate *all* records before any are saved (default),
|
||||
* or 'only' to only validate the records, but not save them.
|
||||
* - atomic: If true (default), will attempt to save all records in a single transaction.
|
||||
* - `atomic`: If true (default), will attempt to save all records in a single transaction.
|
||||
* Should be set to false if database/table does not support transactions.
|
||||
* - fieldList: Equivalent to the $fieldList parameter in Model::save().
|
||||
* - `fieldList`: Equivalent to the $fieldList parameter in Model::save().
|
||||
* It should be an associate array with model name as key and array of fields as value. Eg.
|
||||
* {{{
|
||||
* array(
|
||||
|
@ -2032,9 +2032,9 @@ class Model extends Object implements CakeEventListener {
|
|||
* 'AssociatedModel' => array('field', 'otherfield')
|
||||
* )
|
||||
* }}}
|
||||
* - deep: See saveMany/saveAssociated
|
||||
* - callbacks: See Model::save()
|
||||
* - counterCache: See Model::save()
|
||||
* - `deep`: See saveMany/saveAssociated
|
||||
* - `callbacks`: See Model::save()
|
||||
* - `counterCache`: See Model::save()
|
||||
*
|
||||
* @param array $data Record data to save. This can be either a numerically-indexed array (for saving multiple
|
||||
* records of the same type), or an array indexed by association name.
|
||||
|
@ -2064,14 +2064,14 @@ class Model extends Object implements CakeEventListener {
|
|||
*
|
||||
* #### Options
|
||||
*
|
||||
* - validate: Set to false to disable validation, true to validate each record before saving,
|
||||
* - `validate`: Set to false to disable validation, true to validate each record before saving,
|
||||
* 'first' to validate *all* records before any are saved (default),
|
||||
* - atomic: If true (default), will attempt to save all records in a single transaction.
|
||||
* - `atomic`: If true (default), will attempt to save all records in a single transaction.
|
||||
* Should be set to false if database/table does not support transactions.
|
||||
* - fieldList: Equivalent to the $fieldList parameter in Model::save()
|
||||
* - deep: If set to true, all associated data will be saved as well.
|
||||
* - callbacks: See Model::save()
|
||||
* - counterCache: See Model::save()
|
||||
* - `fieldList`: Equivalent to the $fieldList parameter in Model::save()
|
||||
* - `deep`: If set to true, all associated data will be saved as well.
|
||||
* - `callbacks`: See Model::save()
|
||||
* - `counterCache`: See Model::save()
|
||||
*
|
||||
* @param array $data Record data to save. This should be a numerically-indexed array
|
||||
* @param array $options Options to use when saving record data, See $options above.
|
||||
|
@ -2149,9 +2149,9 @@ class Model extends Object implements CakeEventListener {
|
|||
*
|
||||
* #### Options
|
||||
*
|
||||
* - atomic: If true (default), returns boolean. If false returns array.
|
||||
* - fieldList: Equivalent to the $fieldList parameter in Model::save()
|
||||
* - deep: If set to true, all associated data will be validated as well.
|
||||
* - `atomic`: If true (default), returns boolean. If false returns array.
|
||||
* - `fieldList`: Equivalent to the $fieldList parameter in Model::save()
|
||||
* - `deep`: If set to true, all associated data will be validated as well.
|
||||
*
|
||||
* Warning: This method could potentially change the passed argument `$data`,
|
||||
* If you do not want this to happen, make a copy of `$data` before passing it
|
||||
|
@ -2172,11 +2172,11 @@ class Model extends Object implements CakeEventListener {
|
|||
*
|
||||
* #### Options
|
||||
*
|
||||
* - validate: Set to `false` to disable validation, `true` to validate each record before saving,
|
||||
* - `validate`: Set to `false` to disable validation, `true` to validate each record before saving,
|
||||
* 'first' to validate *all* records before any are saved(default),
|
||||
* - atomic: If true (default), will attempt to save all records in a single transaction.
|
||||
* - `atomic`: If true (default), will attempt to save all records in a single transaction.
|
||||
* Should be set to false if database/table does not support transactions.
|
||||
* - fieldList: Equivalent to the $fieldList parameter in Model::save().
|
||||
* - `fieldList`: Equivalent to the $fieldList parameter in Model::save().
|
||||
* It should be an associate array with model name as key and array of fields as value. Eg.
|
||||
* {{{
|
||||
* array(
|
||||
|
@ -2184,9 +2184,9 @@ class Model extends Object implements CakeEventListener {
|
|||
* 'AssociatedModel' => array('field', 'otherfield')
|
||||
* )
|
||||
* }}}
|
||||
* - deep: If set to true, not only directly associated data is saved, but deeper nested associated data as well.
|
||||
* - callbacks: See Model::save()
|
||||
* - counterCache: See Model::save()
|
||||
* - `deep`: If set to true, not only directly associated data is saved, but deeper nested associated data as well.
|
||||
* - `callbacks`: See Model::save()
|
||||
* - `counterCache`: See Model::save()
|
||||
*
|
||||
* @param array $data Record data to save. This should be an array indexed by association name.
|
||||
* @param array $options Options to use when saving record data, See $options above.
|
||||
|
@ -2358,9 +2358,9 @@ class Model extends Object implements CakeEventListener {
|
|||
*
|
||||
* #### Options
|
||||
*
|
||||
* - atomic: If true (default), returns boolean. If false returns array.
|
||||
* - fieldList: Equivalent to the $fieldList parameter in Model::save()
|
||||
* - deep: If set to true, not only directly associated data , but deeper nested associated data is validated as well.
|
||||
* - `atomic`: If true (default), returns boolean. If false returns array.
|
||||
* - `fieldList`: Equivalent to the $fieldList parameter in Model::save()
|
||||
* - `deep`: If set to true, not only directly associated data , but deeper nested associated data is validated as well.
|
||||
*
|
||||
* Warning: This method could potentially change the passed argument `$data`,
|
||||
* If you do not want this to happen, make a copy of `$data` before passing it
|
||||
|
@ -2592,8 +2592,8 @@ class Model extends Object implements CakeEventListener {
|
|||
/**
|
||||
* Returns true if a record with particular ID exists.
|
||||
*
|
||||
* If $id is not passed it calls Model::getID() to obtain the current record ID,
|
||||
* and then performs a Model::find('count') on the currently configured datasource
|
||||
* If $id is not passed it calls `Model::getID()` to obtain the current record ID,
|
||||
* and then performs a `Model::find('count')` on the currently configured datasource
|
||||
* to ascertain the existence of the record in persistent storage.
|
||||
*
|
||||
* @param integer|string $id ID of record to check for existence
|
||||
|
|
|
@ -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->format('U') + $date->getOffset();
|
||||
$expected = $date->getTimestamp() + $date->getOffset();
|
||||
|
||||
$this->assertWithinMargin($expected, $result, 1);
|
||||
|
||||
|
@ -888,6 +888,7 @@ class CakeTimeTest extends CakeTestCase {
|
|||
|
||||
$date = new DateTime('+1 hour', new DateTimeZone('America/New_York'));
|
||||
$result = $this->Time->fromString($date, 'Asia/Kuwait');
|
||||
|
||||
$date->setTimezone(new DateTimeZone('Asia/Kuwait'));
|
||||
$expected = $date->format('U') + $date->getOffset();
|
||||
$this->assertWithinMargin($expected, $result, 1);
|
||||
|
@ -895,6 +896,18 @@ class CakeTimeTest extends CakeTestCase {
|
|||
$this->_restoreSystemTimezone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that datetimes in the default timezone are not modified.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFromStringWithDateTimeNoConversion() {
|
||||
Configure::write('Config.timezone', date_default_timezone_get());
|
||||
$date = new DateTime('2013-04-09');
|
||||
$result = $this->Time->fromString($date);
|
||||
$this->assertEquals($result, $date->getTimestamp());
|
||||
}
|
||||
|
||||
/**
|
||||
* test converting time specifiers using a time definition localfe file
|
||||
*
|
||||
|
|
|
@ -319,10 +319,15 @@ class CakeTime {
|
|||
|
||||
if (is_int($dateString) || is_numeric($dateString)) {
|
||||
$date = intval($dateString);
|
||||
} elseif (is_object($dateString) && $dateString instanceof DateTime) {
|
||||
} elseif (
|
||||
$dateString instanceof DateTime &&
|
||||
$dateString->getTimezone()->getName() != date_default_timezone_get()
|
||||
) {
|
||||
$clone = clone $dateString;
|
||||
$clone->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||
$date = (int)$clone->format('U') + $clone->getOffset();
|
||||
$date = (int)$clone->getTimestamp() + $clone->getOffset();
|
||||
} elseif ($dateString instanceof DateTime) {
|
||||
$date = (int)$dateString->getTimeStamp();
|
||||
} else {
|
||||
$date = strtotime($dateString);
|
||||
}
|
||||
|
|
|
@ -845,7 +845,7 @@ class FormHelper extends AppHelper {
|
|||
$modelFields = array();
|
||||
$model = $this->model();
|
||||
if ($model) {
|
||||
$modelFields = array_keys($this->_introspectModel($model, 'fields'));
|
||||
$modelFields = array_keys((array)$this->_introspectModel($model, 'fields'));
|
||||
}
|
||||
if (is_array($fields)) {
|
||||
if (array_key_exists('legend', $fields) && !in_array('legend', $modelFields)) {
|
||||
|
|
Loading…
Add table
Reference in a new issue