Skip to content

Commit

Permalink
Merge branch '11.4' into 11.x
Browse files Browse the repository at this point in the history
  • Loading branch information
lukmzig committed Oct 28, 2024
2 parents eca112d + ab4ec3f commit 322366f
Show file tree
Hide file tree
Showing 18 changed files with 133 additions and 85 deletions.
6 changes: 0 additions & 6 deletions bundles/CoreBundle/src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,6 @@ private function addGeneralNode(ArrayNodeDefinition $rootNode): void
->end()
->scalarNode('domain')
->defaultValue('')
->validate()
->ifTrue(function ($v) {
return $v && !filter_var($v, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME);
})
->thenInvalid('Invalid domain name "%s"')
->end()
->end()
->booleanNode('redirect_to_maindomain')
->beforeNormalization()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

namespace Pimcore\Bundle\CoreBundle\DependencyInjection;

use InvalidArgumentException;
use Pimcore;
use Pimcore\Bundle\CoreBundle\EventListener\TranslationDebugListener;
use Pimcore\Extension\Document\Areabrick\Attribute\AsAreabrick;
Expand Down Expand Up @@ -84,7 +85,15 @@ public function loadInternal(array $config, ContainerBuilder $container): void

// set default domain for router to main domain if configured
// this will be overridden from the request in web context but is handy for CLI scripts
if (!empty($config['general']['domain'])) {
$domain = $config['general']['domain'] ?? '';
if ($domain) {
// when not an env variable, check if the domain is valid
if (
!str_starts_with($domain, 'env_') &&
!filter_var(idn_to_ascii($domain), FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)
) {
throw new InvalidArgumentException(sprintf('Invalid main domain name "%s"', $domain));
}
$container->setParameter('router.request_context.host', $config['general']['domain']);
}

Expand Down
3 changes: 0 additions & 3 deletions bundles/InstallBundle/src/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,6 @@ private function runInstall(array $dbConfig, array $userCredentials, Connection
}

if (in_array('mark_migrations_as_done', $stepsToRun)) {
$this->dispatchStepEvent('install_classes');
$this->installClasses();

$this->dispatchStepEvent('migrations');
$this->markMigrationsAsDone();
}
Expand Down
24 changes: 23 additions & 1 deletion bundles/TinymceBundle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pimcore.plugin.YourTinymceEditorConfigBundle = Class.create({
},
pimcoreReady: function (e) {
pimcore.object.tags.wysiwyg = pimcore.document.editables.wysiwyg || {};
pimcore.object.tags.wysiwyg = pimcore.object.tags.wysiwyg || {};
pimcore.object.tags.wysiwyg.defaultEditorConfig = { menubar: true };
}
});
Expand Down Expand Up @@ -168,3 +168,25 @@ class EditmodeListener implements EventSubscriberInterface
}
}
```

### Loading additional TinyMCE plugins that are not shipped with this bundle

You can load additional plugins that are not shipped by default with Pimcore's TinyMCE bundle.

The following example adds the plugin `charmap` (Note: Included since Pimcore 11.4):

1) [Download](https://www.tiny.cloud/get-tiny/) a TinyMCE dist package matching the version the bundle is currently shipped with.
2) Extract the desired plugin from the TinyMCE dist package and place it in your app's or bundle's resource folder,
e.g. copy `js/tinymce/plugins/charmap/plugin.min.js` to `public/static/js/tinymce_plugins/charmap/plugin.min.js`.
3) Use TinyMCE's config option [`external_plugins`](https://www.tiny.cloud/docs/tinymce/latest/editor-important-options/#external_plugins)
to load the plugin:
```javascript
{
// ...
external_plugins: {
charmap: '/static/js/tinymce_plugins/charmap/plugin.min.js',
},
// ...
charmap: [/* ... */], // plugin's configuration
}
```
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
"codeception/codeception": "^5.0.3",
"codeception/module-symfony": "^3.1.0",
"ergebnis/phpstan-rules": "^2.0",
"phpstan/phpstan": "1.12.5",
"phpstan/phpstan": "1.12.7",
"phpstan/phpstan-symfony": "^1.3.5",
"phpunit/phpunit": "^9.3",
"gotenberg/gotenberg-php": "^1.1 || ^2.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ like CloudFront for your resources.
### Example: AWS S3 Adapter for Assets
First, install AWS S3 Adapter with command:
```
composer require league/flysystem-aws-s3-v3:^2.0
composer require league/flysystem-aws-s3-v3
````
Next step is to configure AWS S3 client service for class `Aws\S3\S3Client` with following required arguments:
Expand Down
5 changes: 4 additions & 1 deletion lib/SystemSettingsConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ private function prepareSystemConfig(array $values): array
$this->checkFallbackLanguageLoop($sourceLang, $fallbackLanguages);
}

if ($values['general.domain'] && !filter_var($values['general.domain'], FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)) {
if (
$values['general.domain'] &&
!filter_var(idn_to_ascii($values['general.domain']), FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)
) {
throw new InvalidArgumentException(sprintf('Invalid main domain name "%s"', $values['general.domain']));
}

Expand Down
5 changes: 3 additions & 2 deletions lib/Translation/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,11 @@ private function checkForEmptyTranslation(string $id, string $translated, array
}

if ($fallbackValue && $normalizedId != $fallbackValue) {
$isIntl = $catalogue->defines($normalizedId, $domain . $catalogue::INTL_DOMAIN_SUFFIX);
// update fallback value in original catalogue otherwise multiple calls to the same id will not work
$this->getCatalogue($locale)->set($normalizedId, $fallbackValue, $domain);
$this->getCatalogue($locale)->set($normalizedId, $fallbackValue, $domain . ($isIntl ? $catalogue::INTL_DOMAIN_SUFFIX : ''));

return strtr($fallbackValue, $parameters);
return $this->translator->trans($normalizedId, $parameters, $domain, $locale);
}
}
}
Expand Down
46 changes: 46 additions & 0 deletions models/DataObject/AbstractObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Pimcore;
use Pimcore\Cache;
use Pimcore\Cache\RuntimeCache;
use Pimcore\Db;
use Pimcore\Event\DataObjectEvents;
use Pimcore\Event\Model\DataObjectEvent;
use Pimcore\Logger;
Expand Down Expand Up @@ -118,6 +119,19 @@ abstract class AbstractObject extends Model\Element\AbstractElement
*/
protected ?string $childrenSortOrder = null;

/**
* @internal
*
* @var string|null
*/
protected $classId = null;

/**
* @internal
*
*/
protected ?array $__rawRelationData = null;

