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
3244b9e3d7
16 changed files with 115 additions and 22 deletions
|
@ -18,6 +18,7 @@ matrix:
|
|||
- PHPCS=1
|
||||
|
||||
before_script:
|
||||
- sudo locale-gen de_DE
|
||||
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test;'; fi"
|
||||
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test2;'; fi"
|
||||
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test3;'; fi"
|
||||
|
|
|
@ -94,7 +94,6 @@ if (empty($associations['hasAndBelongsToMany'])) {
|
|||
$associations['hasAndBelongsToMany'] = array();
|
||||
}
|
||||
$relations = array_merge($associations['hasMany'], $associations['hasAndBelongsToMany']);
|
||||
$i = 0;
|
||||
foreach ($relations as $alias => $details):
|
||||
$otherSingularVar = Inflector::variable($alias);
|
||||
$otherPluralHumanName = Inflector::humanize($details['controller']);
|
||||
|
@ -112,9 +111,7 @@ foreach ($relations as $alias => $details):
|
|||
<th class="actions"><?php echo "<?php echo __('Actions'); ?>"; ?></th>
|
||||
</tr>
|
||||
<?php
|
||||
echo "\t<?php
|
||||
\$i = 0;
|
||||
foreach (\${$singularVar}['{$alias}'] as \${$otherSingularVar}): ?>\n";
|
||||
echo "\t<?php foreach (\${$singularVar}['{$alias}'] as \${$otherSingularVar}): ?>\n";
|
||||
echo "\t\t<tr>\n";
|
||||
foreach ($details['fields'] as $field) {
|
||||
echo "\t\t\t<td><?php echo \${$otherSingularVar}['{$field}']; ?></td>\n";
|
||||
|
|
|
@ -163,7 +163,7 @@ class AclNode extends Model {
|
|||
'joins' => array(array(
|
||||
'table' => $table,
|
||||
'alias' => "{$type}0",
|
||||
'type' => 'LEFT',
|
||||
'type' => 'INNER',
|
||||
'conditions' => array(
|
||||
$db->name("{$type}.lft") . ' <= ' . $db->name("{$type}0.lft"),
|
||||
$db->name("{$type}.rght") . ' >= ' . $db->name("{$type}0.rght")
|
||||
|
|
|
@ -48,7 +48,7 @@ abstract class AbstractTransport {
|
|||
*/
|
||||
public function config($config = null) {
|
||||
if (is_array($config)) {
|
||||
$this->_config = $config;
|
||||
$this->_config = $config + $this->_config;
|
||||
}
|
||||
return $this->_config;
|
||||
}
|
||||
|
|
|
@ -1622,6 +1622,11 @@ class CakeEmail {
|
|||
if ($this->_theme) {
|
||||
$View->theme = $this->_theme;
|
||||
}
|
||||
// Convert null to false, as View needs false to disable
|
||||
// the layout.
|
||||
if ($layout === null) {
|
||||
$layout = false;
|
||||
}
|
||||
|
||||
foreach ($types as $type) {
|
||||
$View->set('content', $content);
|
||||
|
|
|
@ -86,7 +86,7 @@ class SmtpTransport extends AbstractTransport {
|
|||
'client' => null,
|
||||
'tls' => false
|
||||
);
|
||||
$this->_config = empty($config) ? $this->_config + $default : $config + $default;
|
||||
$this->_config = array_merge($default, $this->_config, $config);
|
||||
return $this->_config;
|
||||
}
|
||||
|
||||
|
|
|
@ -152,7 +152,8 @@ class MysqlTest extends CakeTestCase {
|
|||
$this->skipIf(DS === '\\', 'The locale is not supported in Windows and affect the others tests.');
|
||||
|
||||
$restore = setlocale(LC_NUMERIC, 0);
|
||||
setlocale(LC_NUMERIC, 'de_DE');
|
||||
|
||||
$this->skipIf(setlocale(LC_NUMERIC, 'de_DE') === false, "The German locale isn't available.");
|
||||
|
||||
$result = $this->Dbo->value(3.141593);
|
||||
$this->assertEquals('3.141593', $result);
|
||||
|
|
|
@ -340,7 +340,8 @@ class PostgresTest extends CakeTestCase {
|
|||
*/
|
||||
public function testLocalizedFloats() {
|
||||
$restore = setlocale(LC_NUMERIC, 0);
|
||||
setlocale(LC_NUMERIC, 'de_DE');
|
||||
|
||||
$this->skipIf(setlocale(LC_NUMERIC, 'de_DE') === false, "The German locale isn't available.");
|
||||
|
||||
$result = $this->db->value(3.141593, 'float');
|
||||
$this->assertEquals("3.141593", $result);
|
||||
|
|
|
@ -6494,7 +6494,8 @@ class ModelWriteTest extends BaseModelTest {
|
|||
*/
|
||||
public function testWriteFloatAsGerman() {
|
||||
$restore = setlocale(LC_NUMERIC, 0);
|
||||
setlocale(LC_NUMERIC, 'de_DE');
|
||||
|
||||
$this->skipIf(setlocale(LC_NUMERIC, 'de_DE') === false, "The German locale isn't available.");
|
||||
|
||||
$model = new DataTest();
|
||||
$result = $model->save(array(
|
||||
|
|
|
@ -95,6 +95,20 @@ class EmailConfig {
|
|||
'helpers' => array('Html', 'Form'),
|
||||
);
|
||||
|
||||
/**
|
||||
* test config 2
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $test2 = array(
|
||||
'from' => array('some@example.com' => 'My website'),
|
||||
'to' => array('test@example.com' => 'Testname'),
|
||||
'subject' => 'Test mail subject',
|
||||
'transport' => 'Smtp',
|
||||
'host' => 'cakephp.org',
|
||||
'timeout' => 60
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -789,12 +803,13 @@ class CakeEmailTest extends CakeTestCase {
|
|||
$this->assertSame($this->CakeEmail->config(), $config);
|
||||
|
||||
$this->CakeEmail->config(array());
|
||||
$this->assertSame($transportClass->config(), array());
|
||||
$this->assertSame($transportClass->config(), $config);
|
||||
|
||||
$config = array('test' => 'test@example.com');
|
||||
$this->CakeEmail->config($config);
|
||||
$expected = array('test' => 'test@example.com', 'test2' => true);
|
||||
$this->assertSame($expected, $this->CakeEmail->config());
|
||||
$this->assertSame($expected, $transportClass->config());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -828,6 +843,35 @@ class CakeEmailTest extends CakeTestCase {
|
|||
$this->assertEquals($configs->test['helpers'], $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test updating config doesn't reset transport's config.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConfigMerge() {
|
||||
$this->CakeEmail->config('test2');
|
||||
|
||||
$expected = array(
|
||||
'host' => 'cakephp.org',
|
||||
'port' => 25,
|
||||
'timeout' => 60,
|
||||
'username' => null,
|
||||
'password' => null,
|
||||
'client' => null,
|
||||
'tls' => false
|
||||
);
|
||||
$this->assertEquals($expected, $this->CakeEmail->transportClass()->config());
|
||||
|
||||
$this->CakeEmail->config(array('log' => true));
|
||||
$result = $this->CakeEmail->transportClass()->config();
|
||||
$expected += array('log' => true);
|
||||
$this->assertEquals($expected, $this->CakeEmail->transportClass()->config());
|
||||
|
||||
$this->CakeEmail->config(array('timeout' => 45));
|
||||
$result = $this->CakeEmail->transportClass()->config();
|
||||
$this->assertEquals(45, $result['timeout']);
|
||||
}
|
||||
|
||||
/**
|
||||
* testSendWithContent method
|
||||
*
|
||||
|
@ -1177,6 +1221,26 @@ class CakeEmailTest extends CakeTestCase {
|
|||
$this->assertContains('To: ', $result['headers']);
|
||||
}
|
||||
|
||||
/**
|
||||
* test sending and rendering with no layout
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSendRenderNoLayout() {
|
||||
$this->CakeEmail->reset();
|
||||
$this->CakeEmail->transport('debug');
|
||||
|
||||
$this->CakeEmail->from('cake@cakephp.org');
|
||||
$this->CakeEmail->to(array('you@cakephp.org' => 'You'));
|
||||
$this->CakeEmail->subject('My title');
|
||||
$this->CakeEmail->config(array('empty'));
|
||||
$this->CakeEmail->template('default', null);
|
||||
$result = $this->CakeEmail->send('message body.');
|
||||
|
||||
$this->assertContains('message body.', $result['message']);
|
||||
$this->assertNotContains('This email was sent using the CakePHP Framework', $result['message']);
|
||||
}
|
||||
|
||||
/**
|
||||
* testSendRender method for ISO-2022-JP
|
||||
*
|
||||
|
|
|
@ -654,12 +654,29 @@ class CakeNumberTest extends CakeTestCase {
|
|||
*/
|
||||
public function testReadableSizeLocalized() {
|
||||
$restore = setlocale(LC_NUMERIC, 0);
|
||||
setlocale(LC_NUMERIC, 'de_DE');
|
||||
|
||||
$this->skipIf(setlocale(LC_NUMERIC, 'de_DE') === false, "The German locale isn't available.");
|
||||
|
||||
$result = $this->Number->toReadableSize(1321205);
|
||||
$this->assertRegExp('/1[,.]26 MB/', $result);
|
||||
$this->assertEquals('1,26 MB', $result);
|
||||
|
||||
$result = $this->Number->toReadableSize(1024 * 1024 * 1024 * 512);
|
||||
$this->assertRegExp('/512[,.]00 GB/', $result);
|
||||
$this->assertEquals('512,00 GB', $result);
|
||||
setlocale(LC_NUMERIC, $restore);
|
||||
}
|
||||
|
||||
/**
|
||||
* test precision() with locales
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testPrecisionLocalized() {
|
||||
$restore = setlocale(LC_NUMERIC, 0);
|
||||
|
||||
$this->skipIf(setlocale(LC_NUMERIC, 'de_DE') === false, "The German locale isn't available.");
|
||||
|
||||
$result = $this->Number->precision(1.234);
|
||||
$this->assertEquals('1,234', $result);
|
||||
setlocale(LC_NUMERIC, $restore);
|
||||
}
|
||||
|
||||
|
|
|
@ -604,6 +604,9 @@ class CakeTimeTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Time->format('nonsense', '%d-%m-%Y', 'invalid', 'UTC');
|
||||
$this->assertEquals('invalid', $result);
|
||||
|
||||
$result = $this->Time->format('0000-00-00', '%d-%m-%Y', 'invalid');
|
||||
$this->assertEquals('invalid', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -103,7 +103,7 @@ class CakeNumber {
|
|||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/number.html#NumberHelper::precision
|
||||
*/
|
||||
public static function precision($value, $precision = 3) {
|
||||
return sprintf("%01.{$precision}F", $value);
|
||||
return sprintf("%01.{$precision}f", $value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -118,13 +118,13 @@ class CakeNumber {
|
|||
case $size < 1024:
|
||||
return __dn('cake', '%d Byte', '%d Bytes', $size, $size);
|
||||
case round($size / 1024) < 1024:
|
||||
return __d('cake', '%d KB', self::precision($size / 1024, 0));
|
||||
return __d('cake', '%s KB', self::precision($size / 1024, 0));
|
||||
case round($size / 1024 / 1024, 2) < 1024:
|
||||
return __d('cake', '%.2f MB', self::precision($size / 1024 / 1024, 2));
|
||||
return __d('cake', '%s MB', self::precision($size / 1024 / 1024, 2));
|
||||
case round($size / 1024 / 1024 / 1024, 2) < 1024:
|
||||
return __d('cake', '%.2f GB', self::precision($size / 1024 / 1024 / 1024, 2));
|
||||
return __d('cake', '%s GB', self::precision($size / 1024 / 1024 / 1024, 2));
|
||||
default:
|
||||
return __d('cake', '%.2f TB', self::precision($size / 1024 / 1024 / 1024 / 1024, 2));
|
||||
return __d('cake', '%s TB', self::precision($size / 1024 / 1024 / 1024 / 1024, 2));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -316,6 +316,11 @@ class CakeTime {
|
|||
return false;
|
||||
}
|
||||
|
||||
$containsDummyDate = (is_string($dateString) && substr($dateString, 0, 10) === '0000-00-00');
|
||||
if ($containsDummyDate) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_int($dateString) || is_numeric($dateString)) {
|
||||
$date = intval($dateString);
|
||||
} elseif (
|
||||
|
|
|
@ -68,10 +68,10 @@ class Sanitize {
|
|||
* @return string SQL safe string
|
||||
*/
|
||||
public static function escape($string, $connection = 'default') {
|
||||
$db = ConnectionManager::getDataSource($connection);
|
||||
if (is_numeric($string) || $string === null || is_bool($string)) {
|
||||
return $string;
|
||||
}
|
||||
$db = ConnectionManager::getDataSource($connection);
|
||||
$string = $db->value($string, 'string');
|
||||
$start = 1;
|
||||
if ($string{0} === 'N') {
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
<h2><?php echo __d('cake', 'View %s', $singularHumanName); ?></h2>
|
||||
<dl>
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach ($scaffoldFields as $_field) {
|
||||
$isKey = false;
|
||||
if (!empty($associations['belongsTo'])) {
|
||||
|
@ -98,7 +97,6 @@ foreach ($associations['hasOne'] as $_alias => $_details): ?>
|
|||
<?php if (!empty(${$singularVar}[$_alias])): ?>
|
||||
<dl>
|
||||
<?php
|
||||
$i = 0;
|
||||
$otherFields = array_keys(${$singularVar}[$_alias]);
|
||||
foreach ($otherFields as $_field) {
|
||||
echo "\t\t<dt>" . Inflector::humanize($_field) . "</dt>\n";
|
||||
|
|
Loading…
Reference in a new issue