Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Register the related models in the registry (see contao/core-bundle#333
Browse files Browse the repository at this point in the history
…).
  • Loading branch information
leofeyer committed Aug 24, 2015
1 parent 2058492 commit 8ede060
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions system/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Contao Open Source CMS changelog
Version 3.5.3 (2015-XX-XX)
--------------------------

### Fixed
Register the related models in the registry (see contao/core-bundle#333).

### Fixed
Correctly escape in the `findMultipleFilesByFolder()` method (see #7966).

Expand Down
8 changes: 6 additions & 2 deletions system/modules/core/library/Contao/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ public function __construct(\Database\Result $objResult=null)
}
}

$objRegistry = \Model\Registry::getInstance();

// Create the related models
foreach ($arrRelated as $key=>$row)
{
Expand All @@ -152,7 +154,7 @@ public function __construct(\Database\Result $objResult=null)
}
else
{
$objRelated = \Model\Registry::getInstance()->fetch($table, $row[$intPk]);
$objRelated = $objRegistry->fetch($table, $row[$intPk]);

if ($objRelated !== null)
{
Expand All @@ -163,14 +165,16 @@ public function __construct(\Database\Result $objResult=null)
/** @var static $objRelated */
$objRelated = new $strClass();
$objRelated->setRow($row);

$objRegistry->register($objRelated);
}

$this->arrRelated[$key] = $objRelated;
}
}

$this->setRow($arrData); // see #5439
\Model\Registry::getInstance()->register($this);
$objRegistry->register($this);
}
}

Expand Down
2 changes: 1 addition & 1 deletion system/modules/core/library/Contao/Model/Registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function fetchByAlias($strTable, $strAlias, $varValue)
/**
* Register a model in the registry
*
* @param \Model $objModel The model object
* @param \Model|\Contao\Model $objModel The model object
*
* @throws \RuntimeException If the instance exists already
*/
Expand Down

0 comments on commit 8ede060

Please sign in to comment.