Skip to content

Commit 5600502

Browse files
committed
Merge tag '2.0.4'
Hotfix release 2.0.4 - Initialize attributes with empty values.
2 parents 6fd2af7 + e06380d commit 5600502

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/MetaModels/DcGeneral/Data/Driver.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* @author David Molineus <david.molineus@netzmacht.de>
1919
* @author binron <rtb@gmx.ch>
2020
* @author Sven Baumann <baumann.sv@gmail.com>
21+
* @author Richard Henkenjohann <richardhenkenjohann@googlemail.com>
2122
* @copyright 2012-2018 The MetaModels team.
2223
* @license https://github.com/MetaModels/core/blob/master/LICENSE LGPL-3.0-or-later
2324
* @filesource
@@ -304,7 +305,7 @@ public function getEmptyConfig()
304305
*/
305306
public function getEmptyModel()
306307
{
307-
$objItem = new Item($this->getMetaModel(), array());
308+
$objItem = new Item($this->getMetaModel(), null);
308309
return new Model($objItem);
309310
}
310311

src/MetaModels/Item.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,19 @@ class Item implements IItem
6161
*
6262
* @param IMetaModel $objMetaModel The model this item is represented by.
6363
*
64-
* @param array $arrData The initial data that shall be injected into the new instance.
64+
* @param array|null $arrData The initial data that shall be injected into the new instance.
6565
*/
6666
public function __construct(IMetaModel $objMetaModel, $arrData)
6767
{
68+
if (null === $arrData) {
69+
// Initialize attributes with empty values.
70+
$arrData = [];
71+
72+
foreach ($objMetaModel->getAttributes() as $attribute) {
73+
$arrData[$attribute->getColName()] = null;
74+
}
75+
}
76+
6877
$this->arrData = $arrData;
6978
$this->metaModel = $objMetaModel;
7079
}

0 commit comments

Comments
 (0)