mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Merge pull request #153 from ajibarra/e4c1f28d849c6a60c369265a502315260babe80b
Preventing AppModel to be inspected inside CakeSchema
This commit is contained in:
commit
7596fcf45a
2 changed files with 44 additions and 3 deletions
|
@ -224,11 +224,16 @@ class CakeSchema extends Object {
|
||||||
$models = App::objects('Model');
|
$models = App::objects('Model');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($models)) {
|
if (is_array($models)) {
|
||||||
foreach ($models as $model) {
|
foreach ($models as $model) {
|
||||||
$importModel = $model;
|
$importModel = $model;
|
||||||
$plugin = null;
|
$plugin = null;
|
||||||
|
|
||||||
|
if ($model == 'AppModel') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($this->plugin)) {
|
if (isset($this->plugin)) {
|
||||||
if ($model == $this->plugin . 'AppModel') {
|
if ($model == $this->plugin . 'AppModel') {
|
||||||
continue;
|
continue;
|
||||||
|
@ -236,7 +241,7 @@ class CakeSchema extends Object {
|
||||||
$importModel = $model;
|
$importModel = $model;
|
||||||
$plugin = $this->plugin . '.';
|
$plugin = $this->plugin . '.';
|
||||||
}
|
}
|
||||||
|
|
||||||
App::uses($importModel, $plugin . 'Model');
|
App::uses($importModel, $plugin . 'Model');
|
||||||
if (!class_exists($importModel)) {
|
if (!class_exists($importModel)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -290,7 +295,7 @@ class CakeSchema extends Object {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($currentTables)) {
|
if (!empty($currentTables)) {
|
||||||
foreach ($currentTables as $table) {
|
foreach ($currentTables as $table) {
|
||||||
if ($prefix) {
|
if ($prefix) {
|
||||||
|
@ -324,6 +329,7 @@ class CakeSchema extends Object {
|
||||||
|
|
||||||
ksort($tables);
|
ksort($tables);
|
||||||
return compact('name', 'tables');
|
return compact('name', 'tables');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -602,6 +602,41 @@ class CakeSchemaTest extends CakeTestCase {
|
||||||
));
|
));
|
||||||
$this->assertFalse(isset($read['tables']['missing']['posts_tags']), 'Join table marked as missing');
|
$this->assertFalse(isset($read['tables']['missing']['posts_tags']), 'Join table marked as missing');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* testSchemaReadWithAppModel method
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testSchemaReadWithAppModel() {
|
||||||
|
$connections = ConnectionManager::enumConnectionObjects();
|
||||||
|
if (!empty($connections['default'])) {
|
||||||
|
$backup = $connections['default'];
|
||||||
|
ConnectionManager::drop('default');
|
||||||
|
}
|
||||||
|
ConnectionManager::create('default', $connections['test']);
|
||||||
|
try {
|
||||||
|
$read = $this->Schema->read(array(
|
||||||
|
'connection' => 'default',
|
||||||
|
'name' => 'TestApp',
|
||||||
|
'models' => array('AppModel')
|
||||||
|
));
|
||||||
|
unset($read['tables']['missing']);
|
||||||
|
$this->assertTrue(empty($read['tables']));
|
||||||
|
if (!empty($backup)) {
|
||||||
|
ConnectionManager::drop('default');
|
||||||
|
ConnectionManager::create('default', $backup);
|
||||||
|
}
|
||||||
|
} catch(MissingTableException $mte) {
|
||||||
|
if (!empty($backup)) {
|
||||||
|
ConnectionManager::drop('default');
|
||||||
|
ConnectionManager::create('default', $backup);
|
||||||
|
}
|
||||||
|
$this->fail($mte->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testSchemaReadWithOddTablePrefix method
|
* testSchemaReadWithOddTablePrefix method
|
||||||
|
|
Loading…
Reference in a new issue