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

Bugfix/47512 warning #358

Merged
merged 2 commits into from
Aug 2, 2024
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
2 changes: 1 addition & 1 deletion classes/API/HttpJsonResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function getHeaders()
return $this->response->getHeaders();
}

public function setHeaders($headers)
public function setHeaders(array $headers)
{
return $this->response->setHeaders($headers);
}
Expand Down
87 changes: 87 additions & 0 deletions services/Kit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php
/*
* Since 2007 PayPal
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author Since 2007 PayPal
* @author 202 ecommerce <[email protected]>
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @copyright PayPal
*
*/

namespace PaypalAddons\services;

use Exception;
use Throwable;

class Kit
{
public function rrmdir($dir)
{
if (false === is_dir($dir)) {
return false;
}

$objects = scandir($dir);

foreach ($objects as $object) {
if ($object === '.' || $object === '..') {
continue;
}
if (is_dir($dir . DIRECTORY_SEPARATOR . $object) && !is_link($dir . '/' . $object)) {
$this->rrmdir($dir . DIRECTORY_SEPARATOR . $object);
continue;
}

$this->unlink($dir . DIRECTORY_SEPARATOR . $object);
}

return $this->rmdir($dir);
}

public function unlink($file)
{
if (false === is_file($file)) {
return false;
}

try {
return unlink($file);
} catch (Exception $e) {
} catch (Throwable $e) {
}

return false;
}

public function rmdir($dir)
{
if (false === is_dir($dir)) {
return false;
}

try {
return rmdir($dir);
} catch (Exception $e) {
} catch (Throwable $e) {
}

return false;
}
}
13 changes: 3 additions & 10 deletions upgrade/Upgrade-6.4.3.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
*/
function upgrade_module_6_4_3($module)
{
$kit = new \PaypalAddons\services\Kit();
$baseDir = _PS_ROOT_DIR_ . '/modules/paypal/';
$dirs = [
'_dev',
Expand Down Expand Up @@ -74,18 +75,10 @@ function upgrade_module_6_4_3($module)
];

foreach ($dirs as $dir) {
if (file_exists($baseDir . $dir)) {
rmdir($baseDir . $dir);
}
$kit->rrmdir($baseDir . $dir);
bogdan202 marked this conversation as resolved.
Show resolved Hide resolved
}
foreach ($files as $file) {
if (file_exists($baseDir . $file)) {
try {
unlink($baseDir . $file);
} catch (Exception $e) {
} catch (Throwable $e) {
}
}
$kit->unlink($baseDir . $file);
}

return true;
Expand Down
Loading