Skip to content

Commit

Permalink
Fix: Deprecated Connection::PARAM_*_ARRAY constants
Browse files Browse the repository at this point in the history
  • Loading branch information
blankse committed Sep 4, 2023
1 parent bd2e352 commit 2526743
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 60 deletions.
95 changes: 48 additions & 47 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,52 +1,53 @@
{
"name": "pimcore/web-to-print-bundle",
"license": "GPL-3.0-or-later",
"type": "pimcore-bundle",
"description": "Pimcore WebToPrint Bundle",
"config": {
"sort-packages": true,
"preferred-install": {
"pimcore/pimcore": "source",
"*": "dist"
}
},
"prefer-stable": true,
"minimum-stability": "dev",
"require": {
"pimcore/pimcore": "^11.0",
"pimcore/admin-ui-classic-bundle": "^1.1"
},
"require-dev": {
"phpstan/phpstan": "^1.10.5",
"phpstan/phpstan-symfony": "^1.2.20",
"gotenberg/gotenberg-php": "^1.0.0",
"chrome-php/chrome": "^1.8",
"codeception/codeception": "^5.0.3",
"codeception/module-symfony": "^3.1.0",
"codeception/phpunit-wrapper": "^9"
},
"suggest": {
"gotenberg/gotenberg-php": "Required for generating pdf via Gotenberg in assets preview (LibreOffice), page preview, version diff and web2print",
"chrome-php/chrome": "Required for Documents Page Previews"
},
"autoload": {
"psr-4": {
"Pimcore\\Bundle\\WebToPrintBundle\\": "src/"
}
"name": "pimcore/web-to-print-bundle",
"license": "GPL-3.0-or-later",
"type": "pimcore-bundle",
"description": "Pimcore WebToPrint Bundle",
"config": {
"sort-packages": true,
"preferred-install": {
"pimcore/pimcore": "source",
"*": "dist"
}
},
"prefer-stable": true,
"minimum-stability": "dev",
"require": {
"doctrine/dbal": "^3.6",
"pimcore/pimcore": "^11.0",
"pimcore/admin-ui-classic-bundle": "^1.1"
},
"require-dev": {
"phpstan/phpstan": "^1.10.5",
"phpstan/phpstan-symfony": "^1.2.20",
"gotenberg/gotenberg-php": "^1.0.0",
"chrome-php/chrome": "^1.8",
"codeception/codeception": "^5.0.3",
"codeception/module-symfony": "^3.1.0",
"codeception/phpunit-wrapper": "^9"
},
"suggest": {
"gotenberg/gotenberg-php": "Required for generating pdf via Gotenberg in assets preview (LibreOffice), page preview, version diff and web2print",
"chrome-php/chrome": "Required for Documents Page Previews"
},
"autoload": {
"psr-4": {
"Pimcore\\Bundle\\WebToPrintBundle\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Pimcore\\Bundle\\WebToPrintBundle\\Tests\\": "tests"
},
"autoload-dev": {
"psr-4": {
"Pimcore\\Bundle\\WebToPrintBundle\\Tests\\": "tests"
},
"files": [
"kernel/Kernel.php"
"files": [
"kernel/Kernel.php"
]
},
"extra": {
"pimcore": {
"bundles": [
"Pimcore\\Bundle\\WebToPrintBundle\\PimcoreWebToPrintBundle"
]
},
"extra": {
"pimcore": {
"bundles": [
"Pimcore\\Bundle\\WebToPrintBundle\\PimcoreWebToPrintBundle"
]
}
}
}
}
21 changes: 8 additions & 13 deletions src/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
namespace Pimcore\Bundle\WebToPrintBundle;

use Doctrine\DBAL\ArrayParameterType;
use Doctrine\DBAL\Connection;
use Pimcore\Db;
use Pimcore\Extension\Bundle\Installer\SettingsStoreAwareInstaller;
use Pimcore\Model\Tool\SettingsStore;
Expand Down Expand Up @@ -76,7 +75,7 @@ public function uninstall(): void

private function addUserPermission(): void
{
$db = \Pimcore\Db::get();
$db = Db::get();

foreach (self::USER_PERMISSIONS as $permission) {
// check if the permission already exists
Expand All @@ -92,7 +91,7 @@ private function addUserPermission(): void

private function removeUserPermission(): void
{
$db = \Pimcore\Db::get();
$db = Db::get();

foreach (self::USER_PERMISSIONS as $permission) {
$db->delete('users_permission_definitions', [
Expand All @@ -105,7 +104,7 @@ private function installDatabaseTable(): void
{
$sqlPath = __DIR__ . '/Resources/install/';
$sqlFileNames = ['install.sql'];
$db = \Pimcore\Db::get();
$db = Db::get();

foreach ($sqlFileNames as $fileName) {
$statement = file_get_contents($sqlPath.$fileName);
Expand All @@ -122,7 +121,7 @@ private function getCurrentEnumTypes(): array
$typeColumn = $result->fetchAllAssociative();

return explode("','", preg_replace("/(enum)\('(.+?)'\)/", '\\2', $typeColumn[0]['Type']));
} catch (\Exception $ex) {
} catch (\Exception) {
// nothing to do here if it does not work we return the standard types
}

Expand All @@ -131,21 +130,17 @@ private function getCurrentEnumTypes(): array

private function modifyEnumTypes(array $enums): void
{
$type = Connection::PARAM_STR_ARRAY;
if (class_exists('Doctrine\\DBAL\\ArrayParameterType')) {
$type = ArrayParameterType::STRING;
}
$db = Db::get();
$db->executeQuery('ALTER TABLE documents MODIFY COLUMN `type` ENUM(:enums);', ['enums' => $enums], ['enums' => $type]);
$db->executeQuery('ALTER TABLE documents MODIFY COLUMN `type` ENUM(:enums);', ['enums' => $enums], ['enums' => ArrayParameterType::STRING]);
}

private function removePrintDocTypes(): void
{
foreach(SettingsStore::getIdsByScope(self::SETTINGS_STORE_SCOPE) as $id) {
foreach (SettingsStore::getIdsByScope(self::SETTINGS_STORE_SCOPE) as $id) {
$printDocTypes = SettingsStore::get($id, self::SETTINGS_STORE_SCOPE);
if($printDocTypes) {
if ($printDocTypes) {
$data = json_decode($printDocTypes->getData(), true);
if(!empty($data) && in_array($data['type'], self::DOCTYPES)) {
if (!empty($data) && in_array($data['type'], self::DOCTYPES)) {
SettingsStore::delete($id, self::SETTINGS_STORE_SCOPE);
}
}
Expand Down

0 comments on commit 2526743

Please sign in to comment.