Skip to content

Commit

Permalink
refs #47377 error class not found during first upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan202 committed Aug 16, 2024
1 parent a623694 commit 0e16481
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
2 changes: 1 addition & 1 deletion paypal.php
Original file line number Diff line number Diff line change
Expand Up @@ -3115,7 +3115,7 @@ public function getRedundantFiles()
return array_filter(
$response['created'],
function ($file) {
return !preg_match('/^config_[a-z]+\.xml$/', $file);
return !preg_match('/^config_[a-z]+\.xml$/', $file) && $file !== 'config.xml';
});
}
}
34 changes: 27 additions & 7 deletions upgrade/Upgrade-6.4.3.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,45 @@
*
*/

use PaypalPPBTlib\Extensions\Diagnostic\Stubs\Concrete\FileIntegrityStub;

if (!defined('_PS_VERSION_')) {
exit;
}

include _PS_MODULE_DIR_ . 'paypal/vendor/autoload.php';

/**
* @param $module PayPal
*
* @return bool
*/
function upgrade_module_6_4_3(PayPal $module)
{
if (class_exists('\PaypalAddons\services\ToolKit')) {
$kit = new \PaypalAddons\services\ToolKit();
$baseDir = _PS_MODULE_DIR_ . 'paypal/';
$baseDir = _PS_MODULE_DIR_ . 'paypal/';
$diagnosticConf = include _PS_MODULE_DIR_ . 'paypal/diagnostic.php';

if (empty($diagnosticConf[0]['stubs'][FileIntegrityStub::class])) {
throw new Exception('File integrity stubs not found');
}

$stub = new FileIntegrityStub($diagnosticConf[0]['stubs'][FileIntegrityStub::class]);
$stub->setModule($module);
$response = $stub->getHandler()->handle();

if (empty($response['created'])) {
throw new Exception('Redundant files are not found');
}

$files = array_filter(
$response['created'],
function ($file) {
return !preg_match('/^config_[a-z]+\.xml$/', $file) && $file !== 'config.xml';
});

foreach ($module->getRedundantFiles() as $file) {
$kit->unlink($baseDir . $file);
foreach ($files as $file) {
try {
unlink($baseDir . $file);
} catch (Exception $e) {
} catch (Throwable $e) {
}
}

Expand Down

0 comments on commit 0e16481

Please sign in to comment.