Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
EZP-29376: New SiteAccess aware repo not handling languages when usin…
…g sudo() (ezsystems#2376)

Another issue found and fixed late in the review of SiteAccess Aware repo, broke usage
out of the box with ContentView as it is using sudo() which was no longer passing right
repository.

PR here is cleaning up the signature for sudo() on all Repo implementations
so this is not an issue anymore.
  • Loading branch information
andrerom committed Jul 4, 2018
1 parent ec9b6e5 commit e36a27a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
7 changes: 2 additions & 5 deletions eZ/Publish/Core/Repository/Repository.php
Expand Up @@ -378,7 +378,7 @@ public function setCurrentUser(APIUserReference $user)
*
*
* @param \Closure $callback
* @param \eZ\Publish\API\Repository\Repository $outerRepository
* @param \eZ\Publish\API\Repository\Repository|null $outerRepository
*
* @throws \RuntimeException Thrown on recursive sudo() use.
* @throws \Exception Re throws exceptions thrown inside $callback
Expand All @@ -387,10 +387,7 @@ public function setCurrentUser(APIUserReference $user)
*/
public function sudo(Closure $callback, RepositoryInterface $outerRepository = null)
{
return $this->getPermissionResolver()->sudo(
$callback,
$outerRepository !== null ? $outerRepository : $this
);
return $this->getPermissionResolver()->sudo($callback, $outerRepository ?? $this);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions eZ/Publish/Core/Repository/SiteAccessAware/Repository.php
Expand Up @@ -100,9 +100,9 @@ public function setCurrentUser(UserReference $user)
return $this->repository->setCurrentUser($user);
}

public function sudo(Closure $callback)
public function sudo(Closure $callback, RepositoryInterface $outerRepository = null)
{
return $this->repository->sudo($callback, $this);
return $this->repository->sudo($callback, $outerRepository ?? $this);
}

public function hasAccess($module, $function, UserReference $user = null)
Expand Down
5 changes: 3 additions & 2 deletions eZ/Publish/Core/SignalSlot/Repository.php
Expand Up @@ -261,15 +261,16 @@ public function setCurrentUser(UserReference $user)
*
*
* @param \Closure $callback
* @param \eZ\Publish\API\Repository\Repository|null $outerRepository
*
* @throws \RuntimeException Thrown on recursive sudo() use.
* @throws \Exception Re throws exceptions thrown inside $callback
*
* @return mixed
*/
public function sudo(Closure $callback)
public function sudo(Closure $callback, RepositoryInterface $outerRepository = null)
{
return $this->repository->sudo($callback, $this);
return $this->repository->sudo($callback, $outerRepository ?? $this);
}

/**
Expand Down

0 comments on commit e36a27a

Please sign in to comment.