From e36a27aa03090a217744b8dfc6e719d8528f88c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20R?= Date: Wed, 4 Jul 2018 16:58:19 +0200 Subject: [PATCH] EZP-29376: New SiteAccess aware repo not handling languages when using sudo() (#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. --- eZ/Publish/Core/Repository/Repository.php | 7 ++----- eZ/Publish/Core/Repository/SiteAccessAware/Repository.php | 4 ++-- eZ/Publish/Core/SignalSlot/Repository.php | 5 +++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/eZ/Publish/Core/Repository/Repository.php b/eZ/Publish/Core/Repository/Repository.php index 8ae4c31154c..58d1b0e924c 100644 --- a/eZ/Publish/Core/Repository/Repository.php +++ b/eZ/Publish/Core/Repository/Repository.php @@ -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 @@ -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); } /** diff --git a/eZ/Publish/Core/Repository/SiteAccessAware/Repository.php b/eZ/Publish/Core/Repository/SiteAccessAware/Repository.php index 9bd65ae4908..dfa3eb70afe 100644 --- a/eZ/Publish/Core/Repository/SiteAccessAware/Repository.php +++ b/eZ/Publish/Core/Repository/SiteAccessAware/Repository.php @@ -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) diff --git a/eZ/Publish/Core/SignalSlot/Repository.php b/eZ/Publish/Core/SignalSlot/Repository.php index ca33aec5cd5..11fa3d4fe19 100644 --- a/eZ/Publish/Core/SignalSlot/Repository.php +++ b/eZ/Publish/Core/SignalSlot/Repository.php @@ -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); } /**