diff --git a/bundles/AdminBundle/Controller/Admin/DataObject/ClassController.php b/bundles/AdminBundle/Controller/Admin/DataObject/ClassController.php index ce44ed65340..58959ce1cba 100644 --- a/bundles/AdminBundle/Controller/Admin/DataObject/ClassController.php +++ b/bundles/AdminBundle/Controller/Admin/DataObject/ClassController.php @@ -455,6 +455,14 @@ public function saveAction(Request $request) $class->rename($values['name']); } + if ($values['compositeIndices']) { + foreach ($values['compositeIndices'] as $index => $compositeIndex) { + if ($compositeIndex['index_key'] !== ($sanitizedKey = preg_replace('/[^a-za-z0-9_\-+]/', '', $compositeIndex['index_key']))) { + $values['compositeIndices'][$index]['index_key'] = $sanitizedKey; + } + } + } + unset($values['creationDate']); unset($values['userOwner']); unset($values['layoutDefinitions']); diff --git a/bundles/AdminBundle/Controller/Admin/SettingsController.php b/bundles/AdminBundle/Controller/Admin/SettingsController.php index dd549e26d19..df2ed7af227 100644 --- a/bundles/AdminBundle/Controller/Admin/SettingsController.php +++ b/bundles/AdminBundle/Controller/Admin/SettingsController.php @@ -404,14 +404,12 @@ public function getSystemAction(Request $request, Config $config) $valueArray['general']['valid_language'] = explode(',', $valueArray['general']['valid_languages']); //for "wrong" legacy values - if (is_array($valueArray['general']['valid_language'])) { - foreach ($valueArray['general']['valid_language'] as $existingValue) { - if (!in_array($existingValue, $validLanguages)) { - $languageOptions[] = [ - 'language' => $existingValue, - 'display' => $existingValue, - ]; - } + foreach ($valueArray['general']['valid_language'] as $existingValue) { + if (!in_array($existingValue, $validLanguages)) { + $languageOptions[] = [ + 'language' => $existingValue, + 'display' => $existingValue, + ]; } } diff --git a/bundles/AdminBundle/Resources/public/js/pimcore/object/classes/class.js b/bundles/AdminBundle/Resources/public/js/pimcore/object/classes/class.js index 28602a94fda..ebedbe757d2 100644 --- a/bundles/AdminBundle/Resources/public/js/pimcore/object/classes/class.js +++ b/bundles/AdminBundle/Resources/public/js/pimcore/object/classes/class.js @@ -1085,7 +1085,14 @@ pimcore.object.classes.klass = Class.create({ fieldLabel: t("key"), labelWidth: 100, width: 250, - value: data.index_key + value: data.index_key, + validator: function (value) { + if(value !== value.replace(/[^a-za-z0-9_\-+]/g,'')){ + this.setvalue(value.replace(/[^a-za-z0-9_\-+]/g,'')); + } + + return true; + } }; //fixes data to match store model diff --git a/bundles/AdminBundle/Resources/public/js/pimcore/object/fieldcollection.js b/bundles/AdminBundle/Resources/public/js/pimcore/object/fieldcollection.js index a1628c03992..6a714356c46 100644 --- a/bundles/AdminBundle/Resources/public/js/pimcore/object/fieldcollection.js +++ b/bundles/AdminBundle/Resources/public/js/pimcore/object/fieldcollection.js @@ -15,7 +15,8 @@ pimcore.registerNS("pimcore.object.fieldcollection"); pimcore.object.fieldcollection = Class.create({ forbiddenNames: [ - "abstract", "class", "data", "folder", "list", "permissions", "resource", "concrete", "interface", "default" + "abstract", "class", "data", "folder", "list", "permissions", "resource", "dao", "concrete", "items", + "object", "interface", "default" ], initialize: function () { diff --git a/bundles/AdminBundle/Resources/public/js/pimcore/object/helpers/imageGalleryDropZone.js b/bundles/AdminBundle/Resources/public/js/pimcore/object/helpers/imageGalleryDropZone.js index b11c372a65a..9bfc9ae86a5 100644 --- a/bundles/AdminBundle/Resources/public/js/pimcore/object/helpers/imageGalleryDropZone.js +++ b/bundles/AdminBundle/Resources/public/js/pimcore/object/helpers/imageGalleryDropZone.js @@ -69,7 +69,7 @@ Ext.define('pimcore.object.helpers.ImageGalleryDropZone', { var y = p.el.getY(); var w = p.el.getWidth(); - if(xy[1] >y && (xy[1] < (y + h)) && xy[0] > x && (xy[0] < (x + w))) { + if(pos != currentPosition && (xy[1] >y && (xy[1] < (y + h)) && xy[0] > x && (xy[0] < (x + w)))) { match = true; break; }else if (pos == len -1 && currentPosition != len - 1) { diff --git a/bundles/AdminBundle/Resources/public/js/pimcore/object/tags/manyToOneRelation.js b/bundles/AdminBundle/Resources/public/js/pimcore/object/tags/manyToOneRelation.js index 82d86235099..11f099c2a3b 100644 --- a/bundles/AdminBundle/Resources/public/js/pimcore/object/tags/manyToOneRelation.js +++ b/bundles/AdminBundle/Resources/public/js/pimcore/object/tags/manyToOneRelation.js @@ -128,6 +128,12 @@ pimcore.object.tags.manyToOneRelation = Class.create(pimcore.object.tags.abstrac pimcore.helpers.openElement(this.data.id, this.data.type, subtype); }.bind(this)); }.bind(this)); + this.component.on('afterrender', function (el) { + el.inputEl.setWidth(href.width); + el.inputEl.setStyle({ + 'overflow': 'hidden' + }); + }); var items = [this.component, { xtype: "button", diff --git a/bundles/AdminBundle/Resources/public/js/pimcore/report/custom/item.js b/bundles/AdminBundle/Resources/public/js/pimcore/report/custom/item.js index fe045f89601..d2d84138fab 100644 --- a/bundles/AdminBundle/Resources/public/js/pimcore/report/custom/item.js +++ b/bundles/AdminBundle/Resources/public/js/pimcore/report/custom/item.js @@ -931,12 +931,13 @@ pimcore.report.custom.item = Class.create({ }, saveOnComplete: function () { - this.parentPanel.tree.getStore().load(); pimcore.helpers.showNotification(t("success"), t("saved_successfully"), "success"); Ext.MessageBox.confirm(t("info"), t("reload_pimcore_changes"), function (buttonValue) { if (buttonValue == "yes") { window.location.reload(); + } else { + this.parentPanel.tree.getStore().load(); } }.bind(this)); } diff --git a/bundles/CoreBundle/DependencyInjection/Configuration.php b/bundles/CoreBundle/DependencyInjection/Configuration.php index 5f6927472eb..d600c5063df 100644 --- a/bundles/CoreBundle/DependencyInjection/Configuration.php +++ b/bundles/CoreBundle/DependencyInjection/Configuration.php @@ -2180,7 +2180,7 @@ private function addPredefinedPropertiesNode(ArrayNodeDefinition $rootNode) * * @param ArrayNodeDefinition $rootNode */ - private function addStaticroutesNode(ArrayNodeDefinition $rootNode) + private function addStaticRoutesNode(ArrayNodeDefinition $rootNode) { $rootNode ->children() diff --git a/bundles/CoreBundle/DependencyInjection/PimcoreCoreExtension.php b/bundles/CoreBundle/DependencyInjection/PimcoreCoreExtension.php index ee7cb78e2ad..b550e55d279 100644 --- a/bundles/CoreBundle/DependencyInjection/PimcoreCoreExtension.php +++ b/bundles/CoreBundle/DependencyInjection/PimcoreCoreExtension.php @@ -316,25 +316,6 @@ private function configureTargeting(ContainerBuilder $container, LoaderInterface ->setArgument('$actionHandlers', $actionHandlerLocator); } - /** - * Configures a "typed locator" (a class exposing get/has for a specific type) wrapping - * a standard service locator. Example: Pimcore\Targeting\DataProviderLocator - * - * @param ContainerBuilder $container - * @param string $locatorClass - * @param array $services - */ - private function configureTypedLocator(ContainerBuilder $container, string $locatorClass, array $services) - { - $serviceLocator = new Definition(ServiceLocator::class, [$services]); - $serviceLocator - ->setPublic(false) - ->addTag('container.service_locator'); - - $locator = $container->getDefinition($locatorClass); - $locator->setArgument('$locator', $serviceLocator); - } - /** * Handle pimcore.security.encoder_factories mapping * diff --git a/bundles/CoreBundle/Migrations/Version20230307135459.php b/bundles/CoreBundle/Migrations/Version20230307135459.php new file mode 100644 index 00000000000..a35cf1b2486 --- /dev/null +++ b/bundles/CoreBundle/Migrations/Version20230307135459.php @@ -0,0 +1,50 @@ +getTables() as $table) { + if (str_starts_with($table->getName(), InheritanceHelper::RELATION_TABLE) && !$table->hasIndex($this->fieldname)) { + $table->addIndex([$this->fieldname], $this->fieldname); + } + } + } + + public function down(Schema $schema): void + { + foreach ($schema->getTables() as $table) { + if (str_starts_with($table->getName(), InheritanceHelper::RELATION_TABLE) && $table->hasIndex($this->fieldname)) { + $table->dropIndex($this->fieldname); + } + } + } +} diff --git a/bundles/CoreBundle/Resources/config/message_handler.yaml b/bundles/CoreBundle/Resources/config/message_handler.yaml index 5e59f10e13f..05dbad0c1f6 100644 --- a/bundles/CoreBundle/Resources/config/message_handler.yaml +++ b/bundles/CoreBundle/Resources/config/message_handler.yaml @@ -17,6 +17,7 @@ services: Pimcore\Messenger\Handler\AssetUpdateTasksHandler: arguments: - '@logger' + - '@Pimcore\Helper\LongRunningHelper' tags: - { name: messenger.message_handler } diff --git a/bundles/EcommerceFrameworkBundle/PriceSystem/CachingPriceSystem.php b/bundles/EcommerceFrameworkBundle/PriceSystem/CachingPriceSystem.php index 3d051ad1665..2299f5dea66 100644 --- a/bundles/EcommerceFrameworkBundle/PriceSystem/CachingPriceSystem.php +++ b/bundles/EcommerceFrameworkBundle/PriceSystem/CachingPriceSystem.php @@ -34,7 +34,7 @@ abstract class CachingPriceSystem extends AbstractPriceSystem implements Caching public function getPriceInfo(CheckoutableInterface $product, $quantityScale = 1, $products = null): PriceInfoInterface { $pId = $product->getId(); - if (!array_key_exists($pId, $this->priceInfos) || !is_array($this->priceInfos[$pId])) { + if (!array_key_exists($pId, $this->priceInfos)) { $this->priceInfos[$pId] = []; } diff --git a/composer.json b/composer.json index a3a1df29334..8fbcf5642d2 100644 --- a/composer.json +++ b/composer.json @@ -175,7 +175,7 @@ "codeception/module-symfony": "^1.6.0", "codeception/phpunit-wrapper": "^9", "pimcore/elasticsearch-client": "^1.0.0", - "phpstan/phpstan": "1.9.17", + "phpstan/phpstan": "1.10.5", "phpstan/phpstan-symfony": "^1.2.19", "phpunit/phpunit": "^9.3", "spiritix/php-chrome-html2pdf": "^1.6", diff --git a/lib/Config/Config.php b/lib/Config/Config.php index 48964ec1196..472ef12989b 100644 --- a/lib/Config/Config.php +++ b/lib/Config/Config.php @@ -394,6 +394,6 @@ public function __toString() return ''; } - return is_string($this->data) ? (string)$this->data : json_encode($this->data, JSON_PRETTY_PRINT); + return json_encode($this->data, JSON_PRETTY_PRINT); } } diff --git a/lib/DataObject/ClassBuilder/ClassBuilder.php b/lib/DataObject/ClassBuilder/ClassBuilder.php index 8f330400429..3c24f3e721c 100644 --- a/lib/DataObject/ClassBuilder/ClassBuilder.php +++ b/lib/DataObject/ClassBuilder/ClassBuilder.php @@ -126,10 +126,8 @@ public function buildClass(ClassDefinition $classDefinition): string $cd .= "\n\n"; - if (is_array($classDefinition->getFieldDefinitions()) && count($classDefinition->getFieldDefinitions())) { - foreach ($classDefinition->getFieldDefinitions() as $def) { - $cd .= $this->fieldDefinitionBuilder->buildFieldDefinition($classDefinition, $def); - } + foreach ($classDefinition->getFieldDefinitions() as $def) { + $cd .= $this->fieldDefinitionBuilder->buildFieldDefinition($classDefinition, $def); } $cd .= "}\n"; diff --git a/lib/DataObject/ClassBuilder/FieldCollectionClassBuilder.php b/lib/DataObject/ClassBuilder/FieldCollectionClassBuilder.php index 424c5dc5d8f..12b0e73e022 100644 --- a/lib/DataObject/ClassBuilder/FieldCollectionClassBuilder.php +++ b/lib/DataObject/ClassBuilder/FieldCollectionClassBuilder.php @@ -62,10 +62,8 @@ public function buildClass(Definition $definition): string $cd .= 'protected $type = "' . $definition->getKey() . "\";\n"; - if (is_array($definition->getFieldDefinitions()) && count($definition->getFieldDefinitions())) { - foreach ($definition->getFieldDefinitions() as $key => $def) { - $cd .= 'protected $' . $key . ";\n"; - } + foreach ($definition->getFieldDefinitions() as $key => $def) { + $cd .= 'protected $' . $key . ";\n"; } $cd .= "\n\n"; diff --git a/lib/DataObject/ClassBuilder/ObjectBrickClassBuilder.php b/lib/DataObject/ClassBuilder/ObjectBrickClassBuilder.php index 2c6f7d8b35c..5737ce6318e 100644 --- a/lib/DataObject/ClassBuilder/ObjectBrickClassBuilder.php +++ b/lib/DataObject/ClassBuilder/ObjectBrickClassBuilder.php @@ -66,10 +66,8 @@ public function buildClass(Definition $definition): string $cd .= 'protected $type = "' . $definition->getKey() . "\";\n"; - if (is_array($definition->getFieldDefinitions()) && count($definition->getFieldDefinitions())) { - foreach ($definition->getFieldDefinitions() as $key => $def) { - $cd .= 'protected $' . $key . ";\n"; - } + foreach ($definition->getFieldDefinitions() as $key => $def) { + $cd .= 'protected $' . $key . ";\n"; } $cd .= "\n\n"; @@ -87,19 +85,17 @@ public function buildClass(Definition $definition): string $cd .= "\n\n"; - if (is_array($definition->getFieldDefinitions()) && count($definition->getFieldDefinitions())) { - foreach ($definition->getFieldDefinitions() as $key => $def) { - $cd .= $def->getGetterCodeObjectbrick($definition); + foreach ($definition->getFieldDefinitions() as $def) { + $cd .= $def->getGetterCodeObjectbrick($definition); - if ($def instanceof ClassDefinition\Data\Localizedfields) { - $cd .= $def->getGetterCode($definition); - } + if ($def instanceof ClassDefinition\Data\Localizedfields) { + $cd .= $def->getGetterCode($definition); + } - $cd .= $def->getSetterCodeObjectbrick($definition); + $cd .= $def->getSetterCodeObjectbrick($definition); - if ($def instanceof ClassDefinition\Data\Localizedfields) { - $cd .= $def->getSetterCode($definition); - } + if ($def instanceof ClassDefinition\Data\Localizedfields) { + $cd .= $def->getSetterCode($definition); } } diff --git a/lib/Log/ApplicationLogger.php b/lib/Log/ApplicationLogger.php index 8e12f35a322..7e5a7880f09 100644 --- a/lib/Log/ApplicationLogger.php +++ b/lib/Log/ApplicationLogger.php @@ -142,7 +142,7 @@ public function setRelatedObject($relatedObject) */ public function log($level, $message, array $context = [])// : void { - if (!isset($context['component']) || is_null($context['component'])) { + if (!isset($context['component'])) { $context['component'] = $this->component; } diff --git a/lib/Maintenance/Tasks/VersionsCleanupTask.php b/lib/Maintenance/Tasks/VersionsCleanupTask.php index f14ac4a9398..aca2e9fb1d1 100644 --- a/lib/Maintenance/Tasks/VersionsCleanupTask.php +++ b/lib/Maintenance/Tasks/VersionsCleanupTask.php @@ -96,7 +96,7 @@ private function doVersionCleanup() } $value = $tConf['steps'] ?? 10; - if (isset($tConf['days']) && !is_null($tConf['days'])) { + if (isset($tConf['days'])) { $versioningType = 'days'; $value = (int)$tConf['days']; } diff --git a/lib/Messenger/Handler/AssetUpdateTasksHandler.php b/lib/Messenger/Handler/AssetUpdateTasksHandler.php index abb0a232783..afdcc0c7310 100644 --- a/lib/Messenger/Handler/AssetUpdateTasksHandler.php +++ b/lib/Messenger/Handler/AssetUpdateTasksHandler.php @@ -15,6 +15,7 @@ namespace Pimcore\Messenger\Handler; +use Pimcore\Helper\LongRunningHelper; use Pimcore\Messenger\AssetUpdateTasksMessage; use Pimcore\Model\Asset; use Pimcore\Model\Version; @@ -25,7 +26,7 @@ */ class AssetUpdateTasksHandler { - public function __construct(protected LoggerInterface $logger) + public function __construct(protected LoggerInterface $logger, protected LongRunningHelper $longRunningHelper) { } @@ -46,6 +47,8 @@ public function __invoke(AssetUpdateTasksMessage $message) } elseif ($asset instanceof Asset\Video) { $this->processVideo($asset); } + + $this->longRunningHelper->deleteTemporaryFiles(); } private function saveAsset(Asset $asset) diff --git a/lib/Routing/RedirectHandler.php b/lib/Routing/RedirectHandler.php index 6014b8f0efc..8dc111af9d4 100644 --- a/lib/Routing/RedirectHandler.php +++ b/lib/Routing/RedirectHandler.php @@ -56,7 +56,7 @@ final class RedirectHandler implements LoggerAwareInterface private $siteResolver; /** - * @var Redirect[] + * @var null|Redirect[] */ private $redirects; @@ -261,7 +261,7 @@ protected function buildRedirectResponse(Redirect $redirect, Request $request, $ */ private function getRegexRedirects() { - if (null !== $this->redirects && is_array($this->redirects)) { + if (is_array($this->redirects)) { return $this->redirects; } diff --git a/lib/Workflow/SupportStrategy/ExpressionSupportStrategy.php b/lib/Workflow/SupportStrategy/ExpressionSupportStrategy.php index 265647d6911..08096f60999 100644 --- a/lib/Workflow/SupportStrategy/ExpressionSupportStrategy.php +++ b/lib/Workflow/SupportStrategy/ExpressionSupportStrategy.php @@ -77,11 +77,9 @@ private function supportsClass($subject) return $subject instanceof $this->className; } - if (is_array($this->className)) { - foreach ($this->className as $className) { - if ($subject instanceof $className) { - return true; - } + foreach ($this->className as $className) { + if ($subject instanceof $className) { + return true; } } diff --git a/models/DataObject/ClassDefinition/Dao.php b/models/DataObject/ClassDefinition/Dao.php index 853accab0be..c737e77d9cd 100644 --- a/models/DataObject/ClassDefinition/Dao.php +++ b/models/DataObject/ClassDefinition/Dao.php @@ -154,6 +154,7 @@ public function update() `position` varchar(70) NOT NULL DEFAULT '0', INDEX `forward_lookup` (`src_id`, `ownertype`, `ownername`, `position`), INDEX `reverse_lookup` (`dest_id`, `type`), + INDEX `fieldname` (`fieldname`), CONSTRAINT `".self::getForeignKeyName($objectDatastoreTableRelation, 'src_id').'` FOREIGN KEY (`src_id`) REFERENCES objects (`o_id`) ON DELETE CASCADE ) DEFAULT CHARSET=utf8mb4;'); diff --git a/models/DataObject/ClassDefinition/Data/Block.php b/models/DataObject/ClassDefinition/Data/Block.php index abadbad827a..cb8befaa10e 100644 --- a/models/DataObject/ClassDefinition/Data/Block.php +++ b/models/DataObject/ClassDefinition/Data/Block.php @@ -665,11 +665,10 @@ public function getFieldDefinitions($context = []) } $enrichedFieldDefinitions = []; - if (is_array($this->fieldDefinitionsCache)) { - foreach ($this->fieldDefinitionsCache as $key => $fieldDefinition) { - $fieldDefinition = $this->doEnrichFieldDefinition($fieldDefinition, $context); - $enrichedFieldDefinitions[$key] = $fieldDefinition; - } + + foreach ($this->fieldDefinitionsCache ?? [] as $key => $fieldDefinition) { + $fieldDefinition = $this->doEnrichFieldDefinition($fieldDefinition, $context); + $enrichedFieldDefinitions[$key] = $fieldDefinition; } return $enrichedFieldDefinitions; diff --git a/models/DataObject/ClassDefinition/Data/Input.php b/models/DataObject/ClassDefinition/Data/Input.php index 21080e62993..987f53e3647 100644 --- a/models/DataObject/ClassDefinition/Data/Input.php +++ b/models/DataObject/ClassDefinition/Data/Input.php @@ -327,7 +327,19 @@ public function getQueryColumnType() public function checkValidity($data, $omitMandatoryCheck = false, $params = []) { if (!$omitMandatoryCheck && $this->getRegex() && strlen($data) > 0) { - if (!preg_match('#' . $this->getRegex() . '#' . implode('', $this->getRegexFlags()), $data)) { + $throwException = false; + if (in_array('g', $this->getRegexFlags())) { + $flags = str_replace('g', '', implode('', $this->getRegexFlags())); + if (!preg_match_all('#' . $this->getRegex() . '#' . $flags, $data)) { + $throwException = true; + } + } else { + if (!preg_match('#' . $this->getRegex() . '#' . implode('', $this->getRegexFlags()), $data)) { + $throwException = true; + } + } + + if ($throwException) { throw new Model\Element\ValidationException('Value in field [ ' . $this->getName() . " ] doesn't match input validation '" . $this->getRegex() . "'"); } } diff --git a/models/DataObject/ClassDefinition/Data/Localizedfields.php b/models/DataObject/ClassDefinition/Data/Localizedfields.php index d329a3044df..b93b40ebf3e 100644 --- a/models/DataObject/ClassDefinition/Data/Localizedfields.php +++ b/models/DataObject/ClassDefinition/Data/Localizedfields.php @@ -712,11 +712,10 @@ public function getFieldDefinitions($context = []) } $enrichedFieldDefinitions = []; - if (is_array($this->fieldDefinitionsCache)) { - foreach ($this->fieldDefinitionsCache as $key => $fieldDefinition) { - $fieldDefinition = $this->doEnrichFieldDefinition($fieldDefinition, $context); - $enrichedFieldDefinitions[$key] = $fieldDefinition; - } + + foreach ($this->fieldDefinitionsCache ?? [] as $key => $fieldDefinition) { + $fieldDefinition = $this->doEnrichFieldDefinition($fieldDefinition, $context); + $enrichedFieldDefinitions[$key] = $fieldDefinition; } return $enrichedFieldDefinitions; diff --git a/models/DataObject/Fieldcollection/Definition.php b/models/DataObject/Fieldcollection/Definition.php index c7b4c3348aa..1e367c56f8d 100644 --- a/models/DataObject/Fieldcollection/Definition.php +++ b/models/DataObject/Fieldcollection/Definition.php @@ -34,6 +34,14 @@ class Definition extends Model\AbstractModel use DataObject\Traits\LocateFileTrait; use Model\DataObject\ClassDefinition\Helper\VarExport; + /** + * @var array + */ + protected const FORBIDDEN_NAMES = [ + 'abstract', 'class', 'data', 'folder', 'list', 'permissions', 'resource', 'dao', 'concrete', 'items', + 'object', 'interface', 'default', + ]; + /** * {@inheritdoc} */ @@ -129,7 +137,7 @@ public function save($saveDefinitionFile = true) throw new \Exception('A field-collection needs a key to be saved!'); } - if (!preg_match('/[a-zA-Z]+/', $this->getKey())) { + if (!preg_match('/^[a-zA-Z][a-zA-Z0-9]*$/', $this->getKey()) || $this->isForbiddenName()) { throw new \Exception(sprintf('Invalid key for field-collection: %s', $this->getKey())); } @@ -288,4 +296,9 @@ protected function getInfoDocBlock(): string return $cd; } + + public function isForbiddenName(): bool + { + return in_array($this->getKey(), self::FORBIDDEN_NAMES); + } } diff --git a/models/DataObject/Objectbrick/Definition.php b/models/DataObject/Objectbrick/Definition.php index 7b97ad41390..01afb23f115 100644 --- a/models/DataObject/Objectbrick/Definition.php +++ b/models/DataObject/Objectbrick/Definition.php @@ -160,7 +160,7 @@ public function save($saveDefinitionFile = true) throw new \Exception('A object-brick needs a key to be saved!'); } - if (!preg_match('/[a-zA-Z]+[a-zA-Z0-9]+/', $this->getKey())) { + if (!preg_match('/^[a-zA-Z][a-zA-Z0-9]*$/', $this->getKey()) || $this->isForbiddenName()) { throw new \Exception(sprintf('Invalid key for object-brick: %s', $this->getKey())); } diff --git a/models/Document/Service.php b/models/Document/Service.php index 51225d4c96c..bcbabe958c5 100644 --- a/models/Document/Service.php +++ b/models/Document/Service.php @@ -94,39 +94,6 @@ public static function render(Document\PageSnippet $document, array $attributes return $content; } - /** - * Save document and all child documents - * - * @param Document $document - * @param int $collectGarbageAfterIteration - * @param int $saved - * - * @throws \Exception - */ - private static function saveRecursive($document, $collectGarbageAfterIteration = 25, &$saved = 0) - { - if ($document instanceof Document) { - $document->save(); - $saved++; - if ($saved % $collectGarbageAfterIteration === 0) { - \Pimcore::collectGarbage(); - } - } - - foreach ($document->getChildren() as $child) { - if (!$child->hasChildren()) { - $child->save(); - $saved++; - if ($saved % $collectGarbageAfterIteration === 0) { - \Pimcore::collectGarbage(); - } - } - if ($child->hasChildren()) { - self::saveRecursive($child, $collectGarbageAfterIteration, $saved); - } - } - } - /** * @param Document $target * @param Document $source diff --git a/models/Staticroute.php b/models/Staticroute.php index 85bdff2fe6b..4ba02ffabb7 100644 --- a/models/Staticroute.php +++ b/models/Staticroute.php @@ -434,10 +434,6 @@ public function setSiteId($siteId) */ public function getSiteId() { - if ($this->siteId && !is_array($this->siteId)) { - $this->siteId = explode(',', $this->siteId); - } - return $this->siteId; } @@ -603,10 +599,6 @@ public function match($path, $params = []) */ public function getMethods() { - if ($this->methods && is_string($this->methods)) { - $this->methods = explode(',', $this->methods); - } - return $this->methods; } diff --git a/models/Version/Dao.php b/models/Version/Dao.php index 9b9d4c8b373..62c5c4a3271 100644 --- a/models/Version/Dao.php +++ b/models/Version/Dao.php @@ -143,7 +143,7 @@ public function maintenanceGetOutdatedVersions($elementTypes, $ignoreIds = []) $count = 0; $stop = false; foreach ($elementTypes as $elementType) { - if (isset($elementType['days']) && !is_null($elementType['days'])) { + if (isset($elementType['days'])) { // by days $deadline = time() - ($elementType['days'] * 86400); $tmpVersionIds = $this->db->fetchFirstColumn('SELECT id FROM versions as a WHERE (ctype = ? AND date < ?) AND NOT public AND id NOT IN (' . $ignoreIdsList . ')', [$elementType['elementType'], $deadline]); diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 31c32cca153..bdfa1047aec 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -295,4 +295,23 @@ parameters: paths: - models/DataObject/ClassDefinition/Data/AdvancedManyToManyObjectRelation.php - models/DataObject/ClassDefinition/Data/ClassSavedInterface.php - - models/DataObject/ClassDefinition/Data/Classificationstore.php \ No newline at end of file + - models/DataObject/ClassDefinition/Data/Classificationstore.php + - + message: "#^Method Pimcore\\\\Messenger\\\\Handler\\\\CleanupThumbnailsHandler\\:\\:process\\(\\) is unused\\.$#" + count: 1 + path: lib/Messenger/Handler/CleanupThumbnailsHandler.php + + - + message: "#^Method Pimcore\\\\Messenger\\\\Handler\\\\SanityCheckHandler\\:\\:process\\(\\) is unused\\.$#" + count: 1 + path: lib/Messenger/Handler/SanityCheckHandler.php + + - + message: "#^Method Pimcore\\\\Messenger\\\\Handler\\\\SearchBackendHandler\\:\\:process\\(\\) is unused\\.$#" + count: 1 + path: lib/Messenger/Handler/SearchBackendHandler.php + + - + message: "#^Method Pimcore\\\\Messenger\\\\Handler\\\\SearchBackendHandler\\:\\:shouldFlush\\(\\) is unused\\.$#" + count: 1 + path: lib/Messenger/Handler/SearchBackendHandler.php