Skip to content

Commit

Permalink
MERGE: Merge branch '3.3' into 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kdambekalns committed Jun 25, 2018
2 parents bfb9240 + cfe0b81 commit ecfc1c2
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 19 deletions.
58 changes: 40 additions & 18 deletions Classes/Domain/Service/UserService.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Neos\Flow\Annotations as Flow;
use Neos\Flow\Persistence\Exception\IllegalObjectTypeException;
use Neos\Flow\Persistence\PersistenceManagerInterface;
use Neos\Flow\Security\Account;
use Neos\Flow\Security\AccountFactory;
use Neos\Flow\Security\AccountRepository;
Expand Down Expand Up @@ -125,6 +126,12 @@ class UserService
*/
protected $hashService;

/**
* @Flow\Inject
* @var PersistenceManagerInterface
*/
protected $persistenceManager;

/**
* @Flow\Inject(lazy = FALSE)
* @var Now
Expand Down Expand Up @@ -158,27 +165,21 @@ public function getUsers()
*/
public function getUser($username, $authenticationProviderName = null)
{
if ($authenticationProviderName !== null && isset($this->runtimeUserCache['a_' . $authenticationProviderName][$username])) {
return $this->runtimeUserCache['a_' . $authenticationProviderName][$username];
} elseif (isset($this->runtimeUserCache['u_' . $username])) {
return $this->runtimeUserCache['u_' . $username];
$authenticationProviderName = $authenticationProviderName ?: $this->defaultAuthenticationProviderName;
$cacheIdentifier = $authenticationProviderName . '~' . $username;

if (!array_key_exists($cacheIdentifier, $this->runtimeUserCache)) {
$user = $this->findUserForAccount($username, $authenticationProviderName);
$this->runtimeUserCache[$cacheIdentifier] = $user === null ? null : $this->persistenceManager->getIdentifierByObject($user);
return $user;
}
$account = $this->accountRepository->findByAccountIdentifierAndAuthenticationProviderName($username, $authenticationProviderName ?: $this->defaultAuthenticationProviderName);
if (!$account instanceof Account) {

$userIdentifier = $this->runtimeUserCache[$cacheIdentifier];
if ($userIdentifier === null) {
return null;
}
$user = $this->partyService->getAssignedPartyOfAccount($account);
if (!$user instanceof User) {
throw new Exception(sprintf('Unexpected user type "%s". An account with the identifier "%s" exists, but the corresponding party is not a Neos User.', get_class($user), $username), 1422270948);
}
if ($authenticationProviderName !== null) {
if (!isset($this->runtimeUserCache['a_' . $authenticationProviderName])) {
$this->runtimeUserCache['a_' . $authenticationProviderName] = [];
}
$this->runtimeUserCache['a_' . $authenticationProviderName][$username] = $user;
} else {
$this->runtimeUserCache['u_' . $username] = $user;
}

$user = $this->partyRepository->findByIdentifier($userIdentifier);
return $user;
}

Expand Down Expand Up @@ -814,4 +815,25 @@ protected function removeOwnerFromUsersWorkspaces(User $user)
$this->workspaceRepository->update($workspace);
}
}

/**
* @param string $username
* @param string $authenticationProviderName
* @return \Neos\Party\Domain\Model\AbstractParty|null
* @throws Exception
*/
protected function findUserForAccount($username, $authenticationProviderName)
{
$account = $this->accountRepository->findByAccountIdentifierAndAuthenticationProviderName($username, $authenticationProviderName ?: $this->defaultAuthenticationProviderName);
if ($account === null) {
return null;
}

$user = $this->partyService->getAssignedPartyOfAccount($account);
if (!$user instanceof User) {
throw new Exception(sprintf('Unexpected user type "%s". An account with the identifier "%s" exists, but the corresponding party is not a Neos User.', get_class($user), $username), 1422270948);
}

return $user;
}
}
13 changes: 12 additions & 1 deletion Classes/Fusion/Cache/ContentCacheFlusher.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Neos\Flow\Annotations as Flow;
use Neos\Flow\Log\SystemLoggerInterface;
use Neos\Flow\Persistence\PersistenceManagerInterface;
use Neos\Media\Domain\Model\AssetInterface;
use Neos\Media\Domain\Service\AssetService;
use Neos\Neos\Domain\Model\Dto\AssetUsageInNodeProperties;
Expand Down Expand Up @@ -56,11 +57,17 @@ class ContentCacheFlusher
protected $assetService;

/**
* @Flow\Inject()
* @Flow\Inject
* @var NodeTypeManager
*/
protected $nodeTypeManager;

/**
* @Flow\Inject
* @var PersistenceManagerInterface
*/
protected $persistenceManager;

/**
* Register a node change for a later cache flush. This method is triggered by a signal sent via ContentRepository's Node
* model or the Neos Publishing Service.
Expand Down Expand Up @@ -145,6 +152,10 @@ public function registerAssetChange(AssetInterface $asset)

$this->registerChangeOnNodeIdentifier($reference->getNodeIdentifier());
$this->registerChangeOnNodeType($reference->getNodeTypeName(), $reference->getNodeIdentifier());

$assetIdentifier = $this->persistenceManager->getIdentifierByObject($asset);
$tagName = 'AssetDynamicTag_' . $assetIdentifier;
$this->tagsToFlush[$tagName] = sprintf('which were tagged with "%s" because asset "%s" has changed.', $tagName, $assetIdentifier);
}
}

Expand Down

0 comments on commit ecfc1c2

Please sign in to comment.