From 4bcef82bd5de6870de4c467fd36cd4f1e07e9fef Mon Sep 17 00:00:00 2001 From: Sebastian Blank Date: Thu, 21 Dec 2023 10:23:45 +0100 Subject: [PATCH] Fix: Deprecated Connection::PARAM_*_ARRAY constants (#45) * Fix: Deprecated Connection::PARAM_*_ARRAY constants * Add php versions --- composer.json | 94 ++++++++++++++++++++++++----------------------- src/Installer.php | 21 ++++------- 2 files changed, 56 insertions(+), 59 deletions(-) diff --git a/composer.json b/composer.json index 95d9c5f..2b00a1d 100644 --- a/composer.json +++ b/composer.json @@ -1,51 +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, - "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, + "require": { + "php": "~8.1.0 || ~8.2.0", + "doctrine/dbal": "^3.6", + "pimcore/admin-ui-classic-bundle": "^1.1", + "pimcore/pimcore": "^11.0" + }, + "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" - ] - } } + } } diff --git a/src/Installer.php b/src/Installer.php index 69192f8..3247812 100644 --- a/src/Installer.php +++ b/src/Installer.php @@ -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; @@ -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 @@ -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', [ @@ -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); @@ -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 } @@ -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); } }