Skip to content
Permalink
Browse files

BUG: MIDASDatabasePdo: Remove costly call in link() function

Since in the context of Slicer, it is safe to assume that no duplicated links
will be added, this commit removes the explicit check.

See midasplatform#69
  • Loading branch information
jcfr committed Apr 28, 2019
1 parent 9a46f14 commit 0d609469f69e464080ee02dd0eaf6f615bc17ff9
Showing with 14 additions and 10 deletions.
  1. +14 −10 core/models/MIDASDatabasePdo.php
@@ -201,15 +201,13 @@ protected function getLinkedObject($var, $dao)
/**
* @method function link($var, $daoParent, $daoSon)
* create a link between 2 tables
* @param $var name of the attribute we search
* @param $var name of the attribute we link
* @param $daoParent
* @param $daoSon
* @return sql result
*/
public function link($var, $daoParent, $daoSon)
{
$objs = $daoParent->get($var);
if(isset($this->_mainData[$var]['module']))
{
$model = MidasLoader::loadModel($this->_mainData[$var]['model'],
@@ -219,13 +217,19 @@ public function link($var, $daoParent, $daoSon)
{
$model = MidasLoader::loadModel($this->_mainData[$var]['model']);
}
foreach($objs as $obj)
{
if($model->compareDao($obj, $daoSon))
{
return;
}
}
// The following code is:
// (1) iterating over all objects of type <var> linked in $daoParent. <var> could be "items", "communities", "users"
// (2) returning if the object being added to $daoParent is found. The comparison is done by comparing all the
// columns declared as MIDAS_DATA in <var>ModelBase)
//
//$objs = $daoParent->get($var);
//foreach($objs as $obj)
// {
// if($model->compareDao($obj, $daoSon))
// {
// return;
// }
// }
unset($daoParent->$var);
$data = array();

1 comment on commit 0d60946

@jcfr

This comment has been minimized.

Copy link
Member Author

jcfr commented on 0d60946 Apr 29, 2019

Please sign in to comment.
You can’t perform that action at this time.