Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mautz-et-tong/4b9b5df1d7089841c6c723f16f347007 to your computer and use it in GitHub Desktop.
Save mautz-et-tong/4b9b5df1d7089841c6c723f16f347007 to your computer and use it in GitHub Desktop.
akeneo mariadb compat patch file
diff --git a/src/Akeneo/Platform/PimRequirements.php b/src/Akeneo/Platform/PimRequirements.php
--- a/src/Akeneo/Platform/PimRequirements.php
+++ b/src/Akeneo/Platform/PimRequirements.php
@@ -27,7 +27,8 @@
const REQUIRED_ICU_VERSION = '67.1';
const LOWEST_REQUIRED_MYSQL_VERSION = '8.0.30';
const GREATEST_REQUIRED_MYSQL_VERSION = '8.1.0';
-
+ const LOWEST_REQUIRED_MARIADB_VERSION = '10.4.15';
+ const GREATEST_REQUIRED_MARIADB_VERSION = '10.5.25';
const REQUIRED_EXTENSIONS = [
'apcu',
'bcmath',
@@ -120,21 +121,43 @@
'Set the "<strong>memory_limit</strong>" setting in php.ini<a href="#phpini">*</a> to at least "512M".'
);
- $currentMySQLVersion = $this->getMySQLVersion();
- $requirements[] = new Requirement(
- version_compare($currentMySQLVersion, self::LOWEST_REQUIRED_MYSQL_VERSION, '>=') &&
- version_compare($currentMySQLVersion, self::GREATEST_REQUIRED_MYSQL_VERSION, '<'),
- sprintf(
- 'MySQL version must be greater or equal to %s and lower than %s',
- self::LOWEST_REQUIRED_MYSQL_VERSION,
- self::GREATEST_REQUIRED_MYSQL_VERSION
- ),
- sprintf(
- 'Install MySQL greater or equal to %s and lower than %s (installed version is %s)',
- self::LOWEST_REQUIRED_MYSQL_VERSION,
- self::GREATEST_REQUIRED_MYSQL_VERSION,
- $currentMySQLVersion
- )
+ $currentMySQL = $this->getMySQLVersion();
+ switch($currentMySQL['dialect']){
+ case 'MariaDB':
+ $fullfilled = version_compare($currentMySQL['version'], self::LOWEST_REQUIRED_MARIADB_VERSION, '>=') &&
+ version_compare($currentMySQL['version'], self::GREATEST_REQUIRED_MARIADB_VERSION, '<');
+ $testMessage = sprintf(
+ $currentMySQL['dialect'] . ' version must be greater or equal to %s and lower than %s',
+ self::LOWEST_REQUIRED_MARIADB_VERSION,
+ self::GREATEST_REQUIRED_MARIADB_VERSION
+ );
+ $helpHtml = sprintf(
+ 'Install ' .$currentMySQL['dialect'] . ' greater or equal to %s and lower than %s (installed version is %s)',
+ self::LOWEST_REQUIRED_MARIADB_VERSION,
+ self::GREATEST_REQUIRED_MARIADB_VERSION,
+ $currentMySQL['version']
+ );
+ break;
+ default:
+ $fullfilled = version_compare($currentMySQL['version'], self::LOWEST_REQUIRED_MYSQL_VERSION, '>=') &&
+ version_compare($currentMySQL['version'], self::GREATEST_REQUIRED_MYSQL_VERSION, '<');
+ $testMessage = sprintf(
+ $currentMySQL['dialect'] . ' version must be greater or equal to %s and lower than %s',
+ self::LOWEST_REQUIRED_MYSQL_VERSION,
+ self::GREATEST_REQUIRED_MYSQL_VERSION
+ );
+ $helpHtml = sprintf(
+ 'Install ' .$currentMySQL['dialect'] . ' greater or equal to %s and lower than %s (installed version is %s)',
+ self::LOWEST_REQUIRED_MYSQL_VERSION,
+ self::GREATEST_REQUIRED_MYSQL_VERSION,
+ $currentMySQL['version']
+ );
+ break;
+ }
+ $requirements[] = new Requirement(
+ $fullfilled,
+ $testMessage,
+ $helpHtml
);
$innodbPageSize = (int) $this->getMySQLVariableValue("innodb_page_size");
@@ -187,18 +210,21 @@
}
/**
- * Gets the MySQL server version thanks to a PDO connection.
+ * Gets the MySQL server version and dialect thanks to a PDO connection.
*
* It can accept version with suffix
* @see https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_version
*/
- protected function getMySQLVersion(): string
+ protected function getMySQLVersion(): array
{
+ $installedMysqlVersion = [];
$mysqlVersion = $this->getConnection()->getAttribute(PDO::ATTR_SERVER_VERSION);
- if (strpos($mysqlVersion, '-')) {
- $mysqlVersion = substr($mysqlVersion, 0, strpos($mysqlVersion, '-'));
+ if (preg_match('/(\d+\.\d+\.\d+)-(\w+)-\d+\+(\w+)/', $mysqlVersion, $matches)) {
+ $installedMysqlVersion['version'] = $matches[1];
+ $installedMysqlVersion['dialect'] = $matches[2];
+ $installedMysqlVersion['package'] = $matches[3];
}
- return $mysqlVersion;
+ return $installedMysqlVersion;
}
/**
diff --git a/src/Akeneo/Category/back/Infrastructure/EventSubscriber/InitCategoryDbSchemaSubscriber.php b/src/Akeneo/Category/back/Infrastructure/EventSubscriber/InitCategoryDbSchemaSubscriber.php
--- a/src/Akeneo/Category/back/Infrastructure/EventSubscriber/InitCategoryDbSchemaSubscriber.php
+++ b/src/Akeneo/Category/back/Infrastructure/EventSubscriber/InitCategoryDbSchemaSubscriber.php
@@ -66,7 +66,7 @@
CONSTRAINT `FK_TREE_TEMPLATE_template_uuid` FOREIGN KEY (`category_template_uuid`) REFERENCES `pim_catalog_category_template` (`uuid`),
CONSTRAINT `FK_TREE_TEMPLATE_tree_id` FOREIGN KEY (`category_tree_id`) REFERENCES `pim_catalog_category` (`id`),
CONSTRAINT `PRIMARY` PRIMARY KEY (category_tree_id,category_template_uuid)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
SQL;
$this->dbalConnection->executeQuery($query);
@@ -87,7 +87,7 @@
`is_localizable` TINYINT(1) NOT NULL,
`additional_properties` JSON NULL,
CONSTRAINT `FK_ATTRIBUTE_template_uiid` FOREIGN KEY (`category_template_uuid`) REFERENCES `pim_catalog_category_template` (`uuid`)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
SQL;
$this->dbalConnection->executeQuery($query);
diff --git a/upgrades/schema/Version_7_0_20221019102101_add_category_template_tree_table.php b/upgrades/schema/Version_7_0_20221019102101_add_category_template_tree_table.php
--- a/upgrades/schema/Version_7_0_20221019102101_add_category_template_tree_table.php
+++ b/upgrades/schema/Version_7_0_20221019102101_add_category_template_tree_table.php
@@ -16,7 +16,7 @@
CONSTRAINT `FK_TREE_TEMPLATE_template_uuid` FOREIGN KEY (`category_template_uuid`) REFERENCES `pim_catalog_category_template` (`uuid`),
CONSTRAINT `FK_TREE_TEMPLATE_tree_id` FOREIGN KEY (`category_tree_id`) REFERENCES `pim_catalog_category` (`id`),
CONSTRAINT `PRIMARY` PRIMARY KEY (category_tree_id,category_template_uuid)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
SQL
);
}
diff --git a/upgrades/schema/Version_7_0_20221020161903_add_category_attribute_table.php b/upgrades/schema/Version_7_0_20221020161903_add_category_attribute_table.php
--- a/upgrades/schema/Version_7_0_20221020161903_add_category_attribute_table.php
+++ b/upgrades/schema/Version_7_0_20221020161903_add_category_attribute_table.php
@@ -22,7 +22,7 @@
`is_localizable` TINYINT(1) NOT NULL,
`additional_properties` JSON NULL,
CONSTRAINT `FK_ATTRIBUTE_template_uiid` FOREIGN KEY (`category_template_uuid`) REFERENCES `pim_catalog_category_template` (`uuid`)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
SQL
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment