From 36efcaa665105c18b5055b9fec001509441fb0a3 Mon Sep 17 00:00:00 2001 From: kurozumi Date: Thu, 14 Jul 2022 12:28:10 +0900 Subject: [PATCH 1/8] =?UTF-8?q?PHP8=E3=81=A8MySQL=E3=81=A7=E3=83=97?= =?UTF-8?q?=E3=83=A9=E3=82=B0=E3=82=A4=E3=83=B3=E3=82=A2=E3=83=83=E3=83=97?= =?UTF-8?q?=E3=83=87=E3=83=BC=E3=83=88=E3=82=B3=E3=83=9E=E3=83=B3=E3=83=89?= =?UTF-8?q?=E3=82=92=E5=AE=9F=E8=A1=8C=E3=81=99=E3=82=8B=E3=81=A8=20no=20a?= =?UTF-8?q?ctive=20transaction=20=E3=81=AB=E3=81=AA=E3=82=8B=E3=81=AE?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Eccube/Service/PluginService.php | 117 +++++++++++++++------------ 1 file changed, 64 insertions(+), 53 deletions(-) diff --git a/src/Eccube/Service/PluginService.php b/src/Eccube/Service/PluginService.php index f44d90de33f..c8298dd1481 100644 --- a/src/Eccube/Service/PluginService.php +++ b/src/Eccube/Service/PluginService.php @@ -123,18 +123,19 @@ class PluginService * @param PluginContext $pluginContext */ public function __construct( - EntityManagerInterface $entityManager, - PluginRepository $pluginRepository, - EntityProxyService $entityProxyService, - SchemaService $schemaService, - EccubeConfig $eccubeConfig, - ContainerInterface $container, - CacheUtil $cacheUtil, + EntityManagerInterface $entityManager, + PluginRepository $pluginRepository, + EntityProxyService $entityProxyService, + SchemaService $schemaService, + EccubeConfig $eccubeConfig, + ContainerInterface $container, + CacheUtil $cacheUtil, ComposerServiceInterface $composerService, - PluginApiService $pluginApiService, - SystemService $systemService, - PluginContext $pluginContext - ) { + PluginApiService $pluginApiService, + SystemService $systemService, + PluginContext $pluginContext + ) + { $this->entityManager = $entityManager; $this->pluginRepository = $pluginRepository; $this->entityProxyService = $entityProxyService; @@ -153,8 +154,8 @@ public function __construct( /** * ファイル指定してのプラグインインストール * - * @param string $path path to tar.gz/zip plugin file - * @param int $source + * @param string $path path to tar.gz/zip plugin file + * @param int $source * * @return boolean * @@ -230,8 +231,10 @@ public function installWithCode($code) }); if (!empty($notInstalledOrDisabled)) { - $names = array_map(function ($p) { return $p['name']; }, $notInstalledOrDisabled); - throw new PluginException(implode(', ', $names).'を有効化してください。'); + $names = array_map(function ($p) { + return $p['name']; + }, $notInstalledOrDisabled); + throw new PluginException(implode(', ', $names) . 'を有効化してください。'); } } @@ -323,15 +326,15 @@ public function generateProxyAndUpdateSchema(Plugin $plugin, $config, $uninstall public function generateProxyAndCallback(callable $callback, Plugin $plugin, $config, $uninstall = false, $tmpProxyOutputDir = null) { if ($plugin->isEnabled()) { - $generatedFiles = $this->regenerateProxy($plugin, false, $tmpProxyOutputDir ? $tmpProxyOutputDir : $this->projectRoot.'/app/proxy/entity'); + $generatedFiles = $this->regenerateProxy($plugin, false, $tmpProxyOutputDir ? $tmpProxyOutputDir : $this->projectRoot . '/app/proxy/entity'); - call_user_func($callback, $generatedFiles, $tmpProxyOutputDir ? $tmpProxyOutputDir : $this->projectRoot.'/app/proxy/entity'); + call_user_func($callback, $generatedFiles, $tmpProxyOutputDir ? $tmpProxyOutputDir : $this->projectRoot . '/app/proxy/entity'); } else { // Proxyのクラスをロードせずにスキーマを更新するために、 // インストール時には一時的なディレクトリにProxyを生成する $createOutputDir = false; if (is_null($tmpProxyOutputDir)) { - $tmpProxyOutputDir = sys_get_temp_dir().'/proxy_'.StringUtil::random(12); + $tmpProxyOutputDir = sys_get_temp_dir() . '/proxy_' . StringUtil::random(12); @mkdir($tmpProxyOutputDir); $createOutputDir = true; } @@ -339,12 +342,12 @@ public function generateProxyAndCallback(callable $callback, Plugin $plugin, $co try { if (!$uninstall) { // プラグインmetadata定義を追加 - $entityDir = $this->eccubeConfig['plugin_realdir'].'/'.$plugin->getCode().'/Entity'; + $entityDir = $this->eccubeConfig['plugin_realdir'] . '/' . $plugin->getCode() . '/Entity'; if (file_exists($entityDir)) { $ormConfig = $this->entityManager->getConfiguration(); $chain = $ormConfig->getMetadataDriverImpl()->getDriver(); $driver = $ormConfig->newDefaultAnnotationDriver([$entityDir], false); - $namespace = 'Plugin\\'.$config['code'].'\\Entity'; + $namespace = 'Plugin\\' . $config['code'] . '\\Entity'; $chain->addDriver($driver, $namespace); $ormConfig->addEntityNamespace($plugin->getCode(), $namespace); } @@ -368,9 +371,9 @@ public function generateProxyAndCallback(callable $callback, Plugin $plugin, $co public function createTempDir() { - $tempDir = $this->projectRoot.'/var/cache/'.$this->environment.'/Plugin'; + $tempDir = $this->projectRoot . '/var/cache/' . $this->environment . '/Plugin'; @mkdir($tempDir); - $d = ($tempDir.'/'.sha1(StringUtil::random(16))); + $d = ($tempDir . '/' . sha1(StringUtil::random(16))); if (!mkdir($d, 0777)) { throw new PluginException(trans('admin.store.plugin.mkdir.error', ['%dir_name%' => $d])); @@ -456,7 +459,7 @@ public function checkPluginArchiveContent($dir, array $config_cache = []) */ public function readConfig($pluginDir) { - $composerJsonPath = $pluginDir.DIRECTORY_SEPARATOR.'composer.json'; + $composerJsonPath = $pluginDir . DIRECTORY_SEPARATOR . 'composer.json'; if (file_exists($composerJsonPath) === false) { throw new PluginException("${composerJsonPath} not found."); } @@ -510,7 +513,7 @@ public function checkSamePlugin($code) public function calcPluginDir($code) { - return $this->projectRoot.'/app/Plugin/'.$code; + return $this->projectRoot . '/app/Plugin/' . $code; } /** @@ -562,7 +565,7 @@ public function registerPlugin($meta, $source = 0) */ public function callPluginManagerMethod($meta, $method) { - $class = '\\Plugin'.'\\'.$meta['code'].'\\'.'PluginManager'; + $class = '\\Plugin' . '\\' . $meta['code'] . '\\' . 'PluginManager'; if (class_exists($class)) { $installer = new $class(); // マネージャクラスに所定のメソッドがある場合だけ実行する if (method_exists($installer, $method)) { @@ -600,7 +603,7 @@ public function uninstall(Plugin $plugin, $force = true) $this->generateProxyAndUpdateSchema($plugin, $config, true); // プラグインのネームスペースに含まれるEntityのテーブルを削除する - $namespace = 'Plugin\\'.$plugin->getCode().'\\Entity'; + $namespace = 'Plugin\\' . $plugin->getCode() . '\\Entity'; $this->schemaService->dropTable($namespace); } catch (PersistenceMappingException $e) { } catch (ORMMappingException $e) { @@ -645,12 +648,14 @@ public function disable(Plugin $plugin) private function regenerateProxy(Plugin $plugin, $temporary, $outputDir = null, $uninstall = false) { if (is_null($outputDir)) { - $outputDir = $this->projectRoot.'/app/proxy/entity'; + $outputDir = $this->projectRoot . '/app/proxy/entity'; } @mkdir($outputDir); $enabledPluginCodes = array_map( - function ($p) { return $p->getCode(); }, + function ($p) { + return $p->getCode(); + }, $temporary ? $this->pluginRepository->findAll() : $this->pluginRepository->findAllEnabled() ); @@ -661,16 +666,16 @@ function ($p) { return $p->getCode(); }, $index = array_search($plugin->getCode(), $enabledPluginCodes); if ($index !== false && $index >= 0) { array_splice($enabledPluginCodes, $index, 1); - $excludes = [$this->projectRoot.'/app/Plugin/'.$plugin->getCode().'/Entity']; + $excludes = [$this->projectRoot . '/app/Plugin/' . $plugin->getCode() . '/Entity']; } } $enabledPluginEntityDirs = array_map(function ($code) { - return $this->projectRoot."/app/Plugin/${code}/Entity"; + return $this->projectRoot . "/app/Plugin/${code}/Entity"; }, $enabledPluginCodes); return $this->entityProxyService->generate( - array_merge([$this->projectRoot.'/app/Customize/Entity'], $enabledPluginEntityDirs), + array_merge([$this->projectRoot . '/app/Customize/Entity'], $enabledPluginEntityDirs), $excludes, $outputDir ); @@ -758,7 +763,7 @@ public function update(Plugin $plugin, $path) * Update plugin * * @param Plugin $plugin - * @param array $meta Config data + * @param array $meta Config data * * @throws \Exception */ @@ -779,9 +784,15 @@ public function updatePlugin(Plugin $plugin, $meta) } $this->copyAssets($plugin->getCode()); $em->flush(); - $em->getConnection()->commit(); + if ($em->getConnection()->getNativeConnection()->inTransaction()) { + $em->getConnection()->commit(); + } } catch (\Exception $e) { - $em->getConnection()->rollback(); + if ($em->getConnection()->getNativeConnection()->inTransaction()) { + if ($em->getConnection()->isRollbackOnly()) { + $em->getConnection()->rollback(); + } + } throw $e; } } @@ -803,7 +814,7 @@ public function getPluginRequired($plugin) $results = []; - $this->composerService->foreachRequires('ec-cube/'.strtolower($pluginCode), $pluginVersion, function ($package) use (&$results) { + $this->composerService->foreachRequires('ec-cube/' . strtolower($pluginCode), $pluginVersion, function ($package) use (&$results) { $results[] = $package; }, 'eccube-plugin'); @@ -827,7 +838,7 @@ public function findDependentPluginNeedDisable($pluginCode) * Check in both dtb_plugin table and /composer.json * * @param string $pluginCode - * @param bool $enableOnly + * @param bool $enableOnly * * @return array plugin code */ @@ -844,8 +855,8 @@ public function findDependentPlugin($pluginCode, $enableOnly = false) $plugins = $this->pluginRepository->matching($criteria); $dependents = []; foreach ($plugins as $plugin) { - $dir = $this->eccubeConfig['plugin_realdir'].'/'.$plugin->getCode(); - $fileName = $dir.'/composer.json'; + $dir = $this->eccubeConfig['plugin_realdir'] . '/' . $plugin->getCode(); + $fileName = $dir . '/composer.json'; if (!file_exists($fileName)) { continue; } @@ -855,8 +866,8 @@ public function findDependentPlugin($pluginCode, $enableOnly = false) if (!isset($json['require'])) { continue; } - if (array_key_exists(self::VENDOR_NAME.'/'.$pluginCode, $json['require']) // 前方互換用 - || array_key_exists(self::VENDOR_NAME.'/'.strtolower($pluginCode), $json['require'])) { + if (array_key_exists(self::VENDOR_NAME . '/' . $pluginCode, $json['require']) // 前方互換用 + || array_key_exists(self::VENDOR_NAME . '/' . strtolower($pluginCode), $json['require'])) { $dependents[] = $plugin->getCode(); } } @@ -870,7 +881,7 @@ public function findDependentPlugin($pluginCode, $enableOnly = false) * It's base on composer.json * Return the plugin code and version in the format of the composer * - * @param string $pluginCode + * @param string $pluginCode * @param int|null $libraryType * self::ECCUBE_LIBRARY only return library/plugin of eccube * self::OTHER_LIBRARY only return library/plugin of 3rd part ex: symfony, composer, ... @@ -881,7 +892,7 @@ public function findDependentPlugin($pluginCode, $enableOnly = false) public function getDependentByCode($pluginCode, $libraryType = null) { $pluginDir = $this->calcPluginDir($pluginCode); - $jsonFile = $pluginDir.'/composer.json'; + $jsonFile = $pluginDir . '/composer.json'; if (!file_exists($jsonFile)) { return []; } @@ -892,11 +903,11 @@ public function getDependentByCode($pluginCode, $libraryType = null) $require = $json['require']; switch ($libraryType) { case self::ECCUBE_LIBRARY: - $dependents = array_intersect_key($require, array_flip(preg_grep('/^'.self::VENDOR_NAME.'\//i', array_keys($require)))); + $dependents = array_intersect_key($require, array_flip(preg_grep('/^' . self::VENDOR_NAME . '\//i', array_keys($require)))); break; case self::OTHER_LIBRARY: - $dependents = array_intersect_key($require, array_flip(preg_grep('/^'.self::VENDOR_NAME.'\//i', array_keys($require), PREG_GREP_INVERT))); + $dependents = array_intersect_key($require, array_flip(preg_grep('/^' . self::VENDOR_NAME . '\//i', array_keys($require), PREG_GREP_INVERT))); break; default: @@ -912,8 +923,8 @@ public function getDependentByCode($pluginCode, $libraryType = null) * Format array dependent plugin to string * It is used for commands. * - * @param array $packages format [packageName1 => version1, packageName2 => version2] - * @param bool $getVersion + * @param array $packages format [packageName1 => version1, packageName2 => version2] + * @param bool $getVersion * * @return string format if version=true: "packageName1:version1 packageName2:version2", if version=false: "packageName1 packageName2" */ @@ -922,7 +933,7 @@ public function parseToComposerCommand(array $packages, $getVersion = true) $result = array_keys($packages); if ($getVersion) { $result = array_map(function ($package, $version) { - return $package.':'.$version; + return $package . ':' . $version; }, array_keys($packages), array_values($packages)); } @@ -939,12 +950,12 @@ public function parseToComposerCommand(array $packages, $getVersion = true) */ public function copyAssets($pluginCode) { - $assetsDir = $this->calcPluginDir($pluginCode).'/Resource/assets'; + $assetsDir = $this->calcPluginDir($pluginCode) . '/Resource/assets'; // プラグインにリソースファイルがあれば所定の位置へコピー if (file_exists($assetsDir)) { $file = new Filesystem(); - $file->mirror($assetsDir, $this->eccubeConfig['plugin_html_realdir'].$pluginCode.'/assets'); + $file->mirror($assetsDir, $this->eccubeConfig['plugin_html_realdir'] . $pluginCode . '/assets'); } } @@ -955,7 +966,7 @@ public function copyAssets($pluginCode) */ public function removeAssets($pluginCode) { - $assetsDir = $this->eccubeConfig['plugin_html_realdir'].$pluginCode; + $assetsDir = $this->eccubeConfig['plugin_html_realdir'] . $pluginCode; // コピーされているリソースファイルがあれば削除 if (file_exists($assetsDir)) { @@ -967,15 +978,15 @@ public function removeAssets($pluginCode) /** * Plugin is exist check * - * @param array $plugins get from api + * @param array $plugins get from api * @param string $pluginCode * * @return false|int|string */ public function checkPluginExist($plugins, $pluginCode) { - if (strpos($pluginCode, self::VENDOR_NAME.'/') !== false) { - $pluginCode = str_replace(self::VENDOR_NAME.'/', '', $pluginCode); + if (strpos($pluginCode, self::VENDOR_NAME . '/') !== false) { + $pluginCode = str_replace(self::VENDOR_NAME . '/', '', $pluginCode); } // Find plugin in array $index = array_search($pluginCode, array_column($plugins, 'product_code')); // 前方互換用 From 87a6b0031cdb8e906f4e26e80b091961d07de63a Mon Sep 17 00:00:00 2001 From: kurozumi Date: Thu, 14 Jul 2022 12:30:25 +0900 Subject: [PATCH 2/8] =?UTF-8?q?=E4=BD=99=E8=A8=88=E3=81=AA=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=E3=82=92=E6=88=BB=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Eccube/Service/PluginService.php | 107 +++++++++++++-------------- 1 file changed, 51 insertions(+), 56 deletions(-) diff --git a/src/Eccube/Service/PluginService.php b/src/Eccube/Service/PluginService.php index c8298dd1481..fe3757a4344 100644 --- a/src/Eccube/Service/PluginService.php +++ b/src/Eccube/Service/PluginService.php @@ -123,19 +123,18 @@ class PluginService * @param PluginContext $pluginContext */ public function __construct( - EntityManagerInterface $entityManager, - PluginRepository $pluginRepository, - EntityProxyService $entityProxyService, - SchemaService $schemaService, - EccubeConfig $eccubeConfig, - ContainerInterface $container, - CacheUtil $cacheUtil, + EntityManagerInterface $entityManager, + PluginRepository $pluginRepository, + EntityProxyService $entityProxyService, + SchemaService $schemaService, + EccubeConfig $eccubeConfig, + ContainerInterface $container, + CacheUtil $cacheUtil, ComposerServiceInterface $composerService, - PluginApiService $pluginApiService, - SystemService $systemService, - PluginContext $pluginContext - ) - { + PluginApiService $pluginApiService, + SystemService $systemService, + PluginContext $pluginContext + ) { $this->entityManager = $entityManager; $this->pluginRepository = $pluginRepository; $this->entityProxyService = $entityProxyService; @@ -154,8 +153,8 @@ public function __construct( /** * ファイル指定してのプラグインインストール * - * @param string $path path to tar.gz/zip plugin file - * @param int $source + * @param string $path path to tar.gz/zip plugin file + * @param int $source * * @return boolean * @@ -231,10 +230,8 @@ public function installWithCode($code) }); if (!empty($notInstalledOrDisabled)) { - $names = array_map(function ($p) { - return $p['name']; - }, $notInstalledOrDisabled); - throw new PluginException(implode(', ', $names) . 'を有効化してください。'); + $names = array_map(function ($p) { return $p['name']; }, $notInstalledOrDisabled); + throw new PluginException(implode(', ', $names).'を有効化してください。'); } } @@ -326,15 +323,15 @@ public function generateProxyAndUpdateSchema(Plugin $plugin, $config, $uninstall public function generateProxyAndCallback(callable $callback, Plugin $plugin, $config, $uninstall = false, $tmpProxyOutputDir = null) { if ($plugin->isEnabled()) { - $generatedFiles = $this->regenerateProxy($plugin, false, $tmpProxyOutputDir ? $tmpProxyOutputDir : $this->projectRoot . '/app/proxy/entity'); + $generatedFiles = $this->regenerateProxy($plugin, false, $tmpProxyOutputDir ? $tmpProxyOutputDir : $this->projectRoot.'/app/proxy/entity'); - call_user_func($callback, $generatedFiles, $tmpProxyOutputDir ? $tmpProxyOutputDir : $this->projectRoot . '/app/proxy/entity'); + call_user_func($callback, $generatedFiles, $tmpProxyOutputDir ? $tmpProxyOutputDir : $this->projectRoot.'/app/proxy/entity'); } else { // Proxyのクラスをロードせずにスキーマを更新するために、 // インストール時には一時的なディレクトリにProxyを生成する $createOutputDir = false; if (is_null($tmpProxyOutputDir)) { - $tmpProxyOutputDir = sys_get_temp_dir() . '/proxy_' . StringUtil::random(12); + $tmpProxyOutputDir = sys_get_temp_dir().'/proxy_'.StringUtil::random(12); @mkdir($tmpProxyOutputDir); $createOutputDir = true; } @@ -342,12 +339,12 @@ public function generateProxyAndCallback(callable $callback, Plugin $plugin, $co try { if (!$uninstall) { // プラグインmetadata定義を追加 - $entityDir = $this->eccubeConfig['plugin_realdir'] . '/' . $plugin->getCode() . '/Entity'; + $entityDir = $this->eccubeConfig['plugin_realdir'].'/'.$plugin->getCode().'/Entity'; if (file_exists($entityDir)) { $ormConfig = $this->entityManager->getConfiguration(); $chain = $ormConfig->getMetadataDriverImpl()->getDriver(); $driver = $ormConfig->newDefaultAnnotationDriver([$entityDir], false); - $namespace = 'Plugin\\' . $config['code'] . '\\Entity'; + $namespace = 'Plugin\\'.$config['code'].'\\Entity'; $chain->addDriver($driver, $namespace); $ormConfig->addEntityNamespace($plugin->getCode(), $namespace); } @@ -371,9 +368,9 @@ public function generateProxyAndCallback(callable $callback, Plugin $plugin, $co public function createTempDir() { - $tempDir = $this->projectRoot . '/var/cache/' . $this->environment . '/Plugin'; + $tempDir = $this->projectRoot.'/var/cache/'.$this->environment.'/Plugin'; @mkdir($tempDir); - $d = ($tempDir . '/' . sha1(StringUtil::random(16))); + $d = ($tempDir.'/'.sha1(StringUtil::random(16))); if (!mkdir($d, 0777)) { throw new PluginException(trans('admin.store.plugin.mkdir.error', ['%dir_name%' => $d])); @@ -459,7 +456,7 @@ public function checkPluginArchiveContent($dir, array $config_cache = []) */ public function readConfig($pluginDir) { - $composerJsonPath = $pluginDir . DIRECTORY_SEPARATOR . 'composer.json'; + $composerJsonPath = $pluginDir.DIRECTORY_SEPARATOR.'composer.json'; if (file_exists($composerJsonPath) === false) { throw new PluginException("${composerJsonPath} not found."); } @@ -513,7 +510,7 @@ public function checkSamePlugin($code) public function calcPluginDir($code) { - return $this->projectRoot . '/app/Plugin/' . $code; + return $this->projectRoot.'/app/Plugin/'.$code; } /** @@ -565,7 +562,7 @@ public function registerPlugin($meta, $source = 0) */ public function callPluginManagerMethod($meta, $method) { - $class = '\\Plugin' . '\\' . $meta['code'] . '\\' . 'PluginManager'; + $class = '\\Plugin'.'\\'.$meta['code'].'\\'.'PluginManager'; if (class_exists($class)) { $installer = new $class(); // マネージャクラスに所定のメソッドがある場合だけ実行する if (method_exists($installer, $method)) { @@ -603,7 +600,7 @@ public function uninstall(Plugin $plugin, $force = true) $this->generateProxyAndUpdateSchema($plugin, $config, true); // プラグインのネームスペースに含まれるEntityのテーブルを削除する - $namespace = 'Plugin\\' . $plugin->getCode() . '\\Entity'; + $namespace = 'Plugin\\'.$plugin->getCode().'\\Entity'; $this->schemaService->dropTable($namespace); } catch (PersistenceMappingException $e) { } catch (ORMMappingException $e) { @@ -648,14 +645,12 @@ public function disable(Plugin $plugin) private function regenerateProxy(Plugin $plugin, $temporary, $outputDir = null, $uninstall = false) { if (is_null($outputDir)) { - $outputDir = $this->projectRoot . '/app/proxy/entity'; + $outputDir = $this->projectRoot.'/app/proxy/entity'; } @mkdir($outputDir); $enabledPluginCodes = array_map( - function ($p) { - return $p->getCode(); - }, + function ($p) { return $p->getCode(); }, $temporary ? $this->pluginRepository->findAll() : $this->pluginRepository->findAllEnabled() ); @@ -666,16 +661,16 @@ function ($p) { $index = array_search($plugin->getCode(), $enabledPluginCodes); if ($index !== false && $index >= 0) { array_splice($enabledPluginCodes, $index, 1); - $excludes = [$this->projectRoot . '/app/Plugin/' . $plugin->getCode() . '/Entity']; + $excludes = [$this->projectRoot.'/app/Plugin/'.$plugin->getCode().'/Entity']; } } $enabledPluginEntityDirs = array_map(function ($code) { - return $this->projectRoot . "/app/Plugin/${code}/Entity"; + return $this->projectRoot."/app/Plugin/${code}/Entity"; }, $enabledPluginCodes); return $this->entityProxyService->generate( - array_merge([$this->projectRoot . '/app/Customize/Entity'], $enabledPluginEntityDirs), + array_merge([$this->projectRoot.'/app/Customize/Entity'], $enabledPluginEntityDirs), $excludes, $outputDir ); @@ -763,7 +758,7 @@ public function update(Plugin $plugin, $path) * Update plugin * * @param Plugin $plugin - * @param array $meta Config data + * @param array $meta Config data * * @throws \Exception */ @@ -814,7 +809,7 @@ public function getPluginRequired($plugin) $results = []; - $this->composerService->foreachRequires('ec-cube/' . strtolower($pluginCode), $pluginVersion, function ($package) use (&$results) { + $this->composerService->foreachRequires('ec-cube/'.strtolower($pluginCode), $pluginVersion, function ($package) use (&$results) { $results[] = $package; }, 'eccube-plugin'); @@ -838,7 +833,7 @@ public function findDependentPluginNeedDisable($pluginCode) * Check in both dtb_plugin table and /composer.json * * @param string $pluginCode - * @param bool $enableOnly + * @param bool $enableOnly * * @return array plugin code */ @@ -855,8 +850,8 @@ public function findDependentPlugin($pluginCode, $enableOnly = false) $plugins = $this->pluginRepository->matching($criteria); $dependents = []; foreach ($plugins as $plugin) { - $dir = $this->eccubeConfig['plugin_realdir'] . '/' . $plugin->getCode(); - $fileName = $dir . '/composer.json'; + $dir = $this->eccubeConfig['plugin_realdir'].'/'.$plugin->getCode(); + $fileName = $dir.'/composer.json'; if (!file_exists($fileName)) { continue; } @@ -866,8 +861,8 @@ public function findDependentPlugin($pluginCode, $enableOnly = false) if (!isset($json['require'])) { continue; } - if (array_key_exists(self::VENDOR_NAME . '/' . $pluginCode, $json['require']) // 前方互換用 - || array_key_exists(self::VENDOR_NAME . '/' . strtolower($pluginCode), $json['require'])) { + if (array_key_exists(self::VENDOR_NAME.'/'.$pluginCode, $json['require']) // 前方互換用 + || array_key_exists(self::VENDOR_NAME.'/'.strtolower($pluginCode), $json['require'])) { $dependents[] = $plugin->getCode(); } } @@ -881,7 +876,7 @@ public function findDependentPlugin($pluginCode, $enableOnly = false) * It's base on composer.json * Return the plugin code and version in the format of the composer * - * @param string $pluginCode + * @param string $pluginCode * @param int|null $libraryType * self::ECCUBE_LIBRARY only return library/plugin of eccube * self::OTHER_LIBRARY only return library/plugin of 3rd part ex: symfony, composer, ... @@ -892,7 +887,7 @@ public function findDependentPlugin($pluginCode, $enableOnly = false) public function getDependentByCode($pluginCode, $libraryType = null) { $pluginDir = $this->calcPluginDir($pluginCode); - $jsonFile = $pluginDir . '/composer.json'; + $jsonFile = $pluginDir.'/composer.json'; if (!file_exists($jsonFile)) { return []; } @@ -903,11 +898,11 @@ public function getDependentByCode($pluginCode, $libraryType = null) $require = $json['require']; switch ($libraryType) { case self::ECCUBE_LIBRARY: - $dependents = array_intersect_key($require, array_flip(preg_grep('/^' . self::VENDOR_NAME . '\//i', array_keys($require)))); + $dependents = array_intersect_key($require, array_flip(preg_grep('/^'.self::VENDOR_NAME.'\//i', array_keys($require)))); break; case self::OTHER_LIBRARY: - $dependents = array_intersect_key($require, array_flip(preg_grep('/^' . self::VENDOR_NAME . '\//i', array_keys($require), PREG_GREP_INVERT))); + $dependents = array_intersect_key($require, array_flip(preg_grep('/^'.self::VENDOR_NAME.'\//i', array_keys($require), PREG_GREP_INVERT))); break; default: @@ -923,8 +918,8 @@ public function getDependentByCode($pluginCode, $libraryType = null) * Format array dependent plugin to string * It is used for commands. * - * @param array $packages format [packageName1 => version1, packageName2 => version2] - * @param bool $getVersion + * @param array $packages format [packageName1 => version1, packageName2 => version2] + * @param bool $getVersion * * @return string format if version=true: "packageName1:version1 packageName2:version2", if version=false: "packageName1 packageName2" */ @@ -933,7 +928,7 @@ public function parseToComposerCommand(array $packages, $getVersion = true) $result = array_keys($packages); if ($getVersion) { $result = array_map(function ($package, $version) { - return $package . ':' . $version; + return $package.':'.$version; }, array_keys($packages), array_values($packages)); } @@ -950,12 +945,12 @@ public function parseToComposerCommand(array $packages, $getVersion = true) */ public function copyAssets($pluginCode) { - $assetsDir = $this->calcPluginDir($pluginCode) . '/Resource/assets'; + $assetsDir = $this->calcPluginDir($pluginCode).'/Resource/assets'; // プラグインにリソースファイルがあれば所定の位置へコピー if (file_exists($assetsDir)) { $file = new Filesystem(); - $file->mirror($assetsDir, $this->eccubeConfig['plugin_html_realdir'] . $pluginCode . '/assets'); + $file->mirror($assetsDir, $this->eccubeConfig['plugin_html_realdir'].$pluginCode.'/assets'); } } @@ -966,7 +961,7 @@ public function copyAssets($pluginCode) */ public function removeAssets($pluginCode) { - $assetsDir = $this->eccubeConfig['plugin_html_realdir'] . $pluginCode; + $assetsDir = $this->eccubeConfig['plugin_html_realdir'].$pluginCode; // コピーされているリソースファイルがあれば削除 if (file_exists($assetsDir)) { @@ -978,15 +973,15 @@ public function removeAssets($pluginCode) /** * Plugin is exist check * - * @param array $plugins get from api + * @param array $plugins get from api * @param string $pluginCode * * @return false|int|string */ public function checkPluginExist($plugins, $pluginCode) { - if (strpos($pluginCode, self::VENDOR_NAME . '/') !== false) { - $pluginCode = str_replace(self::VENDOR_NAME . '/', '', $pluginCode); + if (strpos($pluginCode, self::VENDOR_NAME.'/') !== false) { + $pluginCode = str_replace(self::VENDOR_NAME.'/', '', $pluginCode); } // Find plugin in array $index = array_search($pluginCode, array_column($plugins, 'product_code')); // 前方互換用 From 28fe17522fbbeb858aa0d60c3c3e0d2ef82ee028 Mon Sep 17 00:00:00 2001 From: kurozumi Date: Thu, 14 Jul 2022 12:33:41 +0900 Subject: [PATCH 3/8] =?UTF-8?q?=E3=83=97=E3=83=A9=E3=82=B0=E3=82=A4?= =?UTF-8?q?=E3=83=B3=E3=83=86=E3=82=B9=E3=83=88=E3=81=AE=E3=83=AF=E3=83=BC?= =?UTF-8?q?=E3=82=AF=E3=83=95=E3=83=AD=E3=83=BC=E3=81=ABPHP8.0=E3=81=A88.1?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/plugin-test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/plugin-test.yml b/.github/workflows/plugin-test.yml index 72543d23d88..e31a29c0e3d 100644 --- a/.github/workflows/plugin-test.yml +++ b/.github/workflows/plugin-test.yml @@ -20,7 +20,7 @@ jobs: fail-fast: false matrix: operating-system: [ ubuntu-18.04 ] - php: [ 7.4 ] + php: [ '7.4', '8.0', '8.1' ] db: [ pgsql, mysql ] method: - test_install_enable_disable_remove_store @@ -164,7 +164,7 @@ jobs: fail-fast: false matrix: operating-system: [ ubuntu-18.04 ] - php: [ 7.4 ] + php: [ '7.4', '8.0', '8.1' ] db: [ pgsql, mysql ] method: - test_install_update_remove_store @@ -306,7 +306,7 @@ jobs: fail-fast: false matrix: operating-system: [ ubuntu-18.04 ] - php: [ 7.4 ] + php: [ '7.4', '8.0', '8.1' ] db: [ pgsql, mysql ] method: - test_extend_same_table_store @@ -448,7 +448,7 @@ jobs: fail-fast: false matrix: operating-system: [ ubuntu-18.04 ] - php: [ 7.4 ] + php: [ '7.4', '8.0', '8.1' ] db: [ pgsql, mysql ] method: - test_dependency_each_install_plugin From 8a6f665612c3b8c78d96184fc428b01209e5eec1 Mon Sep 17 00:00:00 2001 From: kurozumi Date: Tue, 19 Jul 2022 13:50:52 +0900 Subject: [PATCH 4/8] =?UTF-8?q?plugin-test.yml=E3=81=ABDATABASE=5FCHARSET?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/plugin-test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/plugin-test.yml b/.github/workflows/plugin-test.yml index e31a29c0e3d..a560761b990 100644 --- a/.github/workflows/plugin-test.yml +++ b/.github/workflows/plugin-test.yml @@ -461,9 +461,11 @@ jobs: - db: pgsql database_url: postgres://postgres:password@127.0.0.1:5432/eccube_db database_server_version: 14 + database_charset: utf8 - db: mysql database_url: mysql://root:password@127.0.0.1:3306/eccube_db database_server_version: 5 + database_charset: utf8mb4 exclude: - db: mysql method: test_dependency_plugin_update @@ -519,6 +521,7 @@ jobs: APP_ENV: 'codeception' DATABASE_URL: ${{ matrix.database_url }} DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }} + DATABASE_CHARSET: ${{ matrix.database_charset }} run: | echo "APP_ENV=${APP_ENV}" > .env bin/console doctrine:database:create --env=dev @@ -553,6 +556,7 @@ jobs: APP_ENV: 'codeception' DATABASE_URL: ${{ matrix.database_url }} DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }} + DATABASE_CHARSET: ${{ matrix.database_charset }} MAILER_URL: 'smtp://127.0.0.1:1025' ECCUBE_PACKAGE_API_URL: 'http://127.0.0.1:8080' run: php -S 127.0.0.1:8000 codeception/router.php & @@ -568,6 +572,7 @@ jobs: APP_ENV: ${{ matrix.app_env }} DATABASE_URL: ${{ matrix.database_url }} DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }} + DATABASE_CHARSET: ${{ matrix.database_charset }} MAILER_URL: 'smtp://127.0.0.1:1025' METHOD: ${{ matrix.method }} ECCUBE_PACKAGE_API_URL: 'http://127.0.0.1:8080' From d40d05d07e35a302b20b9666154597cb4829c3fb Mon Sep 17 00:00:00 2001 From: kurozumi Date: Tue, 19 Jul 2022 15:13:53 +0900 Subject: [PATCH 5/8] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=BC=8F=E3=82=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/plugin-test.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/plugin-test.yml b/.github/workflows/plugin-test.yml index a560761b990..af096c21ee0 100644 --- a/.github/workflows/plugin-test.yml +++ b/.github/workflows/plugin-test.yml @@ -35,9 +35,11 @@ jobs: - db: pgsql database_url: postgres://postgres:password@127.0.0.1:5432/eccube_db database_server_version: 14 + database_charset: utf8 - db: mysql database_url: mysql://root:password@127.0.0.1:3306/eccube_db database_server_version: 5 + database_charset: utf8mb4 services: mysql: @@ -90,6 +92,7 @@ jobs: APP_ENV: 'codeception' DATABASE_URL: ${{ matrix.database_url }} DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }} + DATABASE_CHARSET: ${{ matrix.database_charset }} run: | echo "APP_ENV=${APP_ENV}" > .env bin/console doctrine:database:create --env=dev @@ -124,6 +127,7 @@ jobs: APP_ENV: 'codeception' DATABASE_URL: ${{ matrix.database_url }} DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }} + DATABASE_CHARSET: ${{ matrix.database_charset }} MAILER_URL: 'smtp://127.0.0.1:1025' ECCUBE_PACKAGE_API_URL: 'http://127.0.0.1:8080' run: php -S 127.0.0.1:8000 codeception/router.php & @@ -139,6 +143,7 @@ jobs: APP_ENV: ${{ matrix.app_env }} DATABASE_URL: ${{ matrix.database_url }} DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }} + DATABASE_CHARSET: ${{ matrix.database_charset }} MAILER_URL: 'smtp://127.0.0.1:1025' METHOD: ${{ matrix.method }} ECCUBE_PACKAGE_API_URL: 'http://127.0.0.1:8080' @@ -177,9 +182,11 @@ jobs: - db: pgsql database_url: postgres://postgres:password@127.0.0.1:5432/eccube_db database_server_version: 14 + database_charset: utf8 - db: mysql database_url: mysql://root:password@127.0.0.1:3306/eccube_db database_server_version: 5 + database_charset: utf8mb4 services: mysql: @@ -232,6 +239,7 @@ jobs: APP_ENV: 'codeception' DATABASE_URL: ${{ matrix.database_url }} DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }} + DATABASE_CHARSET: ${{ matrix.database_charset }} run: | echo "APP_ENV=${APP_ENV}" > .env bin/console doctrine:database:create --env=dev @@ -266,6 +274,7 @@ jobs: APP_ENV: 'codeception' DATABASE_URL: ${{ matrix.database_url }} DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }} + DATABASE_CHARSET: ${{ matrix.database_charset }} MAILER_URL: 'smtp://127.0.0.1:1025' ECCUBE_PACKAGE_API_URL: 'http://127.0.0.1:8080' run: php -S 127.0.0.1:8000 codeception/router.php & @@ -281,6 +290,7 @@ jobs: APP_ENV: ${{ matrix.app_env }} DATABASE_URL: ${{ matrix.database_url }} DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }} + DATABASE_CHARSET: ${{ matrix.database_charset }} MAILER_URL: 'smtp://127.0.0.1:1025' METHOD: ${{ matrix.method }} ECCUBE_PACKAGE_API_URL: 'http://127.0.0.1:8080' @@ -319,9 +329,11 @@ jobs: - db: pgsql database_url: postgres://postgres:password@127.0.0.1:5432/eccube_db database_server_version: 14 + database_charset: utf8 - db: mysql database_url: mysql://root:password@127.0.0.1:3306/eccube_db database_server_version: 5 + database_charset: utf8mb4 services: mysql: @@ -374,6 +386,7 @@ jobs: APP_ENV: 'codeception' DATABASE_URL: ${{ matrix.database_url }} DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }} + DATABASE_CHARSET: ${{ matrix.database_charset }} run: | echo "APP_ENV=${APP_ENV}" > .env bin/console doctrine:database:create --env=dev @@ -408,6 +421,7 @@ jobs: APP_ENV: 'codeception' DATABASE_URL: ${{ matrix.database_url }} DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }} + DATABASE_CHARSET: ${{ matrix.database_charset }} MAILER_URL: 'smtp://127.0.0.1:1025' ECCUBE_PACKAGE_API_URL: 'http://127.0.0.1:8080' run: php -S 127.0.0.1:8000 codeception/router.php & @@ -423,6 +437,7 @@ jobs: APP_ENV: ${{ matrix.app_env }} DATABASE_URL: ${{ matrix.database_url }} DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }} + DATABASE_CHARSET: ${{ matrix.database_charset }} MAILER_URL: 'smtp://127.0.0.1:1025' METHOD: ${{ matrix.method }} ECCUBE_PACKAGE_API_URL: 'http://127.0.0.1:8080' From 11db57d34a75e33a739296d29236324446f5a47d Mon Sep 17 00:00:00 2001 From: kurozumi Date: Wed, 20 Jul 2022 10:16:47 +0900 Subject: [PATCH 6/8] =?UTF-8?q?codeception=E3=81=AEwait=E3=82=9260?= =?UTF-8?q?=E7=97=85=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- codeception/_support/Page/Admin/PluginManagePage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codeception/_support/Page/Admin/PluginManagePage.php b/codeception/_support/Page/Admin/PluginManagePage.php index 76affc2d4c4..6c4ad4794fb 100644 --- a/codeception/_support/Page/Admin/PluginManagePage.php +++ b/codeception/_support/Page/Admin/PluginManagePage.php @@ -70,7 +70,7 @@ public function ストアプラグイン_削除($pluginCode, $message = '削除 $this->ストアプラグイン_ボタンクリック($pluginCode, '削除'); $this->tester->waitForElementVisible(['id' => 'officialPluginDeleteButton'], 60); $this->tester->click(['id' => 'officialPluginDeleteButton']); - $this->tester->waitForElementVisible(['css' => '#officialPluginDeleteModal > div > div > div.modal-footer > button:nth-child(3)'], 30); + $this->tester->waitForElementVisible(['css' => '#officialPluginDeleteModal > div > div > div.modal-footer > button:nth-child(3)'], 60); $this->tester->see($message, ['css' => '#officialPluginDeleteModal > div > div > div.modal-body.text-left > p']); $this->tester->click(['css' => '#officialPluginDeleteModal > div > div > div.modal-footer > button:nth-child(3)']); From dbb5442db0c2a61ddc0e534b2ee1b326b0e2db3e Mon Sep 17 00:00:00 2001 From: kurozumi Date: Thu, 21 Jul 2022 21:37:22 +0900 Subject: [PATCH 7/8] =?UTF-8?q?TransactionListener=E3=81=AE=E3=83=AD?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E3=83=90=E3=83=83=E3=82=AF=E5=87=A6=E7=90=86?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Eccube/EventListener/TransactionListener.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Eccube/EventListener/TransactionListener.php b/src/Eccube/EventListener/TransactionListener.php index 4e0b4dcac6c..d75b4ac9a5c 100644 --- a/src/Eccube/EventListener/TransactionListener.php +++ b/src/Eccube/EventListener/TransactionListener.php @@ -103,8 +103,10 @@ public function onKernelException(ExceptionEvent $event) return; } - if ($this->em->getConnection()->isTransactionActive()) { - $this->em->rollback(); + if ($this->em->getConnection()->getNativeConnection()->inTransaction()) { + if ($this->em->getConnection()->isRollbackOnly()) { + $this->em->rollback(); + } log_debug('Rollback executed.'); } else { log_debug('Transaction is not active. Rollback skipped.'); @@ -123,7 +125,7 @@ public function onKernelTerminate(TerminateEvent $event) return; } - if ($this->em->getConnection()->isTransactionActive()) { + if ($this->em->getConnection()->getNativeConnection()->inTransaction()) { if ($this->em->getConnection()->isRollbackOnly()) { $this->em->rollback(); log_debug('Rollback executed.'); From 917d164ed8891500dfc835c3ad3e33b83221f1a5 Mon Sep 17 00:00:00 2001 From: kurozumi Date: Thu, 21 Jul 2022 21:40:40 +0900 Subject: [PATCH 8/8] =?UTF-8?q?=E3=82=B3=E3=83=B3=E3=83=95=E3=83=AA?= =?UTF-8?q?=E3=82=AF=E3=83=88=E8=A7=A3=E6=B6=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- codeception/_support/Page/Admin/PluginManagePage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codeception/_support/Page/Admin/PluginManagePage.php b/codeception/_support/Page/Admin/PluginManagePage.php index 6c4ad4794fb..76affc2d4c4 100644 --- a/codeception/_support/Page/Admin/PluginManagePage.php +++ b/codeception/_support/Page/Admin/PluginManagePage.php @@ -70,7 +70,7 @@ public function ストアプラグイン_削除($pluginCode, $message = '削除 $this->ストアプラグイン_ボタンクリック($pluginCode, '削除'); $this->tester->waitForElementVisible(['id' => 'officialPluginDeleteButton'], 60); $this->tester->click(['id' => 'officialPluginDeleteButton']); - $this->tester->waitForElementVisible(['css' => '#officialPluginDeleteModal > div > div > div.modal-footer > button:nth-child(3)'], 60); + $this->tester->waitForElementVisible(['css' => '#officialPluginDeleteModal > div > div > div.modal-footer > button:nth-child(3)'], 30); $this->tester->see($message, ['css' => '#officialPluginDeleteModal > div > div > div.modal-body.text-left > p']); $this->tester->click(['css' => '#officialPluginDeleteModal > div > div > div.modal-footer > button:nth-child(3)']);