Repository: Clone a filter implicitly in self::requireFilter($clone = true)
refs #8826
This commit is contained in:
parent
4bd36bc500
commit
beb5bd7370
|
@ -126,7 +126,7 @@ class DbUserBackend extends DbRepository implements UserBackendInterface
|
|||
{
|
||||
$bind['last_modified'] = date('Y-m-d H:i:s');
|
||||
if ($filter) {
|
||||
$this->requireFilter($table, $filter);
|
||||
$filter = $this->requireFilter($table, $filter);
|
||||
}
|
||||
|
||||
$this->ds->update(
|
||||
|
|
|
@ -296,7 +296,7 @@ abstract class DbRepository extends Repository implements Extensible, Updatable,
|
|||
public function update($table, array $bind, Filter $filter = null)
|
||||
{
|
||||
if ($filter) {
|
||||
$this->requireFilter($table, $filter);
|
||||
$filter = $this->requireFilter($table, $filter);
|
||||
}
|
||||
|
||||
$this->ds->update($this->prependTablePrefix($table), $this->requireStatementColumns($table, $bind), $filter);
|
||||
|
@ -311,7 +311,7 @@ abstract class DbRepository extends Repository implements Extensible, Updatable,
|
|||
public function delete($table, Filter $filter = null)
|
||||
{
|
||||
if ($filter) {
|
||||
$this->requireFilter($table, $filter);
|
||||
$filter = $this->requireFilter($table, $filter);
|
||||
}
|
||||
|
||||
$this->ds->delete($this->prependTablePrefix($table), $filter);
|
||||
|
@ -478,10 +478,13 @@ abstract class DbRepository extends Repository implements Extensible, Updatable,
|
|||
* @param Filter $filter The filter to recurse
|
||||
* @param RepositoryQuery $query An optional query to pass as context
|
||||
* (Directly passed through to $this->requireFilterColumn)
|
||||
* @param bool $clone Whether to clone $filter first
|
||||
*
|
||||
* @return Filter The udpated filter
|
||||
*/
|
||||
public function requireFilter($table, Filter $filter, RepositoryQuery $query = null)
|
||||
public function requireFilter($table, Filter $filter, RepositoryQuery $query = null, $clone = true)
|
||||
{
|
||||
parent::requireFilter($table, $filter, $query);
|
||||
$filter = parent::requireFilter($table, $filter, $query, $clone);
|
||||
|
||||
if ($filter->isExpression()) {
|
||||
$column = $filter->getColumn();
|
||||
|
@ -495,6 +498,8 @@ abstract class DbRepository extends Repository implements Extensible, Updatable,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $filter;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -94,7 +94,7 @@ abstract class IniRepository extends Repository implements Extensible, Updatable
|
|||
}
|
||||
|
||||
if ($filter !== null) {
|
||||
$this->requireFilter($target, $filter);
|
||||
$filter = $this->requireFilter($target, $filter);
|
||||
}
|
||||
|
||||
$newSection = null;
|
||||
|
@ -147,7 +147,7 @@ abstract class IniRepository extends Repository implements Extensible, Updatable
|
|||
public function delete($target, Filter $filter = null)
|
||||
{
|
||||
if ($filter !== null) {
|
||||
$this->requireFilter($target, $filter);
|
||||
$filter = $this->requireFilter($target, $filter);
|
||||
}
|
||||
|
||||
foreach (iterator_to_array($this->ds) as $section => $config) {
|
||||
|
|
|
@ -627,18 +627,27 @@ abstract class Repository implements Selectable
|
|||
* @param Filter $filter The filter to recurse
|
||||
* @param RepositoryQuery $query An optional query to pass as context
|
||||
* (Directly passed through to $this->requireFilterColumn)
|
||||
* @param bool $clone Whether to clone $filter first
|
||||
*
|
||||
* @return Filter The udpated filter
|
||||
*/
|
||||
public function requireFilter($table, Filter $filter, RepositoryQuery $query = null)
|
||||
public function requireFilter($table, Filter $filter, RepositoryQuery $query = null, $clone = true)
|
||||
{
|
||||
if ($clone) {
|
||||
$filter = clone $filter;
|
||||
}
|
||||
|
||||
if ($filter->isExpression()) {
|
||||
$column = $filter->getColumn();
|
||||
$filter->setColumn($this->requireFilterColumn($table, $column, $query));
|
||||
$filter->setExpression($this->persistColumn($table, $column, $filter->getExpression()));
|
||||
} elseif ($filter->isChain()) {
|
||||
foreach ($filter->filters() as $chainOrExpression) {
|
||||
$this->requireFilter($table, $chainOrExpression, $query);
|
||||
$this->requireFilter($table, $chainOrExpression, $query, false);
|
||||
}
|
||||
}
|
||||
|
||||
return $filter;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -183,9 +183,7 @@ class RepositoryQuery implements QueryInterface, Iterator
|
|||
*/
|
||||
public function setFilter(Filter $filter)
|
||||
{
|
||||
$filter = clone $filter;
|
||||
$this->repository->requireFilter($this->target, $filter, $this);
|
||||
$this->query->setFilter($filter);
|
||||
$this->query->setFilter($this->repository->requireFilter($this->target, $filter, $this));
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -200,9 +198,7 @@ class RepositoryQuery implements QueryInterface, Iterator
|
|||
*/
|
||||
public function addFilter(Filter $filter)
|
||||
{
|
||||
$filter = clone $filter;
|
||||
$this->repository->requireFilter($this->target, $filter, $this);
|
||||
$this->query->addFilter($filter);
|
||||
$this->query->addFilter($this->repository->requireFilter($this->target, $filter, $this));
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue