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

[5.2] Refactor all instances of File::delete() to use framework #43360

Merged
merged 8 commits into from
Aug 13, 2024
24 changes: 16 additions & 8 deletions libraries/src/Console/UpdateCoreCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
use Joomla\Application\Cli\CliInput;
use Joomla\CMS\Extension\ExtensionHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\Installer\InstallerHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Log\Log;
use Joomla\Console\Command\AbstractCommand;
use Joomla\Database\DatabaseInterface;
use Joomla\Filesystem\Exception\FilesystemException;
use Joomla\Filesystem\File;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down Expand Up @@ -280,13 +281,20 @@ private function updateJoomlaCore($updatemodel): bool
// Remove the administrator/cache/autoload_psr4.php file
$autoloadFile = JPATH_CACHE . '/autoload_psr4.php';

if (file_exists($autoloadFile)) {
File::delete($autoloadFile);
}

// Remove the xml
if (file_exists(JPATH_BASE . '/joomla.xml')) {
File::delete(JPATH_BASE . '/joomla.xml');
try {
if (file_exists($autoloadFile)) {
File::delete($autoloadFile);
}

// Remove the xml
if (file_exists(JPATH_BASE . '/joomla.xml')) {
File::delete(JPATH_BASE . '/joomla.xml');
}
} catch (FilesystemException $exception) {
$this->progressBar->clear();
$this->ioStyle->error($exception->getMessage());
$this->progressBar->display();
$this->progressBar->advance();
}

InstallerHelper::cleanupInstall($package['file'], $package['extractdir']);
Expand Down
15 changes: 12 additions & 3 deletions plugins/task/rotatelogs/src/Extension/RotateLogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@

namespace Joomla\Plugin\Task\RotateLogs\Extension;

use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\Component\Scheduler\Administrator\Event\ExecuteTaskEvent;
use Joomla\Component\Scheduler\Administrator\Task\Status;
use Joomla\Component\Scheduler\Administrator\Traits\TaskPluginTrait;
use Joomla\Database\DatabaseAwareTrait;
use Joomla\Event\SubscriberInterface;
use Joomla\Filesystem\Exception\FilesystemException;
use Joomla\Filesystem\File;
use Joomla\Filesystem\Folder;
use Joomla\Filesystem\Path;

Expand Down Expand Up @@ -100,7 +101,11 @@ private function rotateLogs(ExecuteTaskEvent $event): int
if ($version >= $logsToKeep) {
// Delete files which have version greater than or equals $logsToKeep
foreach ($files as $file) {
File::delete($logPath . '/' . $file);
try {
File::delete($logPath . '/' . $file);
} catch (FilesystemException $exception) {

}
Hackwar marked this conversation as resolved.
Show resolved Hide resolved
}
} else {
// For files which have version smaller than $logsToKeep, rotate (increase version number)
Expand Down Expand Up @@ -140,7 +145,11 @@ private function rotate($path, $filename, $currentVersion)
$rotatedFile = $path . '/' . implode('.', $parts);
}

File::move($path . '/' . $filename, $rotatedFile);
try {
File::move($path . '/' . $filename, $rotatedFile);
} catch (FilesystemException $exception) {

}
}

/**
Expand Down