Skip to content

Commit

Permalink
Merge branch '11.1' into 11.x
Browse files Browse the repository at this point in the history
  • Loading branch information
fashxp committed Mar 5, 2024
2 parents 86d6e12 + 3ebb18a commit 4da5b84
Show file tree
Hide file tree
Showing 18 changed files with 237 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function write(LogRecord $record): void
'pid' => getmypid(),
'priority' => $record->level->toPsrLogLevel(),
'message' => $record->message,
'timestamp' => $record->datetime->format('Y-m-d H:i:s'),
'timestamp' => $record->datetime->setTimezone(new \DateTimeZone('UTC'))->format('Y-m-d H:i:s'),
'component' => $record->context['component'] ?? $record->channel,
'fileobject' => $record->context['fileObject'] ?? null,
'relatedobject' => $record->context['relatedObject'] ?? null,
Expand Down
5 changes: 5 additions & 0 deletions bundles/CoreBundle/src/Migrations/Version20230616085142.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ final class Version20230616085142 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`';

Expand All @@ -51,10 +53,13 @@ public function up(Schema $schema): void
$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->hasPrimaryKey()) {
Expand Down
90 changes: 90 additions & 0 deletions bundles/CoreBundle/src/Migrations/Version20240222143211.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?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;

/**
* Modifies foreign key constraints for specified tables, changing their names from ending in '_o_id' to '_id' and adding ON DELETE CASCADE.
* The down method reverses the naming back to '_o_id' while keeping ON DELETE CASCADE.
*/
final class Version20240222143211 extends AbstractMigration
{
public function getDescription(): string
{
return 'Dynamically rename _o_id foreign keys to _id.';
}

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

foreach($schema->getTables() as $table) {
if($table->hasColumn('id')) {
$tableName = $table->getName();

if (
str_starts_with($tableName, 'object_brick_') ||
str_starts_with($tableName, 'object_classificationstore_') ||
str_starts_with($tableName, 'object_collection_') ||
str_starts_with($tableName, 'object_metadata_')
) {
$foreignKeyWithoutOPrefix = AbstractDao::getForeignKeyName($tableName, 'id');
$foreignKeyWithOPrefix = AbstractDao::getForeignKeyName($tableName, 'o_id');

if ($table->hasForeignKey($foreignKeyWithOPrefix)) {
$this->addSql("ALTER TABLE {$tableName} DROP FOREIGN KEY {$foreignKeyWithOPrefix}");
$this->addSql("ALTER TABLE {$tableName} ADD CONSTRAINT {$foreignKeyWithoutOPrefix} FOREIGN KEY (id) REFERENCES objects(id) ON DELETE CASCADE");
}
}
}
}

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

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

foreach($schema->getTables() as $table) {
if($table->hasColumn('id')) {
$tableName = $table->getName();

if (
str_starts_with($tableName, 'object_brick_') ||
str_starts_with($tableName, 'object_classificationstore_') ||
str_starts_with($tableName, 'object_collection_') ||
str_starts_with($tableName, 'object_metadata_')
) {
$foreignKeyWithoutOPrefix = AbstractDao::getForeignKeyName($tableName, 'id');
$foreignKeyWithOPrefix = AbstractDao::getForeignKeyName($tableName, 'o_id');

if ($table->hasForeignKey($foreignKeyWithoutOPrefix)) {
$this->addSql("ALTER TABLE {$tableName} DROP FOREIGN KEY {$foreignKeyWithoutOPrefix}");
$this->addSql("ALTER TABLE {$tableName} ADD CONSTRAINT {$foreignKeyWithOPrefix} FOREIGN KEY (id) REFERENCES objects(id) ON DELETE CASCADE");
}
}
}
}

$this->addSql('SET foreign_key_checks = 1');
}
}
2 changes: 1 addition & 1 deletion bundles/TinymceBundle/public/js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pimcore.bundle.tinymce.editor = Class.create({
base_url: '/bundles/pimcoretinymce/build/tinymce',
suffix: '.min',
convert_urls: false,
extended_valid_elements: 'a[name|href|target|title|pimcore_id|pimcore_type],img[style|longdesc|usemap|src|border|alt=|title|hspace|vspace|width|height|align|pimcore_id|pimcore_type]',
extended_valid_elements: 'a[class|name|href|target|title|pimcore_id|pimcore_type],img[class|style|longdesc|usemap|src|border|alt=|title|hspace|vspace|width|height|align|pimcore_id|pimcore_type]',
init_instance_callback: function (editor) {
editor.on('input', function (eChange) {
const charCount = tinymce.activeEditor.plugins.wordcount.body.getCharacterCount();
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
"codeception/codeception": "^5.0.3",
"codeception/module-symfony": "^3.1.0",
"ergebnis/phpstan-rules": "^2.0",
"phpstan/phpstan": "1.10.56",
"phpstan/phpstan": "1.10.59",
"phpstan/phpstan-symfony": "^1.3.5",
"phpunit/phpunit": "^9.3",
"gotenberg/gotenberg-php": "^1.1",
Expand Down
3 changes: 1 addition & 2 deletions doc/19_Development_Tools_and_Details/09_Cache/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ if(!$data = \Pimcore\Cache::load($cacheKey)) {

#### Disable the Cache for a Single Request
Sometimes it's useful to deactivate the cache for testing purposes for a single request. You
can do this by passing the URL parameter `pimcore_nocache=true`. Note: This is only possible if you have
enabled the `DEBUG MODE` in *Settings* > *System*
can do this by passing the URL parameter `pimcore_nocache=true`. Note: This is only possible if you are in [DEBUG MODE](../13_Debugging.md#debug-mode)

For example: `http://www.pimcore.org/download?pimcore_nocache=true`

