mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Dont use private attributes as tables in CakeSchema. Fixes #7
This commit is contained in:
parent
69ee014a60
commit
ae2fa908c5
2 changed files with 26 additions and 0 deletions
|
@ -116,6 +116,9 @@ class CakeSchema extends Object {
|
||||||
foreach ($data as $key => $val) {
|
foreach ($data as $key => $val) {
|
||||||
if (!empty($val)) {
|
if (!empty($val)) {
|
||||||
if (!in_array($key, array('plugin', 'name', 'path', 'file', 'connection', 'tables', '_log'))) {
|
if (!in_array($key, array('plugin', 'name', 'path', 'file', 'connection', 'tables', '_log'))) {
|
||||||
|
if ($key[0] === '_') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$this->tables[$key] = $val;
|
$this->tables[$key] = $val;
|
||||||
unset($this->{$key});
|
unset($this->{$key});
|
||||||
} elseif ($key !== 'tables') {
|
} elseif ($key !== 'tables') {
|
||||||
|
|
|
@ -80,6 +80,14 @@ class MyAppSchema extends CakeSchema {
|
||||||
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => true)),
|
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => true)),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* _foo property
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
protected $_foo = array('bar');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setup method
|
* setup method
|
||||||
*
|
*
|
||||||
|
@ -99,6 +107,19 @@ class MyAppSchema extends CakeSchema {
|
||||||
*/
|
*/
|
||||||
function teardown($version) {
|
function teardown($version) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getVar method
|
||||||
|
*
|
||||||
|
* @param string $var Name of var
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getVar($var) {
|
||||||
|
if (!isset($this->$var)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return $this->$var;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -750,6 +771,8 @@ class CakeSchemaTest extends CakeTestCase {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
$this->assertEqual($expected, $compare);
|
$this->assertEqual($expected, $compare);
|
||||||
|
$this->assertNull($New->getVar('comments'));
|
||||||
|
$this->assertEqual($New->getVar('_foo'), array('bar'));
|
||||||
|
|
||||||
$tables = array(
|
$tables = array(
|
||||||
'missing' => array(
|
'missing' => array(
|
||||||
|
|
Loading…
Reference in a new issue