Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
64c4d8e7
Commit
64c4d8e7
authored
Jan 01, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #1733: Incorrect code about `$_modelClasses` in `DbFixtureManager`
parent
4f346f4b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
9 deletions
+8
-9
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
DbFixtureManager.php
framework/yii/test/DbFixtureManager.php
+7
-9
No files found.
framework/CHANGELOG.md
View file @
64c4d8e7
...
...
@@ -20,6 +20,7 @@ Yii Framework 2 Change Log
-
Bug #1686: ActiveForm is creating duplicated messages in error summary (qiangxue)
-
Bug #1704: Incorrect regexp is used in
`Inflector::camelize()`
(qiangxue)
-
Bug #1710: OpenId auth client does not request required attributes correctly (klimov-paul)
-
Bug #1733: Incorrect code about
`$_modelClasses`
in
`DbFixtureManager`
(qiangxue)
-
Bug: Fixed
`Call to a member function registerAssetFiles() on a non-object`
in case of wrong
`sourcePath`
for an asset bundle (samdark)
-
Bug: Fixed incorrect event name for
`yii\jui\Spinner`
(samdark)
-
Bug: Json::encode() did not handle objects that implement JsonSerializable interface correctly (cebe)
...
...
framework/yii/test/DbFixtureManager.php
View file @
64c4d8e7
...
...
@@ -10,7 +10,7 @@ namespace yii\test;
use
Yii
;
use
yii\base\Component
;
use
yii\base\InvalidConfigException
;
use
yii\db\ActiveRecord
Interface
;
use
yii\db\ActiveRecord
;
use
yii\db\Connection
;
/**
...
...
@@ -59,7 +59,6 @@ class DbFixtureManager extends Component
private
$_rows
;
// fixture name, row alias => row
private
$_models
;
// fixture name, row alias => record (or class name)
private
$_modelClasses
;
/**
...
...
@@ -92,8 +91,7 @@ class DbFixtureManager extends Component
foreach
(
$fixtures
as
$name
=>
$fixture
)
{
if
(
strpos
(
$fixture
,
'\\'
)
!==
false
)
{
$model
=
new
$fixture
;
if
(
$model
instanceof
ActiveRecordInterface
)
{
$this
->
_modelClasses
[
$name
]
=
$fixture
;
if
(
$model
instanceof
ActiveRecord
)
{
$fixtures
[
$name
]
=
$model
->
getTableSchema
()
->
name
;
}
else
{
throw
new
InvalidConfigException
(
"Fixture '
$fixture
' must be an ActiveRecord class."
);
...
...
@@ -101,7 +99,7 @@ class DbFixtureManager extends Component
}
}
$this
->
_
modelClasses
=
$this
->
_
rows
=
$this
->
_models
=
[];
$this
->
_rows
=
$this
->
_models
=
[];
$this
->
checkIntegrity
(
false
);
...
...
@@ -184,20 +182,20 @@ class DbFixtureManager extends Component
* Returns the specified ActiveRecord instance in the fixture data.
* @param string $fixtureName the fixture name
* @param string $modelName the alias for the fixture data row
* @return ActiveRecord
Interface
the ActiveRecord instance. Null is returned if there is no such fixture row.
* @return ActiveRecord the ActiveRecord instance. Null is returned if there is no such fixture row.
*/
public
function
getModel
(
$fixtureName
,
$modelName
)
{
if
(
!
isset
(
$this
->
_
modelClasses
[
$fixtureName
])
||
!
isset
(
$this
->
_
rows
[
$fixtureName
][
$modelName
]))
{
if
(
!
isset
(
$this
->
_rows
[
$fixtureName
][
$modelName
]))
{
return
null
;
}
if
(
isset
(
$this
->
_models
[
$fixtureName
][
$modelName
]))
{
return
$this
->
_models
[
$fixtureName
][
$modelName
];
}
$row
=
$this
->
_rows
[
$fixtureName
][
$modelName
];
/** @var ActiveRecord
Interface
$modelClass */
/** @var ActiveRecord $modelClass */
$modelClass
=
$this
->
_models
[
$fixtureName
];
/** @var ActiveRecord
Interface
$model */
/** @var ActiveRecord $model */
$model
=
new
$modelClass
;
$keys
=
[];
foreach
(
$model
->
primaryKey
()
as
$key
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment