From 3c6a14b55f2628765ac9f17e104b7c136e1e981c Mon Sep 17 00:00:00 2001 From: matks Date: Mon, 6 Jan 2020 17:47:52 +0100 Subject: [PATCH] Release 3.4.1 - removal of vendor/phpunit in upgrade steps --- .gitignore | 1 + config.xml | 2 +- ps_facetedsearch.php | 2 +- upgrade/upgrade-3.4.1.php | 69 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 upgrade/upgrade-3.4.1.php diff --git a/.gitignore b/.gitignore index 149214cfa..b7f78a225 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ tests/php/coverage config_*.xml .php_cs.cache +.idea diff --git a/config.xml b/config.xml index 5e3d1a2b2..b14684f1b 100644 --- a/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ ps_facetedsearch - + diff --git a/ps_facetedsearch.php b/ps_facetedsearch.php index 8723ef404..fa10b5d02 100644 --- a/ps_facetedsearch.php +++ b/ps_facetedsearch.php @@ -97,7 +97,7 @@ public function __construct() { $this->name = 'ps_facetedsearch'; $this->tab = 'front_office_features'; - $this->version = '3.4.0'; + $this->version = '3.4.1'; $this->author = 'PrestaShop'; $this->need_instance = 0; $this->bootstrap = true; diff --git a/upgrade/upgrade-3.4.1.php b/upgrade/upgrade-3.4.1.php new file mode 100644 index 000000000..d2e24e0a1 --- /dev/null +++ b/upgrade/upgrade-3.4.1.php @@ -0,0 +1,69 @@ + + * @copyright 2007-2020 PrestaShop SA + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) + * International Registered Trademark & Property of PrestaShop SA + */ +if (!defined('_PS_VERSION_')) { + exit; +} + +/** + * Removes files or directories. + * + * @param array $files An array of files to remove + * + * @return true|string True if everything goes fine, error details otherwise + */ +function removeFromFsDuringUpgrade(array $files) +{ + $files = array_reverse($files); + foreach ($files as $file) { + if (is_dir($file)) { + $iterator = new FilesystemIterator($file, FilesystemIterator::CURRENT_AS_PATHNAME | FilesystemIterator::SKIP_DOTS); + removeFromFsDuringUpgrade(iterator_to_array($iterator)); + if (!rmdir($file) && file_exists($file)) { + return 'Deletion of directory ' . $file . 'failed'; + } + } elseif (!unlink($file) && file_exists($file)) { + return 'Deletion of file ' . $file . 'failed'; + } + } + return true; +} +/** + * This upgrade file removes the folder vendor/phpunit, when added from a previous release installed on the shop. + * + * @return true|array + */ +function upgrade_module_3_4_1($module) +{ + $path = __DIR__ . '/../vendor/phpunit'; + if (file_exists($path)) { + $result = removeFromFsDuringUpgrade(array($path)); + if ($result !== true) { + PrestaShopLogger::addLog('Could not delete PHPUnit from module. ' . $result, 3); + return false; + } + } + return true; +}