Skip to content

Commit

Permalink
[5.1] Aliasing Filesystem classes for installation, updating script.p…
Browse files Browse the repository at this point in the history
…hp (joomla#42978)
  • Loading branch information
Hackwar authored Mar 10, 2024
1 parent af08b9c commit fba52f5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
11 changes: 4 additions & 7 deletions administrator/components/com_admin/script.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Extension\ExtensionHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\Installer\Installer;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Log\Log;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Uri\Uri;
use Joomla\Database\ParameterType;
use Joomla\Filesystem\Path;
use Joomla\Filesystem\File;
use Joomla\Filesystem\Folder;
use Joomla\Registry\Registry;

// phpcs:disable PSR1.Files.SideEffects
Expand Down Expand Up @@ -573,8 +572,6 @@ public function deleteUnexistingFiles($dryRun = false, $suppressOutput = false)
'folders_deleted' => [],
'files_errors' => [],
'folders_errors' => [],
'folders_checked' => [],
'files_checked' => [],
];

$files = [
Expand Down Expand Up @@ -2540,7 +2537,7 @@ public function deleteUnexistingFiles($dryRun = false, $suppressOutput = false)
$status['folders_checked'] = $folders;

foreach ($files as $file) {
if ($fileExists = is_file(JPATH_ROOT . $file)) {
if (is_file(JPATH_ROOT . $file)) {
$status['files_exist'][] = $file;

if ($dryRun === false) {
Expand All @@ -2554,7 +2551,7 @@ public function deleteUnexistingFiles($dryRun = false, $suppressOutput = false)
}

foreach ($folders as $folder) {
if ($folderExists = is_dir(Path::clean(JPATH_ROOT . $folder))) {
if (is_dir(JPATH_ROOT . $folder)) {
$status['folders_exist'][] = $folder;

if ($dryRun === false) {
Expand Down
16 changes: 12 additions & 4 deletions administrator/components/com_joomlaupdate/finalisation.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,16 @@ function finalizeUpdate(string $siteRoot, string $restorePath): void
$namespaceMapFile = JPATH_ROOT . '/administrator/cache/autoload_psr4.php';

if (is_file($namespaceMapFile)) {
\Joomla\CMS\Filesystem\File::delete($namespaceMapFile);
\Joomla\Filesystem\File::delete($namespaceMapFile);
}
}
}
}

namespace Joomla\CMS\Filesystem
namespace Joomla\Filesystem
{
// Fake the File class
if (!class_exists('\Joomla\CMS\Filesystem\File')) {
if (!class_exists('\Joomla\Filesystem\File')) {
/**
* File mock class
*
Expand Down Expand Up @@ -168,7 +168,7 @@ public static function invalidateFileCache($filepath, $force = true)
}

// Fake the Folder class, mapping it to Restore's post-processing class
if (!class_exists('\Joomla\CMS\Filesystem\Folder')) {
if (!class_exists('\Joomla\Filesystem\Folder')) {
/**
* Folder mock class
*
Expand Down Expand Up @@ -236,6 +236,14 @@ public static function delete(string $folderName): bool
}
}
}

if (!class_exists('\Joomla\CMS\Filesystem\File')) {
class_alias('\\Joomla\\Filesystem\\File', '\\Joomla\\CMS\\Filesystem\\File');
}

if (!class_exists('\Joomla\CMS\Filesystem\Folder')) {
class_alias('\\Joomla\\Filesystem\\Folder', '\\Joomla\\CMS\\Filesystem\\Folder');
}
}

namespace Joomla\CMS\Language
Expand Down

0 comments on commit fba52f5

Please sign in to comment.