mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge branch 'master' into 2.3
This commit is contained in:
commit
59e948fb1b
9 changed files with 76 additions and 44 deletions
|
@ -183,6 +183,7 @@ class WincacheEngine extends CacheEngine {
|
||||||
* @return boolean success
|
* @return boolean success
|
||||||
**/
|
**/
|
||||||
public function clearGroup($group) {
|
public function clearGroup($group) {
|
||||||
|
$success = null;
|
||||||
wincache_ucache_inc($this->settings['prefix'] . $group, 1, $success);
|
wincache_ucache_inc($this->settings['prefix'] . $group, 1, $success);
|
||||||
return $success;
|
return $success;
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,7 +215,8 @@ class ShellDispatcher {
|
||||||
return $Shell->main();
|
return $Shell->main();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new MissingShellMethodException(array('shell' => $shell, 'method' => $arg));
|
|
||||||
|
throw new MissingShellMethodException(array('shell' => $shell, 'method' => $command));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -295,11 +295,11 @@ class ExceptionRenderer {
|
||||||
$this->controller->layoutPath = null;
|
$this->controller->layoutPath = null;
|
||||||
$this->controller->subDir = null;
|
$this->controller->subDir = null;
|
||||||
$this->controller->viewPath = 'Errors/';
|
$this->controller->viewPath = 'Errors/';
|
||||||
$this->controller->viewClass = 'View';
|
|
||||||
$this->controller->layout = 'error';
|
$this->controller->layout = 'error';
|
||||||
$this->controller->helpers = array('Form', 'Html', 'Session');
|
$this->controller->helpers = array('Form', 'Html', 'Session');
|
||||||
|
|
||||||
$this->controller->render($template);
|
$view = new View($this->controller);
|
||||||
|
$this->controller->response->body($view->render($template, 'error'));
|
||||||
$this->controller->response->type('html');
|
$this->controller->response->type('html');
|
||||||
$this->controller->response->send();
|
$this->controller->response->send();
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,11 +148,14 @@ class TranslateBehavior extends ModelBehavior {
|
||||||
if (empty($query['fields'])) {
|
if (empty($query['fields'])) {
|
||||||
$addFields = $fields;
|
$addFields = $fields;
|
||||||
} elseif (is_array($query['fields'])) {
|
} elseif (is_array($query['fields'])) {
|
||||||
|
$isAllFields = (
|
||||||
|
in_array($Model->alias . '.' . '*', $query['fields']) ||
|
||||||
|
in_array($Model->escapeField('*'), $query['fields'])
|
||||||
|
);
|
||||||
foreach ($fields as $key => $value) {
|
foreach ($fields as $key => $value) {
|
||||||
$field = (is_numeric($key)) ? $value : $key;
|
$field = (is_numeric($key)) ? $value : $key;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
in_array($Model->escapeField('*'), $query['fields']) ||
|
$isAllFields ||
|
||||||
in_array($Model->alias . '.' . $field, $query['fields']) ||
|
in_array($Model->alias . '.' . $field, $query['fields']) ||
|
||||||
in_array($field, $query['fields'])
|
in_array($field, $query['fields'])
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -3261,7 +3261,7 @@ class Model extends Object implements CakeEventListener {
|
||||||
return array($with, array_unique(array_merge($assoc[$with], $keys)));
|
return array($with, array_unique(array_merge($assoc[$with], $keys)));
|
||||||
}
|
}
|
||||||
trigger_error(
|
trigger_error(
|
||||||
__d('cake_dev', 'Invalid join model settings in %s', $model->alias),
|
__d('cake_dev', 'Invalid join model settings in %s. The association parameter has the wrong type, expecting a string or array, but was passed type: %s', $this->alias, gettype($assoc)),
|
||||||
E_USER_WARNING
|
E_USER_WARNING
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -325,7 +325,7 @@ class CakeEmail {
|
||||||
if ($this->_appCharset !== null) {
|
if ($this->_appCharset !== null) {
|
||||||
$this->charset = $this->_appCharset;
|
$this->charset = $this->_appCharset;
|
||||||
}
|
}
|
||||||
$this->_domain = env('HTTP_HOST');
|
$this->_domain = preg_replace('/\:\d+$/', '', env('HTTP_HOST'));
|
||||||
if (empty($this->_domain)) {
|
if (empty($this->_domain)) {
|
||||||
$this->_domain = php_uname('n');
|
$this->_domain = php_uname('n');
|
||||||
}
|
}
|
||||||
|
|
|
@ -691,25 +691,49 @@ class ExceptionRendererTest extends CakeTestCase {
|
||||||
$exception = new MissingHelperException(array('class' => 'Fail'));
|
$exception = new MissingHelperException(array('class' => 'Fail'));
|
||||||
$ExceptionRenderer = new ExceptionRenderer($exception);
|
$ExceptionRenderer = new ExceptionRenderer($exception);
|
||||||
|
|
||||||
$ExceptionRenderer->controller = $this->getMock('Controller');
|
$ExceptionRenderer->controller = $this->getMock('Controller', array('render'));
|
||||||
$ExceptionRenderer->controller->helpers = array('Fail', 'Boom');
|
$ExceptionRenderer->controller->helpers = array('Fail', 'Boom');
|
||||||
$ExceptionRenderer->controller->request = $this->getMock('CakeRequest');
|
$ExceptionRenderer->controller->request = $this->getMock('CakeRequest');
|
||||||
$ExceptionRenderer->controller->expects($this->at(2))
|
$ExceptionRenderer->controller->expects($this->at(0))
|
||||||
->method('render')
|
->method('render')
|
||||||
->with('missingHelper')
|
->with('missingHelper')
|
||||||
->will($this->throwException($exception));
|
->will($this->throwException($exception));
|
||||||
|
|
||||||
$ExceptionRenderer->controller->expects($this->at(4))
|
$response = $this->getMock('CakeResponse');
|
||||||
->method('render')
|
$response->expects($this->once())
|
||||||
->with('error500')
|
->method('body')
|
||||||
->will($this->returnValue(true));
|
->with($this->stringContains('Helper class Fail'));
|
||||||
|
|
||||||
$ExceptionRenderer->controller->response = $this->getMock('CakeResponse');
|
$ExceptionRenderer->controller->response = $response;
|
||||||
$ExceptionRenderer->render();
|
$ExceptionRenderer->render();
|
||||||
sort($ExceptionRenderer->controller->helpers);
|
sort($ExceptionRenderer->controller->helpers);
|
||||||
$this->assertEquals(array('Form', 'Html', 'Session'), $ExceptionRenderer->controller->helpers);
|
$this->assertEquals(array('Form', 'Html', 'Session'), $ExceptionRenderer->controller->helpers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that exceptions in beforeRender() are handled by outputMessageSafe
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testRenderExceptionInBeforeRender() {
|
||||||
|
$exception = new NotFoundException('Not there, sorry');
|
||||||
|
$ExceptionRenderer = new ExceptionRenderer($exception);
|
||||||
|
|
||||||
|
$ExceptionRenderer->controller = $this->getMock('Controller', array('beforeRender'));
|
||||||
|
$ExceptionRenderer->controller->request = $this->getMock('CakeRequest');
|
||||||
|
$ExceptionRenderer->controller->expects($this->any())
|
||||||
|
->method('beforeRender')
|
||||||
|
->will($this->throwException($exception));
|
||||||
|
|
||||||
|
$response = $this->getMock('CakeResponse');
|
||||||
|
$response->expects($this->once())
|
||||||
|
->method('body')
|
||||||
|
->with($this->stringContains('Not there, sorry'));
|
||||||
|
|
||||||
|
$ExceptionRenderer->controller->response = $response;
|
||||||
|
$ExceptionRenderer->render();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that missing subDir/layoutPath don't cause other fatal errors.
|
* Test that missing subDir/layoutPath don't cause other fatal errors.
|
||||||
*
|
*
|
||||||
|
@ -719,32 +743,31 @@ class ExceptionRendererTest extends CakeTestCase {
|
||||||
$exception = new NotFoundException();
|
$exception = new NotFoundException();
|
||||||
$ExceptionRenderer = new ExceptionRenderer($exception);
|
$ExceptionRenderer = new ExceptionRenderer($exception);
|
||||||
|
|
||||||
$ExceptionRenderer->controller = $this->getMock('Controller');
|
$ExceptionRenderer->controller = $this->getMock('Controller', array('render'));
|
||||||
$ExceptionRenderer->controller->helpers = array('Fail', 'Boom');
|
$ExceptionRenderer->controller->helpers = array('Fail', 'Boom');
|
||||||
$ExceptionRenderer->controller->layoutPath = 'json';
|
$ExceptionRenderer->controller->layoutPath = 'json';
|
||||||
$ExceptionRenderer->controller->subDir = 'json';
|
$ExceptionRenderer->controller->subDir = 'json';
|
||||||
$ExceptionRenderer->controller->viewClass = 'Json';
|
$ExceptionRenderer->controller->viewClass = 'Json';
|
||||||
$ExceptionRenderer->controller->request = $this->getMock('CakeRequest');
|
$ExceptionRenderer->controller->request = $this->getMock('CakeRequest');
|
||||||
|
|
||||||
$ExceptionRenderer->controller->expects($this->at(1))
|
$ExceptionRenderer->controller->expects($this->once())
|
||||||
->method('render')
|
->method('render')
|
||||||
->with('error400')
|
->with('error400')
|
||||||
->will($this->throwException($exception));
|
->will($this->throwException($exception));
|
||||||
|
|
||||||
$ExceptionRenderer->controller->expects($this->at(3))
|
$response = $this->getMock('CakeResponse');
|
||||||
->method('render')
|
$response->expects($this->once())
|
||||||
->with('error500')
|
->method('body')
|
||||||
->will($this->returnValue(true));
|
->with($this->stringContains('Not Found'));
|
||||||
|
$response->expects($this->once())
|
||||||
$ExceptionRenderer->controller->response = $this->getMock('CakeResponse');
|
|
||||||
$ExceptionRenderer->controller->response->expects($this->once())
|
|
||||||
->method('type')
|
->method('type')
|
||||||
->with('html');
|
->with('html');
|
||||||
|
|
||||||
|
$ExceptionRenderer->controller->response = $response;
|
||||||
|
|
||||||
$ExceptionRenderer->render();
|
$ExceptionRenderer->render();
|
||||||
$this->assertEquals('', $ExceptionRenderer->controller->layoutPath);
|
$this->assertEquals('', $ExceptionRenderer->controller->layoutPath);
|
||||||
$this->assertEquals('', $ExceptionRenderer->controller->subDir);
|
$this->assertEquals('', $ExceptionRenderer->controller->subDir);
|
||||||
$this->assertEquals('View', $ExceptionRenderer->controller->viewClass);
|
|
||||||
$this->assertEquals('Errors/', $ExceptionRenderer->controller->viewPath);
|
$this->assertEquals('Errors/', $ExceptionRenderer->controller->viewPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -411,14 +411,18 @@ class CakeEmailTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testMessageIdWithDomain() {
|
public function testMessageIdWithDomain() {
|
||||||
$result = $this->CakeEmail->getHeaders();
|
|
||||||
$expected = '@' . (env('HTTP_HOST') ? env('HTTP_HOST') : php_uname('n')) . '>';
|
|
||||||
$this->assertTextContains($expected, $result['Message-ID']);
|
|
||||||
|
|
||||||
$this->CakeEmail->domain('example.org');
|
$this->CakeEmail->domain('example.org');
|
||||||
$result = $this->CakeEmail->getHeaders();
|
$result = $this->CakeEmail->getHeaders();
|
||||||
$expected = '@example.org>';
|
$expected = '@example.org>';
|
||||||
$this->assertTextContains($expected, $result['Message-ID']);
|
$this->assertTextContains($expected, $result['Message-ID']);
|
||||||
|
|
||||||
|
$_SERVER['HTTP_HOST'] = 'example.org';
|
||||||
|
$result = $this->CakeEmail->getHeaders();
|
||||||
|
$this->assertTextContains('example.org', $result['Message-ID']);
|
||||||
|
|
||||||
|
$_SERVER['HTTP_HOST'] = 'example.org:81';
|
||||||
|
$result = $this->CakeEmail->getHeaders();
|
||||||
|
$this->assertTextNotContains(':81', $result['Message-ID']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1826,32 +1826,32 @@ class ValidationTest extends CakeTestCase {
|
||||||
$this->assertTrue(Validation::url('ftp://cakephp.org/pub/cake'));
|
$this->assertTrue(Validation::url('ftp://cakephp.org/pub/cake'));
|
||||||
$this->assertTrue(Validation::url('ftp://192.168.0.1/pub/cake'));
|
$this->assertTrue(Validation::url('ftp://192.168.0.1/pub/cake'));
|
||||||
$this->assertTrue(Validation::url('sftp://192.168.0.1/pub/cake'));
|
$this->assertTrue(Validation::url('sftp://192.168.0.1/pub/cake'));
|
||||||
$this->assertFalse(Validation::url('ftps://256.168.0.1/pub/cake'));
|
|
||||||
$this->assertFalse(Validation::url('ftp://256.168.0.1/pub/cake'));
|
|
||||||
$this->assertTrue(Validation::url('https://my.domain.com/gizmo/app?class=MySip;proc=start'));
|
$this->assertTrue(Validation::url('https://my.domain.com/gizmo/app?class=MySip;proc=start'));
|
||||||
$this->assertTrue(Validation::url('www.domain.tld'));
|
$this->assertTrue(Validation::url('www.domain.tld'));
|
||||||
|
$this->assertTrue(Validation::url('http://123456789112345678921234567893123456789412345678951234567896123.com'));
|
||||||
|
$this->assertTrue(Validation::url('http://www.domain.com/blogs/index.php?blog=6&tempskin=_rss2'));
|
||||||
|
$this->assertTrue(Validation::url('http://www.domain.com/blogs/parenth()eses.php'));
|
||||||
|
$this->assertTrue(Validation::url('http://www.domain.com/index.php?get=params&get2=params'));
|
||||||
|
$this->assertTrue(Validation::url('http://www.domain.com/ndex.php?get=params&get2=params#anchor'));
|
||||||
|
$this->assertTrue(Validation::url('http://www.domain.com/real%20url%20encodeing'));
|
||||||
|
$this->assertTrue(Validation::url('http://en.wikipedia.org/wiki/Architectural_pattern_(computer_science)'));
|
||||||
|
$this->assertTrue(Validation::url('http://www.cakephp.org', true));
|
||||||
|
$this->assertTrue(Validation::url('http://example.com/~userdir/'));
|
||||||
|
$this->assertTrue(Validation::url('http://underscore_subdomain.example.org'));
|
||||||
|
$this->assertTrue(Validation::url('http://_jabber._tcp.gmail.com'));
|
||||||
|
$this->assertFalse(Validation::url('ftps://256.168.0.1/pub/cake'));
|
||||||
|
$this->assertFalse(Validation::url('ftp://256.168.0.1/pub/cake'));
|
||||||
$this->assertFalse(Validation::url('http://w_w.domain.co_m'));
|
$this->assertFalse(Validation::url('http://w_w.domain.co_m'));
|
||||||
$this->assertFalse(Validation::url('http://www.domain.12com'));
|
$this->assertFalse(Validation::url('http://www.domain.12com'));
|
||||||
$this->assertFalse(Validation::url('http://www.domain.longttldnotallowed'));
|
$this->assertFalse(Validation::url('http://www.domain.longttldnotallowed'));
|
||||||
$this->assertFalse(Validation::url('http://www.-invaliddomain.tld'));
|
$this->assertFalse(Validation::url('http://www.-invaliddomain.tld'));
|
||||||
$this->assertFalse(Validation::url('http://www.domain.-invalidtld'));
|
$this->assertFalse(Validation::url('http://www.domain.-invalidtld'));
|
||||||
$this->assertTrue(Validation::url('http://123456789112345678921234567893123456789412345678951234567896123.com'));
|
|
||||||
$this->assertFalse(Validation::url('http://this-domain-is-too-loooooong-by-icann-rules-maximum-length-is-63.com'));
|
$this->assertFalse(Validation::url('http://this-domain-is-too-loooooong-by-icann-rules-maximum-length-is-63.com'));
|
||||||
$this->assertTrue(Validation::url('http://www.domain.com/blogs/index.php?blog=6&tempskin=_rss2'));
|
|
||||||
$this->assertTrue(Validation::url('http://www.domain.com/blogs/parenth()eses.php'));
|
|
||||||
$this->assertTrue(Validation::url('http://www.domain.com/index.php?get=params&get2=params'));
|
|
||||||
$this->assertTrue(Validation::url('http://www.domain.com/ndex.php?get=params&get2=params#anchor'));
|
|
||||||
$this->assertFalse(Validation::url('http://www.domain.com/fakeenco%ode'));
|
|
||||||
$this->assertTrue(Validation::url('http://www.domain.com/real%20url%20encodeing'));
|
|
||||||
$this->assertTrue(Validation::url('http://en.wikipedia.org/wiki/Architectural_pattern_(computer_science)'));
|
|
||||||
$this->assertFalse(Validation::url('http://en.(wikipedia).org/'));
|
|
||||||
$this->assertFalse(Validation::url('www.cakephp.org', true));
|
|
||||||
$this->assertTrue(Validation::url('http://www.cakephp.org', true));
|
|
||||||
$this->assertTrue(Validation::url('http://example.com/~userdir/'));
|
|
||||||
$this->assertTrue(Validation::url('http://underscore_subdomain.example.org'));
|
|
||||||
$this->assertTrue(Validation::url('http://_jabber._tcp.gmail.com'));
|
|
||||||
$this->assertFalse(Validation::url('http://www.underscore_domain.org'));
|
$this->assertFalse(Validation::url('http://www.underscore_domain.org'));
|
||||||
$this->assertFalse(Validation::url('http://_jabber._tcp.g_mail.com'));
|
$this->assertFalse(Validation::url('http://_jabber._tcp.g_mail.com'));
|
||||||
|
$this->assertFalse(Validation::url('http://en.(wikipedia).org/'));
|
||||||
|
$this->assertFalse(Validation::url('http://www.domain.com/fakeenco%ode'));
|
||||||
|
$this->assertFalse(Validation::url('www.cakephp.org', true));
|
||||||
|
|
||||||
$this->assertTrue(Validation::url('http://example.com/~userdir/subdir/index.html'));
|
$this->assertTrue(Validation::url('http://example.com/~userdir/subdir/index.html'));
|
||||||
$this->assertTrue(Validation::url('http://www.zwischenraume.de'));
|
$this->assertTrue(Validation::url('http://www.zwischenraume.de'));
|
||||||
|
|
Loading…
Reference in a new issue