Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/10.5' into 10.6
Browse files Browse the repository at this point in the history
# Conflicts:
#	composer.json
  • Loading branch information
dvesh3 committed Jan 4, 2023
2 parents 83d74d0 + 0afd723 commit ef119d0
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ pimcore.object.fieldcollection = Class.create({

addFieldComplete: function (button, value, object) {

var isValidName = /^[a-zA-Z]+$/;
var isValidName = /^[a-zA-Z][a-zA-Z0-9]*$/;

if (button == "ok" && value.length > 2 && isValidName.test(value) && !in_arrayi(value, this.forbiddenNames)) {
Ext.Ajax.request({
Expand Down
4 changes: 2 additions & 2 deletions bundles/CoreBundle/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -1807,7 +1807,7 @@ private function addWorkflowNode(ArrayNodeDefinition $rootNode)
->scalarNode('guard')
->cannotBeEmpty()
->info('An expression to block the transition')
->example('is_fully_authenticated() and has_role(\'ROLE_JOURNALIST\') and subject.getTitle() == \'My first article\'')
->example('is_fully_authenticated() and is_granted(\'ROLE_JOURNALIST\') and subject.getTitle() == \'My first article\'')
->end()
->arrayNode('from')
->beforeNormalization()
Expand Down Expand Up @@ -1975,7 +1975,7 @@ private function addWorkflowNode(ArrayNodeDefinition $rootNode)
->scalarNode('guard')
->cannotBeEmpty()
->info('An expression to block the action')
->example('is_fully_authenticated() and has_role(\'ROLE_JOURNALIST\') and subject.getTitle() == \'My first article\'')
->example('is_fully_authenticated() and is_granted(\'ROLE_JOURNALIST\') and subject.getTitle() == \'My first article\'')
->end()
->arrayNode('to')
->beforeNormalization()
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@
"codeception/module-symfony": "^1.6.0",
"codeception/phpunit-wrapper": "^9",
"pimcore/elasticsearch-client": "^1.0.0",
"phpstan/phpstan": "^1.9.3",
"phpstan/phpstan-symfony": "^1.2.14",
"phpstan/phpstan": "^1.9.5",
"phpstan/phpstan-symfony": "^1.2.19",
"phpunit/phpunit": "^9.3",
"spiritix/php-chrome-html2pdf": "^1.6",
"elasticsearch/elasticsearch": "^8.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ pimcore:
objectLayout: false

# An expression to block the action
guard: ~ # Example: is_fully_authenticated() and has_role('ROLE_JOURNALIST') and subject.getTitle() == 'My first article'
guard: ~ # Example: is_fully_authenticated() and is_granted('ROLE_JOURNALIST') and subject.getTitle() == 'My first article'

# Optionally set the current place of the workflow. Can be used for example to reset the workflow to the initial place.
to: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This section of documentation gives an overview over tools and features provided
be used via Pimcore PHP API.

The topics include insights to [Versioning](./01_Versioning.md), [Notes and Events](./05_Notes_and_Events.md),
[Tags](./05_Tags.md), [Perspectives](./13_Perspectives.md) and much much more.
[Tags](./09_Tags.md), [Perspectives](./13_Perspectives.md) and much much more.

Just have a look at the sub pages and dive into the possibilities of Pimcore.

2 changes: 2 additions & 0 deletions lib/Tool/Text/Csv.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ protected function guessQuoteAndDelim($data)
* @param string $quotechar
*
* @return bool|string
*
* @phpstan-param non-empty-string $linefeed
*/
protected function guessDelim($data, $linefeed, $quotechar)
{
Expand Down
2 changes: 1 addition & 1 deletion models/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ public static function getTypeFromMimeMapping($mimeType, $filename)
$mappings = [
'unknown' => ["/\.stp$/"],
'image' => ['/image/', "/\.eps$/", "/\.ai$/", "/\.svgz$/", "/\.pcx$/", "/\.iff$/", "/\.pct$/", "/\.wmf$/", '/photoshop/'],
'text' => ['/text/', '/xml$/', '/\.json$/'],
'text' => ['/text\//', '/xml$/', '/\.json$/'],
'audio' => ['/audio/'],
'video' => ['/video/'],
'document' => ['/msword/', '/pdf/', '/powerpoint/', '/office/', '/excel/', '/opendocument/'],
Expand Down
8 changes: 7 additions & 1 deletion models/Asset/Folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,13 @@ public function getPreviewImage(bool $force = false)
break;
}

$tile = imagecreatefromstring(stream_get_contents($tileThumb->getStream()));
$stream = $tileThumb->getStream();

if (null === $stream) {
break;
}

$tile = imagecreatefromstring(stream_get_contents($stream));
imagecopyresampled($collage, $tile, $offsetLeft, $offsetTop, 0, 0, $squareDimension, $squareDimension, $tileThumb->getWidth(), $tileThumb->getHeight());

$count++;
Expand Down
13 changes: 8 additions & 5 deletions models/DataObject/ClassDefinition/Data/QuantityValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -531,13 +531,16 @@ public function getDataForResource($data, $object = null, $params = [])
*/
public function getDataFromResource($data, $object = null, $params = [])
{
if ($data[$this->getName() . '__value'] !== null || $data[$this->getName() . '__unit']) {
if (!is_numeric($data[$this->getName() . '__value'])) {
$value = $this->toNumeric($data[$this->getName() . '__value']);
$dataValue = $data[$this->getName() . '__value'];
$dataUnit = $data[$this->getName() . '__unit'];

if ($dataValue !== null || $dataUnit) {
if ($dataValue !== null && !is_numeric($dataValue)) {
$value = $this->toNumeric($dataValue);
} else {
$value = $data[$this->getName() . '__value'];
$value = $dataValue;
}
$quantityValue = new Model\DataObject\Data\QuantityValue((float) $value, $data[$this->getName() . '__unit']);
$quantityValue = new Model\DataObject\Data\QuantityValue($value === null ? null : (float)$value, $dataUnit);

if (isset($params['owner'])) {
$quantityValue->_setOwner($params['owner']);
Expand Down
5 changes: 5 additions & 0 deletions models/DataObject/ClassDefinition/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,11 @@ public static function importObjectBrickFromJson($objectBrick, $json, $throwExce
public static function generateLayoutTreeFromArray($array, $throwException = false, $insideLocalizedField = false)
{
if (is_array($array) && count($array) > 0) {
if ($title = $array['title'] ?? false) {
if (preg_match('/<.+?>/', $title)) {
throw new \Exception('not a valid title:' . htmlentities($title));
}
}
if ($name = $array['name'] ?? false) {
if (preg_match('/<.+?>/', $name)) {
throw new \Exception('not a valid name:' . htmlentities($name));
Expand Down
15 changes: 14 additions & 1 deletion models/DataObject/Fieldcollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

namespace Pimcore\Model\DataObject;

use Pimcore\Logger;
use Pimcore\Model;
use Pimcore\Model\DataObject;
use Pimcore\Model\Element\DirtyIndicatorInterface;
Expand All @@ -33,7 +34,7 @@ class Fieldcollection extends Model\AbstractModel implements \Iterator, DirtyInd
/**
* @internal
*
* @var TItem[]
* @var array<TItem|\__PHP_Incomplete_Class>
*/
protected $items = [];

Expand Down Expand Up @@ -366,4 +367,16 @@ public function loadLazyData()
}
}
}

public function __wakeup()
{
if (is_array($this->items)) {
foreach ($this->items as $key => $item) {
if ($item instanceof \__PHP_Incomplete_Class) {
unset($this->items[$key]);
Logger::error('fieldcollection item ' . $key . ' does not exist anymore');
}
}
}
}
}
4 changes: 1 addition & 3 deletions models/DataObject/Objectbrick.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,6 @@ public function __sleep(): array

public function __wakeup()
{
$brickGetter = null;

// for backwards compatibility
if ($this->object) {
$this->objectId = $this->object->getId();
Expand All @@ -339,7 +337,7 @@ public function __wakeup()
foreach ($this->items as $key => $item) {
if ($item instanceof \__PHP_Incomplete_Class) {
unset($this->items[$key]);
Logger::error('brick ' . $brickGetter . ' does not exist anymore');
Logger::error('brick item ' . $key . ' does not exist anymore');
}
}
}
Expand Down
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,6 @@ parameters:
count: 1
path: lib/Tool/Serialize.php

-
message: "#^Parameter \\#1 \\$separator of function explode expects non\\-empty\\-string, string given\\.$#"
count: 1
path: lib/Tool/Text/Csv.php

-
message: "#^Negated boolean expression is always true\\.$#"
count: 1
Expand Down

0 comments on commit ef119d0

Please sign in to comment.