Expand Down
47 changes: 32 additions & 15 deletions doc/21_Deployment/03_Configuration_Environments.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,37 +59,37 @@ pimcore:
config_location:
image_thumbnails:
write_target:
type: 'symfony-config'
options:
type: 'symfony-config'
options:
directory: '/var/www/html/var/config/image-thumbnails'
video_thumbnails:
write_target:
type: 'disabled'
type: 'disabled'
document_types:
write_target:
type: 'disabled'
type: 'disabled'
predefined_properties:
write_target:
type: 'settings-store'
type: 'settings-store'
predefined_asset_metadata:
write_target:
type: 'symfony-config'
options:
type: 'symfony-config'
options:
directory: '/var/www/html/var/config/predefined_asset_metadata'
perspectives:
write_target:
type: 'symfony-config'
options:
type: 'symfony-config'
options:
directory: '/var/www/html/var/config/perspectives'
custom_views:
write_target:
type: 'symfony-config'
options:
type: 'symfony-config'
options:
directory: '/var/www/html/var/config/custom_views'
object_custom_layouts:
write_target:
type: 'symfony-config'
options:
type: 'symfony-config'
options:
directory: '/var/www/html/var/config/object_custom_layouts'
select_options:
write_target:
Expand All @@ -98,6 +98,23 @@ pimcore:
directory: '/var/www/html/var/config/select_options'
```

and for some specific optional bundles are:

```yaml
pimcore_custom_reports:
config_location:
custom_reports:
write_target:
type: 'symfony-config'

pimcore_static_routes:
config_location:
staticroutes:
write_target:
type: 'symfony-config'
...
```

#### Production environment with `symfony-config`
When using `symfony-config` write target, configs are written to Symfony Config files (`yaml`), which are only getting revalidated in debug mode. So if you're
changing configs in production you won't see any update, because these configs are read only.
Expand All @@ -107,9 +124,9 @@ You can do so by adding the following to your `symfony-config`. e.g.:
```yaml
pimcore:
config_location:
custom_reports:
predefined_properties:
write_target:
type: 'settings-store'
type: 'settings-store'
```

#### Revalidate existing configuration on production
Expand Down

0 comments on commit 4da5b84

Please sign in to comment.