Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Deprecated Connection::PARAM_*_ARRAY constants #45

Merged
merged 3 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 48 additions & 46 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
}
}
}
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
Loading