protected function getBlockedVars(): array
{
$blockedVars = ['versions', 'class', 'scheduledTasks', 'omitMandatoryCheck'];
Expand Down Expand Up @@ -596,6 +610,9 @@ public function save(array $parameters = []): static
// add to queue that saves dependencies
$this->addToDependenciesQueue();

//Reset Relational data to force a reload
$this->__rawRelationData = null;

$postEvent = new DataObjectEvent($this, $parameters);
if ($isUpdate) {
if ($differentOldPath) {
Expand Down Expand Up @@ -969,6 +986,35 @@ public function getChildrenSortOrder(): string
return $this->childrenSortOrder ?? self::OBJECT_CHILDREN_SORT_ORDER_DEFAULT;
}

/**
* @return $this
*/
public function setClassId(string $classId): static
{
$this->classId = $classId;

return $this;
}

public function getClassId(): ?string
{
return $this->classId;
}

/**
* @internal
*
*/
public function __getRawRelationData(): array
{
if ($this->__rawRelationData === null) {
$db = Db::get();
$this->__rawRelationData = $db->fetchAllAssociative('SELECT * FROM object_relations_' . $this->getClassId() . ' WHERE src_id = ?', [$this->getId()]);
}

return $this->__rawRelationData;
}

/**
* load lazy loaded fields before cloning
*/
Expand Down
16 changes: 12 additions & 4 deletions models/DataObject/ClassDefinition/Data/NumericRange.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,18 @@ public function getDataForResource(mixed $data, DataObject\Concrete $object = nu
public function getDataFromResource(mixed $data, DataObject\Concrete $object = null, array $params = []): ?DataObject\Data\NumericRange
{
if (isset($data[$this->getName() . '__minimum'], $data[$this->getName() . '__maximum'])) {
$numericRange = new DataObject\Data\NumericRange(
$data[$this->getName() . '__minimum'],
$data[$this->getName() . '__maximum']
);
$minimum = $data[$this->getName() . '__minimum'];
$maximum = $data[$this->getName() . '__maximum'];

if (is_string($minimum)) {
$minimum = (float) $minimum;
}

if (is_string($maximum)) {
$maximum = (float) $maximum;
}

$numericRange = new DataObject\Data\NumericRange($minimum, $maximum);

if (isset($params['owner'])) {
$numericRange->_setOwner($params['owner']);
Expand Down
11 changes: 6 additions & 5 deletions models/DataObject/ClassDefinition/Data/QuantityValueRange.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,19 +286,20 @@ public function checkValidity(mixed $data, bool $omitMandatoryCheck = false, arr
throw new ValidationException('Expected an instance of QuantityValueRange');
}

$minimum = $data?->getMinimum();
$maximum = $data?->getMaximum();

if ($omitMandatoryCheck === false && $this->getMandatory()
&& ($data === null
|| $data->getMinimum() === null
|| $data->getMaximum() === null
|| $minimum === null
|| $maximum === null
|| $data->getUnitId() === null
)
) {
throw new ValidationException(sprintf('Empty mandatory field [ %s ]', $fieldName));
}

if (!empty($data)) {
$minimum = $data->getMinimum();
$maximum = $data->getMaximum();
if ($minimum || $maximum) {

if (!is_numeric($minimum) || !is_numeric($maximum)) {
throw new ValidationException(sprintf('Invalid dimension unit data: %s', $fieldName));
Expand Down
2 changes: 1 addition & 1 deletion models/DataObject/ClassDefinition/Layout/Panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function setLayout(string $layout): static
return $this;
}

public function getLayout(): string
public function getLayout(): ?string
{
return $this->layout;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public function load(): array
$resource = $entry->getDao();
$dataItem['enabled'] = (bool)$dataItem['enabled'];
$dataItem['mandatory'] = (bool)$dataItem['mandatory'];

$definition = json_decode($dataItem['definition'], true);
$definition['mandatory'] = $dataItem['mandatory'];
$dataItem['definition'] = json_encode($definition);

$resource->assignVariablesToModel($dataItem);

$configData[] = $entry;
Expand Down
48 changes: 0 additions & 48 deletions models/DataObject/Concrete.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ class Concrete extends DataObject implements LazyLoadedFieldsInterface
use Model\DataObject\Traits\LazyLoadedRelationTrait;
use Model\Element\Traits\ScheduledTasksTrait;

/**
* @internal
*
*/
protected ?array $__rawRelationData = null;

/**
* @internal
*
Expand All @@ -74,13 +68,6 @@ class Concrete extends DataObject implements LazyLoadedFieldsInterface
*/
protected ?ClassDefinition $class = null;

/**
* @internal
*
* @var string|null
*/
protected $classId = null;

/**
* @internal
*
Expand Down Expand Up @@ -401,25 +388,6 @@ public function getClass(): ClassDefinition
return $this->class;
}

public function getClassId(): ?string
{
if (isset($this->classId)) {
return (string)$this->classId;
}

return null;
}

/**
* @return $this
*/
public function setClassId(string $classId): static
{
$this->classId = $classId;

return $this;
}

public function getClassName(): ?string
{
return $this->className;
Expand Down Expand Up @@ -667,8 +635,6 @@ public function save(array $parameters = []): static

try {
parent::save($parameters);
//Reset Relational data to force a reload
$this->__rawRelationData = null;

if ($this instanceof DirtyIndicatorInterface) {
$this->resetDirtyMap();
Expand Down Expand Up @@ -843,18 +809,4 @@ public function retrieveRelationData(array $descriptor): array

return $filteredData;
}

/**
* @internal
*
*/
public function __getRawRelationData(): array
{
if ($this->__rawRelationData === null) {
$db = Db::get();
$this->__rawRelationData = $db->fetchAllAssociative('SELECT * FROM object_relations_' . $this->getClassId() . ' WHERE src_id = ?', [$this->getId()]);
}

return $this->__rawRelationData;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ trait FieldDefinitionEnrichmentDataTrait
use FieldDefinitionEnrichmentModelTrait;

/**
* @params array<string, Data> $fields
* @param array<string, Data> $fields
*
* @return array<string, Data>
*/
Expand Down
2 changes: 1 addition & 1 deletion models/Element/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ protected function updateChildren(DataObject|Document|Asset\Folder $target, Elem
{
//check in case of recursion
$found = false;
foreach ($target->getChildren() as $child) {
foreach ($target->getChildren()->load() as $child) {
if ($child->getId() == $new->getId()) {
$found = true;

Expand Down
4 changes: 2 additions & 2 deletions models/Schedule/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function setId(int $id): static
/**
* @return $this
*/
public function setCid(int $cid): static
public function setCid(?int $cid): static
{
$this->cid = $cid;

Expand All @@ -132,7 +132,7 @@ public function setCid(int $cid): static
/**
* @return $this
*/
public function setCtype(string $ctype): static
public function setCtype(?string $ctype): static
{
$this->ctype = $ctype;

Expand Down
Loading

0 comments on commit 322366f

Please sign in to comment.