diff --git a/administrator/components/com_admin/script.php b/administrator/components/com_admin/script.php index f7c70206341f3..8923b67508116 100644 --- a/administrator/components/com_admin/script.php +++ b/administrator/components/com_admin/script.php @@ -22,6 +22,7 @@ use Joomla\CMS\Table\Table; use Joomla\CMS\Uri\Uri; use Joomla\Database\ParameterType; +use Joomla\Filesystem\Path; use Joomla\Registry\Registry; // phpcs:disable PSR1.Files.SideEffects @@ -2458,7 +2459,7 @@ public function deleteUnexistingFiles($dryRun = false, $suppressOutput = false) } foreach ($folders as $folder) { - if ($folderExists = Folder::exists(JPATH_ROOT . $folder)) { + if ($folderExists = is_dir(Path::clean(JPATH_ROOT . $folder))) { $status['folders_exist'][] = $folder; if ($dryRun === false) { diff --git a/administrator/components/com_config/src/Model/ApplicationModel.php b/administrator/components/com_config/src/Model/ApplicationModel.php index 35699473633c3..528205007d615 100644 --- a/administrator/components/com_config/src/Model/ApplicationModel.php +++ b/administrator/components/com_config/src/Model/ApplicationModel.php @@ -496,7 +496,7 @@ public function save($data) $data['session_filesystem_path'] = Path::clean($data['session_filesystem_path']); if ($currentPath !== $data['session_filesystem_path']) { - if (!Folder::exists($data['session_filesystem_path']) && !Folder::create($data['session_filesystem_path'])) { + if (!is_dir(Path::clean($data['session_filesystem_path'])) && !Folder::create($data['session_filesystem_path'])) { try { Log::add( Text::sprintf( diff --git a/administrator/components/com_menus/src/Helper/MenusHelper.php b/administrator/components/com_menus/src/Helper/MenusHelper.php index 4ba123ed1f344..c2b963f576b02 100644 --- a/administrator/components/com_menus/src/Helper/MenusHelper.php +++ b/administrator/components/com_menus/src/Helper/MenusHelper.php @@ -615,7 +615,7 @@ public static function getPresets() $folder = JPATH_ADMINISTRATOR . '/components/' . $component->option . '/presets/'; - if (!Folder::exists($folder)) { + if (!is_dir($folder)) { continue; } diff --git a/administrator/components/com_templates/src/Model/TemplateModel.php b/administrator/components/com_templates/src/Model/TemplateModel.php index 0f2ef4130dd6e..b933ddb13d2c1 100644 --- a/administrator/components/com_templates/src/Model/TemplateModel.php +++ b/administrator/components/com_templates/src/Model/TemplateModel.php @@ -693,7 +693,7 @@ public function copy() // Delete new folder if it exists $toPath = $this->getState('to_path'); - if (Folder::exists($toPath)) { + if (is_dir(Path::clean($toPath))) { if (!Folder::delete($toPath)) { $app->enqueueMessage(Text::_('COM_TEMPLATES_ERROR_COULD_NOT_WRITE'), 'error'); @@ -1145,7 +1145,7 @@ public function createOverride($override) } // Check Html folder, create if not exist - if (!Folder::exists($htmlPath) && !Folder::create($htmlPath)) { + if (!is_dir(Path::clean($htmlPath)) && !Folder::create($htmlPath)) { $app->enqueueMessage(Text::_('COM_TEMPLATES_FOLDER_ERROR'), 'error'); return false; @@ -1203,7 +1203,7 @@ public function createTemplateOverride($overridePath, $htmlPath) foreach ($folders as $folder) { $htmlFolder = $htmlPath . str_replace($overridePath, '', $folder); - if (!Folder::exists($htmlFolder)) { + if (!is_dir(Path::clean($htmlFolder))) { Folder::create($htmlFolder); } } @@ -1864,7 +1864,7 @@ public function child() // Delete new folder if it exists $toPath = $this->getState('to_path'); - if (Folder::exists($toPath)) { + if (is_dir(Path::clean($toPath))) { if (!Folder::delete($toPath)) { $app->enqueueMessage(Text::_('COM_TEMPLATES_ERROR_COULD_NOT_WRITE'), 'error'); diff --git a/libraries/src/Form/Field/ChromestyleField.php b/libraries/src/Form/Field/ChromestyleField.php index 8a874191fd61b..f6901508580b4 100644 --- a/libraries/src/Form/Field/ChromestyleField.php +++ b/libraries/src/Form/Field/ChromestyleField.php @@ -15,6 +15,7 @@ use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; use Joomla\Database\ParameterType; +use Joomla\Filesystem\Path; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; @@ -189,7 +190,7 @@ protected function getTemplateModuleStyles() foreach ($templates as $template) { $chromeLayoutPath = $path . '/templates/' . $template->element . '/html/layouts/chromes'; - if (!Folder::exists($chromeLayoutPath)) { + if (!is_dir(Path::clean($chromeLayoutPath))) { continue; } diff --git a/libraries/src/Form/Rule/FolderPathExistsRule.php b/libraries/src/Form/Rule/FolderPathExistsRule.php index 9418439971757..5837604b0dacf 100644 --- a/libraries/src/Form/Rule/FolderPathExistsRule.php +++ b/libraries/src/Form/Rule/FolderPathExistsRule.php @@ -9,7 +9,6 @@ namespace Joomla\CMS\Form\Rule; -use Joomla\CMS\Filesystem\Folder; use Joomla\CMS\Form\Form; use Joomla\Filesystem\Path; use Joomla\Registry\Registry; @@ -64,6 +63,6 @@ public function test(\SimpleXMLElement $element, $value, $group = null, Registry return false; } - return Folder::exists($pathCleaned); + return is_dir(Path::clean($pathCleaned)); } } diff --git a/libraries/src/Installer/Adapter/FileAdapter.php b/libraries/src/Installer/Adapter/FileAdapter.php index 3f122feedc493..92eccd665555e 100644 --- a/libraries/src/Installer/Adapter/FileAdapter.php +++ b/libraries/src/Installer/Adapter/FileAdapter.php @@ -79,7 +79,7 @@ protected function copyBaseFiles() // Now that we have folder list, lets start creating them foreach ($this->folderList as $folder) { - if (!Folder::exists($folder)) { + if (!is_dir(Path::clean($folder))) { if (!$created = Folder::create($folder)) { throw new \RuntimeException( Text::sprintf('JLIB_INSTALLER_ABORT_FILE_INSTALL_FAIL_SOURCE_DIRECTORY', $folder) @@ -308,7 +308,7 @@ protected function removeExtensionFiles() // Lastly, remove the extension_root $folder = $this->parent->getPath('extension_root'); - if (Folder::exists($folder)) { + if (is_dir(Path::clean($folder))) { Folder::delete($folder); } @@ -515,7 +515,7 @@ protected function populateFilesAndFolderList() $folderName .= '/' . $dir; // Check if folder exists, if not then add to the array for folder creation - if (!Folder::exists($folderName)) { + if (!is_dir(Path::clean($folderName))) { $this->folderList[] = $folderName; } } @@ -525,7 +525,7 @@ protected function populateFilesAndFolderList() $targetFolder = empty($target) ? $jRootPath : $jRootPath . '/' . $target; // Check if source folder exists - if (!Folder::exists($sourceFolder)) { + if (!is_dir(Path::clean($sourceFolder))) { Log::add(Text::sprintf('JLIB_INSTALLER_ABORT_FILE_INSTALL_FAIL_SOURCE_DIRECTORY', $sourceFolder), Log::WARNING, 'jerror'); // If installation fails, rollback diff --git a/libraries/src/Installer/Adapter/LanguageAdapter.php b/libraries/src/Installer/Adapter/LanguageAdapter.php index 9564ff7f9036d..347f5a00b51d5 100644 --- a/libraries/src/Installer/Adapter/LanguageAdapter.php +++ b/libraries/src/Installer/Adapter/LanguageAdapter.php @@ -23,6 +23,7 @@ use Joomla\CMS\Table\Table; use Joomla\CMS\Table\Update; use Joomla\Database\ParameterType; +use Joomla\Filesystem\Path; use Joomla\Registry\Registry; // phpcs:disable PSR1.Files.SideEffects @@ -201,7 +202,7 @@ protected function setupUninstall() $this->parent->setPath('source', $path); // Check it exists - if (!Folder::exists($path)) { + if (!is_dir(Path::clean($path))) { // If the folder doesn't exist lets just nuke the row as well and presume the user killed it for us $this->extension->delete(); diff --git a/libraries/src/Installer/Adapter/LibraryAdapter.php b/libraries/src/Installer/Adapter/LibraryAdapter.php index f3eeacb7518d6..ffbdaf64a9c3f 100644 --- a/libraries/src/Installer/Adapter/LibraryAdapter.php +++ b/libraries/src/Installer/Adapter/LibraryAdapter.php @@ -19,6 +19,7 @@ use Joomla\CMS\Table\Update; use Joomla\Database\ParameterType; use Joomla\Filesystem\File; +use Joomla\Filesystem\Path; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; @@ -282,7 +283,7 @@ protected function removeExtensionFiles() // @todo: Change this so it walked up the path backwards so we clobber multiple empties // If the folder is empty, let's delete it - if (Folder::exists($this->parent->getPath('extension_root'))) { + if (is_dir(Path::clean($this->parent->getPath('extension_root')))) { if (is_dir($this->parent->getPath('extension_root'))) { $files = Folder::files($this->parent->getPath('extension_root')); diff --git a/libraries/src/Installer/Adapter/PackageAdapter.php b/libraries/src/Installer/Adapter/PackageAdapter.php index eb7875212dd89..a2a851158f44e 100644 --- a/libraries/src/Installer/Adapter/PackageAdapter.php +++ b/libraries/src/Installer/Adapter/PackageAdapter.php @@ -25,6 +25,7 @@ use Joomla\Database\ParameterType; use Joomla\Event\Event; use Joomla\Filesystem\File; +use Joomla\Filesystem\Path; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; @@ -336,7 +337,7 @@ protected function finaliseUninstall(): bool $folder = $this->parent->getPath('extension_root'); - if (Folder::exists($folder)) { + if (is_dir(Path::clean($folder))) { Folder::delete($folder); } diff --git a/libraries/src/Installer/Adapter/TemplateAdapter.php b/libraries/src/Installer/Adapter/TemplateAdapter.php index 7b768f4bdb20d..2f3f1d7ed2a3b 100644 --- a/libraries/src/Installer/Adapter/TemplateAdapter.php +++ b/libraries/src/Installer/Adapter/TemplateAdapter.php @@ -19,6 +19,7 @@ use Joomla\CMS\Table\Table; use Joomla\CMS\Table\Update; use Joomla\Database\ParameterType; +use Joomla\Filesystem\Path; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; @@ -392,7 +393,7 @@ protected function removeExtensionFiles() $this->parent->removeFiles($this->getManifest()->languages, $this->extension->client_id); // Delete the template directory - if (Folder::exists($this->parent->getPath('extension_root'))) { + if (is_dir(Path::clean($this->parent->getPath('extension_root')))) { Folder::delete($this->parent->getPath('extension_root')); } else { Log::add(Text::_('JLIB_INSTALLER_ERROR_TPL_UNINSTALL_TEMPLATE_DIRECTORY'), Log::WARNING, 'jerror'); diff --git a/libraries/src/Installer/Installer.php b/libraries/src/Installer/Installer.php index fdc98c9f102a2..094dd7a31d74a 100644 --- a/libraries/src/Installer/Installer.php +++ b/libraries/src/Installer/Installer.php @@ -614,7 +614,7 @@ public function abort($msg = null, $type = null) */ public function install($path = null) { - if ($path && Folder::exists($path)) { + if ($path && is_dir(Path::clean($path))) { $this->setPath('source', $path); } else { $this->abort(Text::_('JLIB_INSTALLER_ABORT_NOINSTALLPATH')); @@ -803,7 +803,7 @@ public function discover() */ public function update($path = null) { - if ($path && Folder::exists($path)) { + if ($path && is_dir(Path::clean($path))) { $this->setPath('source', $path); } else { $this->abort(Text::_('JLIB_INSTALLER_ABORT_NOUPDATEPATH')); @@ -1579,7 +1579,7 @@ public function parseLanguages(\SimpleXMLElement $element, $cid = 0) } // If the language folder is not present, then the core pack hasn't been installed... ignore - if (!Folder::exists(\dirname($path['dest']))) { + if (!is_dir(Path::clean(\dirname($path['dest'])))) { continue; } } else { @@ -1947,7 +1947,7 @@ public function removeFiles($element, $cid = 0) } // If the language folder is not present, then the core pack hasn't been installed... ignore - if (!Folder::exists(\dirname($path))) { + if (!is_dir(Path::clean(\dirname($path)))) { continue; } } else { @@ -2012,7 +2012,7 @@ public function copyManifest($cid = 1) public function findManifest() { // Do nothing if folder does not exist for some reason - if (!Folder::exists($this->getPath('source'))) { + if (!is_dir(Path::clean($this->getPath('source')))) { return false; } diff --git a/libraries/src/Installer/InstallerHelper.php b/libraries/src/Installer/InstallerHelper.php index 56e0245e03977..d3624541bb2f7 100644 --- a/libraries/src/Installer/InstallerHelper.php +++ b/libraries/src/Installer/InstallerHelper.php @@ -208,7 +208,7 @@ public static function unpack($packageFilename, $alwaysReturnArray = false) $dirList = array_merge((array) Folder::files($extractdir, ''), (array) Folder::folders($extractdir, '')); if (\count($dirList) === 1) { - if (Folder::exists($extractdir . '/' . $dirList[0])) { + if (is_dir(Path::clean($extractdir . '/' . $dirList[0]))) { $extractdir = Path::clean($extractdir . '/' . $dirList[0]); } } diff --git a/libraries/src/Installer/InstallerScript.php b/libraries/src/Installer/InstallerScript.php index 28da7035a4f52..22e71a6027e45 100644 --- a/libraries/src/Installer/InstallerScript.php +++ b/libraries/src/Installer/InstallerScript.php @@ -325,7 +325,7 @@ public function removeFiles() if (!empty($this->deleteFolders)) { foreach ($this->deleteFolders as $folder) { - if (Folder::exists(JPATH_ROOT . $folder) && !Folder::delete(JPATH_ROOT . $folder)) { + if (is_dir(Path::clean(JPATH_ROOT . $folder)) && !Folder::delete(JPATH_ROOT . $folder)) { echo Text::sprintf('JLIB_INSTALLER_ERROR_FILE_FOLDER', $folder) . '
'; } } diff --git a/plugins/editors/tinymce/src/PluginTraits/DisplayTrait.php b/plugins/editors/tinymce/src/PluginTraits/DisplayTrait.php index 6359531624349..61c290665f384 100644 --- a/plugins/editors/tinymce/src/PluginTraits/DisplayTrait.php +++ b/plugins/editors/tinymce/src/PluginTraits/DisplayTrait.php @@ -10,7 +10,6 @@ namespace Joomla\Plugin\Editors\TinyMCE\PluginTraits; -use Joomla\CMS\Filesystem\Folder; use Joomla\CMS\Filter\InputFilter; use Joomla\CMS\Language\Text; use Joomla\CMS\Layout\LayoutHelper; @@ -178,8 +177,8 @@ public function display(string $name, string $content = '', array $attributes = $skinDark = $levelParams->get($app->isClient('administrator') ? 'skin_admin_dark' : 'skin_dark', 'oxide-dark'); // Check that selected skin exists. - $skin = Folder::exists(JPATH_ROOT . '/media/vendor/tinymce/skins/ui/' . $skin) ? $skin : 'oxide'; - $skinDark = Folder::exists(JPATH_ROOT . '/media/vendor/tinymce/skins/ui/' . $skinDark) ? $skinDark : 'oxide-dark'; + $skin = is_dir(JPATH_ROOT . '/media/vendor/tinymce/skins/ui/' . $skin) ? $skin : 'oxide'; + $skinDark = is_dir(JPATH_ROOT . '/media/vendor/tinymce/skins/ui/' . $skinDark) ? $skinDark : 'oxide-dark'; if (!$levelParams->get('lang_mode', 1)) { // Admin selected language diff --git a/plugins/filesystem/local/src/Adapter/LocalAdapter.php b/plugins/filesystem/local/src/Adapter/LocalAdapter.php index c2a30d9481221..fa0e56813b51d 100644 --- a/plugins/filesystem/local/src/Adapter/LocalAdapter.php +++ b/plugins/filesystem/local/src/Adapter/LocalAdapter.php @@ -333,7 +333,7 @@ public function delete(string $path) $success = File::delete($localPath); } else { - if (!Folder::exists($localPath)) { + if (!is_dir(Path::clean($localPath))) { throw new FileNotFoundException(); } diff --git a/plugins/system/languagefilter/src/Extension/LanguageFilter.php b/plugins/system/languagefilter/src/Extension/LanguageFilter.php index 826a01543c81e..e925e411abab8 100644 --- a/plugins/system/languagefilter/src/Extension/LanguageFilter.php +++ b/plugins/system/languagefilter/src/Extension/LanguageFilter.php @@ -15,7 +15,6 @@ use Joomla\CMS\Association\AssociationServiceInterface; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Factory; -use Joomla\CMS\Filesystem\Folder; use Joomla\CMS\Language\Associations; use Joomla\CMS\Language\LanguageFactoryInterface; use Joomla\CMS\Language\LanguageHelper; @@ -606,7 +605,7 @@ public function onUserLogin($user, $options = []) if ( !\array_key_exists($lang_code, $this->lang_codes) || !\array_key_exists($lang_code, Multilanguage::getSiteHomePages()) - || !Folder::exists(JPATH_SITE . '/language/' . $lang_code) + || !is_dir(JPATH_SITE . '/language/' . $lang_code) ) { $lang_code = $this->current_lang; }