forked from pimcore/pimcore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'pimcore:11.x' into 11.x
- Loading branch information
Showing
28 changed files
with
434 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
bundles/CoreBundle/src/Migrations/Version20241021111028.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
142
bundles/CoreBundle/src/Migrations/Version20241025101923.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...tallation_and_Upgrade/03_System_Setup_and_Hosting/08_Multi_Application_Setup.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
``` | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.