Skip to content

Commit

Permalink
Merge branch 'pimcore:11.x' into 11.x
Browse files Browse the repository at this point in the history
  • Loading branch information
michalananapps authored Nov 6, 2024
2 parents 4af93ed + 322366f commit 55e1162
Show file tree
Hide file tree
Showing 28 changed files with 434 additions and 132 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
56 changes: 56 additions & 0 deletions bundles/CoreBundle/src/Migrations/Version20241021111028.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

declare(strict_types=1);

/**
* Pimcore
*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - Pimcore Commercial License (PCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license GPLv3 and PCL
*/

namespace Pimcore\Bundle\CoreBundle\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

final class Version20241021111028 extends AbstractMigration
{
protected array $tables = [
'assets',
'documents',
'objects',
'versions',
];

public function getDescription(): string
{
return 'Add versionCount index to elements and versions table';
}

public function up(Schema $schema): void
{
foreach ($this->tables as $table) {
$dbTable = $schema->getTable($table);
if (!$dbTable->hasIndex('versionCount')) {
$dbTable->addIndex(['versionCount'], 'versionCount');
}
}
}

public function down(Schema $schema): void
{
foreach ($this->tables as $table) {
$dbTable = $schema->getTable($table);
if ($dbTable->hasIndex('versionCount')) {
$dbTable->dropIndex('versionCount');
}
}
}
}
142 changes: 142 additions & 0 deletions bundles/CoreBundle/src/Migrations/Version20241025101923.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<?php

declare(strict_types=1);

/**
* Pimcore
*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - Pimcore Commercial License (PCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license GPLv3 and PCL
*/

namespace Pimcore\Bundle\CoreBundle\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
use Pimcore\Model\Dao\AbstractDao;

final class Version20241025101923 extends AbstractMigration
{
private const ID_COLUMN = 'id';

private const O_PREFIX = 'o_';

private const PK_COLUMNS = '`' . self::ID_COLUMN .
'`,`dest_id`, `type`, `fieldname`, `column`, `ownertype`, `ownername`, `position`, `index`';

private const UNIQUE_KEY_NAME = 'metadata_un';

private const AUTO_ID = 'auto_id';

public function getDescription(): string
{
return 'Follow up migrating object_metadata schema to have a auto increment column';
}

public function up(Schema $schema): void
{
$this->addSql('SET foreign_key_checks = 0');

$metaDataTables = $this->connection->fetchAllAssociative(
"SHOW FULL TABLES
WHERE `Tables_in_{$this->connection->getDatabase()}`
LIKE 'object_metadata_%' AND Table_type = 'BASE TABLE'"
);

foreach ($metaDataTables as $table) {
$tableName = current($table);
$metaDataTable = $schema->getTable($tableName);
$foreignKeyName = AbstractDao::getForeignKeyName($tableName, self::ID_COLUMN);
$foreignKeyNameWithOPrefix = AbstractDao::getForeignKeyName($tableName, self::O_PREFIX . self::ID_COLUMN);

if (!$metaDataTable->hasColumn(self::AUTO_ID)) {
if ($recreateForeignKey = $metaDataTable->hasForeignKey($foreignKeyName)) {
$this->addSql('ALTER TABLE `' . $tableName . '` DROP FOREIGN KEY `' . $foreignKeyName . '`');
} elseif ($recreateForeignKey = $metaDataTable->hasForeignKey($foreignKeyNameWithOPrefix)) {
$this->addSql('ALTER TABLE `' . $tableName . '` DROP FOREIGN KEY `' . $foreignKeyNameWithOPrefix . '`');
}

if ($metaDataTable->getPrimaryKey()) {
$this->addSql('ALTER TABLE `' . $tableName . '` DROP PRIMARY KEY');
}

$this->addSql('ALTER TABLE ' . $tableName . ' ADD `' . self::AUTO_ID .
'` int(11) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST');

if (!$metaDataTable->hasIndex(self::UNIQUE_KEY_NAME)) {
$this->addSql(
'ALTER TABLE `' . $tableName . '`
ADD CONSTRAINT `' . self::UNIQUE_KEY_NAME . '`
UNIQUE (' . self::PK_COLUMNS . ')'
);
}

if ($recreateForeignKey) {
$this->addSql(
'ALTER TABLE `' . $tableName . '`
ADD CONSTRAINT `'.$foreignKeyName.'`
FOREIGN KEY (`' . self::ID_COLUMN . '`)
REFERENCES `objects` (`' . self::ID_COLUMN . '`)
ON UPDATE NO ACTION
ON DELETE CASCADE;'
);
}
}
}

$this->addSql('SET foreign_key_checks = 1');
}

public function down(Schema $schema): void
{
$this->addSql('SET foreign_key_checks = 0');

$metaDataTables = $this->connection->fetchAllAssociative(
"SHOW FULL TABLES
WHERE `Tables_in_{$this->connection->getDatabase()}`
LIKE 'object_metadata_%' AND Table_type = 'BASE TABLE'"
);

foreach ($metaDataTables as $table) {
$tableName = current($table);
$metaDataTable = $schema->getTable($tableName);
$foreignKeyName = AbstractDao::getForeignKeyName($tableName, self::ID_COLUMN);

if ($metaDataTable->hasColumn(self::AUTO_ID)) {
if ($recreateForeignKey = $metaDataTable->hasForeignKey($foreignKeyName)) {
$this->addSql('ALTER TABLE `' . $tableName . '` DROP FOREIGN KEY `' . $foreignKeyName . '`');
}

$this->addSql('ALTER TABLE `' . $tableName . '` DROP COLUMN `' . self::AUTO_ID . '`');
$this->addSql(
'ALTER TABLE `' . $tableName . '` ADD PRIMARY KEY (' . self::PK_COLUMNS . ')'
);

if ($metaDataTable->hasIndex(self::UNIQUE_KEY_NAME)) {
$this->addSql(
'ALTER TABLE `' . $tableName . '` DROP INDEX `' . self::UNIQUE_KEY_NAME . '`'
);
}

if ($recreateForeignKey) {
$this->addSql(
'ALTER TABLE `' . $tableName . '`
ADD CONSTRAINT `'.$foreignKeyName.'`
FOREIGN KEY (`' . self::ID_COLUMN . '`)
REFERENCES `objects` (`' . self::ID_COLUMN . '`)
ON UPDATE RESTRICT
ON DELETE CASCADE;'
);
}
}
}

$this->addSql('SET foreign_key_checks = 1');
}
}
12 changes: 8 additions & 4 deletions bundles/InstallBundle/dump/install.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ CREATE TABLE `assets` (
UNIQUE KEY `fullpath` (`path`,`filename`),
KEY `parentId` (`parentId`),
KEY `filename` (`filename`),
KEY `modificationDate` (`modificationDate`)
KEY `modificationDate` (`modificationDate`),
KEY `versionCount` (`versionCount`)
) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;

DROP TABLE IF EXISTS `assets_metadata`;
Expand Down Expand Up @@ -90,7 +91,8 @@ CREATE TABLE `documents` (
KEY `parentId` (`parentId`),
KEY `key` (`key`),
KEY `published` (`published`),
KEY `modificationDate` (`modificationDate`)
KEY `modificationDate` (`modificationDate`),
KEY `versionCount` (`versionCount`)
) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;

DROP TABLE IF EXISTS `documents_editables`;
Expand Down Expand Up @@ -290,7 +292,8 @@ CREATE TABLE `objects` (
KEY `parentId` (`parentId`),
KEY `type_path_classId` (`type`, `path`, `classId`),
KEY `modificationDate` (`modificationDate`),
KEY `classId` (`classId`)
KEY `classId` (`classId`),
KEY `versionCount` (`versionCount`)
) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;

DROP TABLE IF EXISTS `properties`;
Expand Down Expand Up @@ -588,7 +591,8 @@ CREATE TABLE `versions` (
KEY `date` (`date`),
KEY `binaryFileHash` (`binaryFileHash`),
KEY `autoSave` (`autoSave`),
KEY `stackTrace` (`stackTrace`(1))
KEY `stackTrace` (`stackTrace`(1)),
KEY `versionCount` (`versionCount`)
) DEFAULT CHARSET=utf8mb4;

DROP TABLE IF EXISTS `website_settings`;
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 @@ -139,7 +139,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
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Multi-application setup

## Sessions

When running multiple applications on the same domain, there can be session cookie collisions which prevent you to log in to both systems at the same time.

Imagine you run a web shop app on http://example.org and Pimcore on http://pim.example.org. Then you will have 2 cookies with name `PHPSESSID` (if `session.name` in php.ini is the same for both):
| Name| Value | Domain | Path |
|---|---|---|---|
| PHPSESSID | 5a9b08750387d9e11c738a2947d93e38 | .example.org | / |
| PHPSESSID | irqnjh5p96gp2i8iu743ulm32p | pim.example.org | / |

First one is from the web shop, second one from Pimcore.
When trying to log in at http://example.org/admin you will get a 403 Forbidden error.
(The reason why the web shop sets the cookie for `.example.org` instead of `example.org` probably is to also support subdomains.)

You can prevent this problem with the following config in your `config.yaml`. This way the session cookies do not conflict anymore and you will be able to log in to both applications at the same time.
```yaml
framework:
session:
name: "PIMCORE_SESSION_ID"
```
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@

## Advanced Topics
- [Cluster Setup](07_Cluster_Setup.md)
- [Multi-application setup](08_Multi_Application_Setup.md)
- [Performance Guide](09_Performance_Guide.md)
8 changes: 8 additions & 0 deletions doc/23_Installation_and_Upgrade/09_Upgrade_Notes/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# Upgrade Notes
## Pimcore 11.5.0
### [Events]
- `context` property of `ResolveUploadTargetEvent` is deprecated. Use `setArgument()` method instead.

## Pimcore 11.5.0
### General
#### [Database]
- Added an index on `versionCount` columns

## Pimcore 11.4.0
### General
Expand Down
Loading

0 comments on commit 55e1162

Please sign in to comment.