Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/10.6' into 11.0
Browse files Browse the repository at this point in the history
# Conflicts:
#	bundles/AdminBundle/Controller/Admin/Asset/AssetController.php
#	bundles/AdminBundle/Controller/Admin/DataObject/ClassController.php
#	bundles/AdminBundle/Controller/Admin/SettingsController.php
#	models/DataObject/Classificationstore.php
  • Loading branch information
dvesh3 committed Aug 3, 2023
2 parents d590c0c + 4603efa commit e537571
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 10 deletions.
2 changes: 2 additions & 0 deletions models/Asset/Image/Thumbnail/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,9 @@ public static function process(Asset $asset, Config $config, mixed $fileSystemPa
}

if (is_resource($fileSystemPath)) {
$fileSystemPathStream = $fileSystemPath;
$fileSystemPath = self::getLocalFileFromStream($fileSystemPath);
@fclose($fileSystemPathStream);
}

if (!file_exists($fileSystemPath)) {
Expand Down
5 changes: 4 additions & 1 deletion models/Asset/Thumbnail/ImageThumbnailTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,10 @@ public function getLocalFile(): ?string
return null;
}

return self::getLocalFileFromStream($stream);
$localFile = self::getLocalFileFromStream($stream);
@fclose($stream);

return $localFile;
}

public function exists(): bool
Expand Down
24 changes: 20 additions & 4 deletions models/DataObject/Classificationstore.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ class Classificationstore extends Model\AbstractModel implements DirtyIndicatorI
/**
* @internal
*
* @var array
* @var array<int, bool>
*/
protected array $activeGroups = [];

/**
* @internal
*
* @var array
* @var array<int, int>
*/
protected array $groupCollectionMapping = [];

Expand Down Expand Up @@ -263,6 +263,9 @@ public function setFieldname(string $fieldname): void
$this->fieldname = $fieldname;
}

/**
* @return array<int, bool>
*/
public function getActiveGroups(): array
{
$doGetInheritedValues = Model\DataObject::doGetInheritedValues();
Expand All @@ -288,6 +291,9 @@ private function sanitizeActiveGroups(array $activeGroups): array
return $newList;
}

/**
* @param array<int, bool> $activeGroups
*/
public function setActiveGroups(array $activeGroups): void
{
$activeGroups = $this->sanitizeActiveGroups($activeGroups);
Expand Down Expand Up @@ -414,6 +420,9 @@ public static function doGetFallbackValues(): bool
return true;
}

/**
* @return array<int, int>
*/
public function getGroupCollectionMappings(): array
{
$doGetInheritedValues = Model\DataObject::doGetInheritedValues();
Expand All @@ -424,6 +433,9 @@ public function getGroupCollectionMappings(): array
return $this->getAllDataFromField(fn ($classificationStore, $fieldsArray) => $fieldsArray + $classificationStore->groupCollectionMapping);
}

/**
* @param array<int, int> $groupCollectionMapping
*/
public function setGroupCollectionMappings(array $groupCollectionMapping): void
{
$this->groupCollectionMapping = $groupCollectionMapping;
Expand Down Expand Up @@ -466,13 +478,17 @@ private function getAllDataFromField(callable $mergeFunction): array
return $fieldsArray;
}

/**
* @return Model\DataObject\Classificationstore\Group[]
*/
private static function getActiveGroupsWithConfig(Classificationstore $classificationStore): array
{
$groups = [];
$activeGroups = $classificationStore->getActiveGroups();
foreach (array_keys($activeGroups) as $groupId) {
$groupConfig = $classificationStore->getGroupConfigById($groupId);
$groups[] = $classificationStore->createGroup($classificationStore, $groupConfig);
if ($groupConfig = $classificationStore->getGroupConfigById($groupId)) {
$groups[] = $classificationStore->createGroup($classificationStore, $groupConfig);
}
}

return $groups;
Expand Down
4 changes: 3 additions & 1 deletion models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,9 @@ public function getImage(?int $width = null, ?int $height = null)
$storage = Tool\Storage::get('admin');
if ($storage->fileExists($this->getOriginalImageStoragePath())) {
if (!$storage->fileExists($this->getThumbnailImageStoragePath())) {
$localFile = self::getLocalFileFromStream($storage->readStream($this->getOriginalImageStoragePath()));
$originalImageStream = $storage->readStream($this->getOriginalImageStoragePath());
$localFile = self::getLocalFileFromStream($originalImageStream);
@fclose($originalImageStream);
$targetFile = File::getLocalTempFilePath('png');

$image = \Pimcore\Image::getInstance();
Expand Down
21 changes: 17 additions & 4 deletions models/User/AbstractUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

namespace Pimcore\Model\User;

use Pimcore\Cache\RuntimeCache;
use Pimcore\Event\Model\UserRoleEvent;
use Pimcore\Event\Traits\RecursionBlockingEventDispatchHelperTrait;
use Pimcore\Event\UserRoleEvents;
Expand Down Expand Up @@ -46,8 +47,8 @@ public static function getById(int $id): static|null
$cacheKey = 'user_' . $id;

try {
if (\Pimcore\Cache\RuntimeCache::isRegistered($cacheKey)) {
$user = \Pimcore\Cache\RuntimeCache::get($cacheKey);
if (RuntimeCache::isRegistered($cacheKey)) {
$user = RuntimeCache::get($cacheKey);
} else {
$reflectionClass = new \ReflectionClass(static::class);
if ($reflectionClass->isAbstract()) {
Expand All @@ -64,7 +65,7 @@ public static function getById(int $id): static|null
$user = $className::getById($user->getId());
}

\Pimcore\Cache\RuntimeCache::set($cacheKey, $user);
RuntimeCache::set($cacheKey, $user);
}
} catch (Model\Exception\NotFoundException $e) {
return null;
Expand Down Expand Up @@ -201,6 +202,7 @@ public function delete(): void
if ($this->getId() < 1) {
throw new \Exception('Deleting the system user is not allowed!');
}
$parentUserId = $this->getParentId();

$this->dispatchEvent(new UserRoleEvent($this), UserRoleEvents::PRE_DELETE);

Expand All @@ -220,7 +222,18 @@ public function delete(): void

// now delete the current user
$this->getDao()->delete();
\Pimcore\Cache::clearAll();

$cacheKey = 'user_' . $this->getId();
if (RuntimeCache::isRegistered($cacheKey)) {
RuntimeCache::set($cacheKey, null);
}

if ($parentUserId && $parentUserId > 1) {
$parentCacheKey = 'user_' . $parentUserId;
if (RuntimeCache::isRegistered($parentCacheKey)) {
RuntimeCache::set($parentCacheKey, null);
}
}

$this->dispatchEvent(new UserRoleEvent($this), UserRoleEvents::POST_DELETE);
}
Expand Down

0 comments on commit e537571

Please sign in to comment.