mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Merge branch '1.2' of github.com:cakephp/cakephp1x into 1.2
This commit is contained in:
commit
45ef3c6151
3 changed files with 54 additions and 2 deletions
|
@ -2631,7 +2631,7 @@ class Model extends Overloadable {
|
||||||
$field = $this->primaryKey;
|
$field = $this->primaryKey;
|
||||||
}
|
}
|
||||||
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
||||||
if (strpos($field, $db->name($alias)) === 0) {
|
if (strpos($field, $db->name($alias) . '.') === 0) {
|
||||||
return $field;
|
return $field;
|
||||||
}
|
}
|
||||||
return $db->name($alias . '.' . $field);
|
return $db->name($alias . '.' . $field);
|
||||||
|
|
|
@ -148,7 +148,7 @@ class MediaView extends View {
|
||||||
$contentTypes[0] = 'application/octetstream';
|
$contentTypes[0] = 'application/octetstream';
|
||||||
} else if (preg_match('/MSIE ([0-9].[0-9]{1,2})/', $agent)) {
|
} else if (preg_match('/MSIE ([0-9].[0-9]{1,2})/', $agent)) {
|
||||||
$contentTypes[0] = 'application/force-download';
|
$contentTypes[0] = 'application/force-download';
|
||||||
array_push($contentTypes, array(
|
array_merge($contentTypes, array(
|
||||||
'application/octet-stream',
|
'application/octet-stream',
|
||||||
'application/download'
|
'application/download'
|
||||||
));
|
));
|
||||||
|
|
|
@ -24,6 +24,27 @@
|
||||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||||
*/
|
*/
|
||||||
require_once dirname(__FILE__) . DS . 'model.test.php';
|
require_once dirname(__FILE__) . DS . 'model.test.php';
|
||||||
|
App::import('Core', 'DboSource');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DboMock class
|
||||||
|
* A Dbo Source driver to mock a connection and a identity name() method
|
||||||
|
*/
|
||||||
|
class DboMock extends DboSource {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the $field without modifications
|
||||||
|
*/
|
||||||
|
function name($field) {
|
||||||
|
return $field;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Returns true to fake a database connection
|
||||||
|
*/
|
||||||
|
function connect() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ModelIntegrationTest
|
* ModelIntegrationTest
|
||||||
|
@ -1831,5 +1852,36 @@ class ModelIntegrationTest extends BaseModelTest {
|
||||||
$this->assertEqual($FeaturedModel->create($data), $expected);
|
$this->assertEqual($FeaturedModel->create($data), $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* testEscapeField to prove it escapes the field well even when it has part of the alias on it
|
||||||
|
* @see ttp://cakephp.lighthouseapp.com/projects/42648-cakephp-1x/tickets/473-escapefield-doesnt-consistently-prepend-modelname
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testEscapeField() {
|
||||||
|
$TestModel =& new Test();
|
||||||
|
$db =& $TestModel->getDataSource();
|
||||||
|
|
||||||
|
$result = $TestModel->escapeField('test_field');
|
||||||
|
$expected = $db->name('Test.test_field');
|
||||||
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
|
$result = $TestModel->escapeField('TestField');
|
||||||
|
$expected = $db->name('Test.TestField');
|
||||||
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
|
$result = $TestModel->escapeField('DomainHandle', 'Domain');
|
||||||
|
$expected = $db->name('Domain.DomainHandle');
|
||||||
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
|
ConnectionManager::create('mock', array('driver' => 'mock'));
|
||||||
|
$TestModel->setDataSource('mock');
|
||||||
|
$db =& $TestModel->getDataSource();
|
||||||
|
|
||||||
|
$result = $TestModel->escapeField('DomainHandle', 'Domain');
|
||||||
|
$expected = $db->name('Domain.DomainHandle');
|
||||||
|
$this->assertEqual($result, $expected);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
Loading…
Reference in a new issue