diff --git a/administrator/components/com_admin/script.php b/administrator/components/com_admin/script.php
index 0bfcb1ca11650..740af2e95a46e 100644
--- a/administrator/components/com_admin/script.php
+++ b/administrator/components/com_admin/script.php
@@ -538,7 +538,7 @@ protected function updateManifestCaches()
$extensions = ExtensionHelper::getCoreExtensions();
// If we have the search package around, it may not have a manifest cache entry after upgrades from 3.x, so add it to the list
- if (File::exists(JPATH_ROOT . '/administrator/manifests/packages/pkg_search.xml')) {
+ if (is_file(JPATH_ROOT . '/administrator/manifests/packages/pkg_search.xml')) {
$extensions[] = ['package', 'pkg_search', '', 0];
}
@@ -7938,7 +7938,7 @@ public function deleteUnexistingFiles($dryRun = false, $suppressOutput = false)
$status['folders_checked'] = $folders;
foreach ($files as $file) {
- if ($fileExists = File::exists(JPATH_ROOT . $file)) {
+ if ($fileExists = is_file(JPATH_ROOT . $file)) {
$status['files_exist'][] = $file;
if ($dryRun === false) {
@@ -7976,8 +7976,8 @@ public function deleteUnexistingFiles($dryRun = false, $suppressOutput = false)
* but an update has put the files back. In that case it exists even if they don't believe in it!
*/
if (
- !File::exists(JPATH_ROOT . '/administrator/components/com_search/search.php')
- && File::exists(JPATH_ROOT . '/administrator/manifests/packages/pkg_search.xml')
+ !is_file(JPATH_ROOT . '/administrator/components/com_search/search.php')
+ && is_file(JPATH_ROOT . '/administrator/manifests/packages/pkg_search.xml')
) {
File::delete(JPATH_ROOT . '/administrator/manifests/packages/pkg_search.xml');
}
diff --git a/administrator/components/com_config/src/Field/ConfigComponentsField.php b/administrator/components/com_config/src/Field/ConfigComponentsField.php
index b4928f7e090ad..7ec5fb115417f 100644
--- a/administrator/components/com_config/src/Field/ConfigComponentsField.php
+++ b/administrator/components/com_config/src/Field/ConfigComponentsField.php
@@ -11,7 +11,6 @@
namespace Joomla\Component\Config\Administrator\Field;
use Joomla\CMS\Factory;
-use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Form\Field\ListField;
use Joomla\CMS\Language\Text;
use Joomla\Utilities\ArrayHelper;
@@ -60,7 +59,7 @@ protected function getOptions()
// Load language
$extension = $item->value;
- if (File::exists(JPATH_ADMINISTRATOR . '/components/' . $extension . '/config.xml')) {
+ if (is_file(JPATH_ADMINISTRATOR . '/components/' . $extension . '/config.xml')) {
$source = JPATH_ADMINISTRATOR . '/components/' . $extension;
$lang->load("$extension.sys", JPATH_ADMINISTRATOR)
|| $lang->load("$extension.sys", $source);
diff --git a/administrator/components/com_config/src/Model/ApplicationModel.php b/administrator/components/com_config/src/Model/ApplicationModel.php
index ae8704d7e7d94..44b23d5cc4dd2 100644
--- a/administrator/components/com_config/src/Model/ApplicationModel.php
+++ b/administrator/components/com_config/src/Model/ApplicationModel.php
@@ -187,7 +187,7 @@ public function validateDbConnection($data)
return false;
}
- if (!File::exists(Path::clean($data['dbsslca']))) {
+ if (!is_file(Path::clean($data['dbsslca']))) {
Factory::getApplication()->enqueueMessage(
Text::sprintf(
'COM_CONFIG_ERROR_DATABASE_ENCRYPTION_FILE_FIELD_BAD',
@@ -219,7 +219,7 @@ public function validateDbConnection($data)
return false;
}
- if (!File::exists(Path::clean($data['dbsslkey']))) {
+ if (!is_file(Path::clean($data['dbsslkey']))) {
Factory::getApplication()->enqueueMessage(
Text::sprintf(
'COM_CONFIG_ERROR_DATABASE_ENCRYPTION_FILE_FIELD_BAD',
@@ -243,7 +243,7 @@ public function validateDbConnection($data)
return false;
}
- if (!File::exists(Path::clean($data['dbsslcert']))) {
+ if (!is_file(Path::clean($data['dbsslcert']))) {
Factory::getApplication()->enqueueMessage(
Text::sprintf(
'COM_CONFIG_ERROR_DATABASE_ENCRYPTION_FILE_FIELD_BAD',
diff --git a/administrator/components/com_contenthistory/src/Helper/ContenthistoryHelper.php b/administrator/components/com_contenthistory/src/Helper/ContenthistoryHelper.php
index db8928383ae5a..57b03be269efa 100644
--- a/administrator/components/com_contenthistory/src/Helper/ContenthistoryHelper.php
+++ b/administrator/components/com_contenthistory/src/Helper/ContenthistoryHelper.php
@@ -161,7 +161,7 @@ public static function getFormFile(ContentType $typesTable)
// First, see if we have a file name in the $typesTable
$options = json_decode($typesTable->content_history_options);
- if (is_object($options) && isset($options->formFile) && File::exists(JPATH_ROOT . '/' . $options->formFile)) {
+ if (is_object($options) && isset($options->formFile) && is_file(JPATH_ROOT . '/' . $options->formFile)) {
$result = JPATH_ROOT . '/' . $options->formFile;
} else {
$aliasArray = explode('.', $typesTable->type_alias);
@@ -169,7 +169,7 @@ public static function getFormFile(ContentType $typesTable)
$path = Folder::makeSafe(JPATH_ADMINISTRATOR . '/components/' . $component . '/models/forms/');
array_shift($aliasArray);
$file = File::makeSafe(implode('.', $aliasArray) . '.xml');
- $result = File::exists($path . $file) ? $path . $file : false;
+ $result = is_file($path . $file) ? $path . $file : false;
}
return $result;
diff --git a/administrator/components/com_installer/src/Model/UpdateModel.php b/administrator/components/com_installer/src/Model/UpdateModel.php
index 59dc21ed5976e..87df0b865b921 100644
--- a/administrator/components/com_installer/src/Model/UpdateModel.php
+++ b/administrator/components/com_installer/src/Model/UpdateModel.php
@@ -12,7 +12,6 @@
use Joomla\CMS\Extension\ExtensionHelper;
use Joomla\CMS\Factory;
-use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Installer\Installer;
use Joomla\CMS\Installer\InstallerHelper;
@@ -563,7 +562,7 @@ protected function preparePreUpdate($update, $table)
$path = JPATH_ADMINISTRATOR . '/components/' . $table->element . '/helpers/' . $fname;
- if (File::exists($path)) {
+ if (is_file($path)) {
require_once $path;
if (class_exists($cname) && is_callable([$cname, 'prepareUpdate'])) {
@@ -578,7 +577,7 @@ protected function preparePreUpdate($update, $table)
$cname = str_replace('_', '', $table->element) . 'Helper';
$path = ($table->client_id ? JPATH_ADMINISTRATOR : JPATH_SITE) . '/modules/' . $table->element . '/helper.php';
- if (File::exists($path)) {
+ if (is_file($path)) {
require_once $path;
if (class_exists($cname) && is_callable([$cname, 'prepareUpdate'])) {
diff --git a/administrator/components/com_joomlaupdate/finalisation.php b/administrator/components/com_joomlaupdate/finalisation.php
index 697eacff3c585..f220911e3ee2f 100644
--- a/administrator/components/com_joomlaupdate/finalisation.php
+++ b/administrator/components/com_joomlaupdate/finalisation.php
@@ -77,7 +77,7 @@ function finalizeUpdate(string $siteRoot, string $restorePath): void
*/
$namespaceMapFile = JPATH_ROOT . '/administrator/cache/autoload_psr4.php';
- if (\Joomla\CMS\Filesystem\File::exists($namespaceMapFile)) {
+ if (is_file($namespaceMapFile)) {
\Joomla\CMS\Filesystem\File::delete($namespaceMapFile);
}
}
diff --git a/administrator/components/com_joomlaupdate/src/Controller/UpdateController.php b/administrator/components/com_joomlaupdate/src/Controller/UpdateController.php
index 42bb5fa5c5fba..1366e7fd9a89a 100644
--- a/administrator/components/com_joomlaupdate/src/Controller/UpdateController.php
+++ b/administrator/components/com_joomlaupdate/src/Controller/UpdateController.php
@@ -11,7 +11,6 @@
namespace Joomla\Component\Joomlaupdate\Administrator\Controller;
use Joomla\CMS\Factory;
-use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Log\Log;
use Joomla\CMS\MVC\Controller\BaseController;
@@ -283,7 +282,7 @@ public function captive()
// Do I really have an update package?
$tempFile = $this->app->getUserState('com_joomlaupdate.temp_file', null);
- if (empty($tempFile) || !File::exists($tempFile)) {
+ if (empty($tempFile) || !is_file($tempFile)) {
throw new \RuntimeException(Text::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'), 403);
}
diff --git a/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php b/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php
index 65e7ee42291c6..2bac036dafbd7 100644
--- a/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php
+++ b/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php
@@ -388,7 +388,7 @@ public function download()
$response = [];
// Do we have a cached file?
- $exists = File::exists($target);
+ $exists = is_file($target);
if (!$exists) {
// Not there, let's fetch it.
@@ -569,7 +569,7 @@ public function createUpdateFile($basename = null): bool
// Remove the old file, if it's there...
$configpath = JPATH_COMPONENT_ADMINISTRATOR . '/update.php';
- if (File::exists($configpath)) {
+ if (is_file($configpath)) {
if (!File::delete($configpath)) {
File::invalidateFileCache($configpath);
@unlink($configpath);
@@ -844,22 +844,22 @@ public function cleanUp()
File::delete($tempdir . '/' . $file);
// Remove the update.php file used in Joomla 4.0.3 and later.
- if (File::exists(JPATH_COMPONENT_ADMINISTRATOR . '/update.php')) {
+ if (is_file(JPATH_COMPONENT_ADMINISTRATOR . '/update.php')) {
File::delete(JPATH_COMPONENT_ADMINISTRATOR . '/update.php');
}
// Remove the legacy restoration.php file (when updating from Joomla 4.0.2 and earlier).
- if (File::exists(JPATH_COMPONENT_ADMINISTRATOR . '/restoration.php')) {
+ if (is_file(JPATH_COMPONENT_ADMINISTRATOR . '/restoration.php')) {
File::delete(JPATH_COMPONENT_ADMINISTRATOR . '/restoration.php');
}
// Remove the legacy restore_finalisation.php file used in Joomla 4.0.2 and earlier.
- if (File::exists(JPATH_COMPONENT_ADMINISTRATOR . '/restore_finalisation.php')) {
+ if (is_file(JPATH_COMPONENT_ADMINISTRATOR . '/restore_finalisation.php')) {
File::delete(JPATH_COMPONENT_ADMINISTRATOR . '/restore_finalisation.php');
}
// Remove joomla.xml from the site's root.
- if (File::exists(JPATH_ROOT . '/joomla.xml')) {
+ if (is_file(JPATH_ROOT . '/joomla.xml')) {
File::delete(JPATH_ROOT . '/joomla.xml');
}
@@ -985,7 +985,7 @@ public function captiveFileExists()
{
$file = Factory::getApplication()->getUserState('com_joomlaupdate.temp_file', null);
- if (empty($file) || !File::exists($file)) {
+ if (empty($file) || !is_file($file)) {
return false;
}
@@ -1007,7 +1007,7 @@ public function removePackageFiles()
];
foreach ($files as $file) {
- if ($file !== null && File::exists($file)) {
+ if ($file !== null && is_file($file)) {
File::delete($file);
}
}
diff --git a/administrator/components/com_postinstall/src/Controller/MessageController.php b/administrator/components/com_postinstall/src/Controller/MessageController.php
index d9f694ed486ae..18867a4cbe42a 100644
--- a/administrator/components/com_postinstall/src/Controller/MessageController.php
+++ b/administrator/components/com_postinstall/src/Controller/MessageController.php
@@ -10,7 +10,6 @@
namespace Joomla\Component\Postinstall\Administrator\Controller;
-use Joomla\CMS\Filesystem\File;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\Component\Postinstall\Administrator\Helper\PostinstallHelper;
use Joomla\Component\Postinstall\Administrator\Model\MessagesModel;
@@ -158,7 +157,7 @@ public function action()
$helper = new PostinstallHelper();
$file = $helper->parsePath($item->action_file);
- if (File::exists($file)) {
+ if (is_file($file)) {
require_once $file;
call_user_func($item->action);
diff --git a/administrator/components/com_postinstall/src/Model/MessagesModel.php b/administrator/components/com_postinstall/src/Model/MessagesModel.php
index 465d5e7e83351..5881040c45cdd 100644
--- a/administrator/components/com_postinstall/src/Model/MessagesModel.php
+++ b/administrator/components/com_postinstall/src/Model/MessagesModel.php
@@ -14,7 +14,6 @@
use Joomla\CMS\Cache\Controller\CallbackController;
use Joomla\CMS\Extension\ExtensionHelper;
use Joomla\CMS\Factory;
-use Joomla\CMS\Filesystem\File;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
@@ -414,7 +413,7 @@ protected function onProcessList(&$resultArray)
$helper = new PostinstallHelper();
$file = $helper->parsePath($item->condition_file);
- if (File::exists($file)) {
+ if (is_file($file)) {
require_once $file;
$result = call_user_func($item->condition_method);
diff --git a/administrator/components/com_templates/src/Model/TemplateModel.php b/administrator/components/com_templates/src/Model/TemplateModel.php
index 29f0cc72352ed..211f5f479eff7 100644
--- a/administrator/components/com_templates/src/Model/TemplateModel.php
+++ b/administrator/components/com_templates/src/Model/TemplateModel.php
@@ -713,7 +713,7 @@ public function copy()
$src = Path::clean($client->path . '/language/' . $languageFile);
$dst = Path::clean($toPath . '/' . $folder . '/' . $languageFile);
- if (File::exists($src)) {
+ if (is_file($src)) {
File::copy($src, $dst);
}
}
@@ -784,7 +784,7 @@ protected function fixTemplateName()
// Edit XML file
$xmlFile = $this->getState('to_path') . '/templateDetails.xml';
- if (File::exists($xmlFile)) {
+ if (is_file($xmlFile)) {
$contents = file_get_contents($xmlFile);
$pattern[] = '#\s*' . $manifest->name . '\s*#i';
$replace[] = '' . $newName . '';
@@ -1215,7 +1215,7 @@ public function createTemplateOverride($overridePath, $htmlPath)
$overrideFilePath = str_replace($overridePath, '', $file);
$htmlFilePath = $htmlPath . $overrideFilePath;
- if (File::exists($htmlFilePath)) {
+ if (is_file($htmlFilePath)) {
// Generate new unique file name base on current time
$today = Factory::getDate();
$htmlFilePath = File::stripExt($htmlFilePath) . '-' . $today->format('Ymd-His') . '.' . File::getExt($htmlFilePath);
@@ -1890,7 +1890,7 @@ public function child()
// Edit XML file
$xmlFile = Path::clean($this->getState('to_path') . '/templateDetails.xml');
- if (!File::exists($xmlFile)) {
+ if (!is_file($xmlFile)) {
$app->enqueueMessage(Text::_('COM_TEMPLATES_ERROR_INVALID_FROM_NAME'), 'error');
return false;
diff --git a/components/com_config/tmpl/modules/default.php b/components/com_config/tmpl/modules/default.php
index 147b6a9482455..7a46f66473d10 100644
--- a/components/com_config/tmpl/modules/default.php
+++ b/components/com_config/tmpl/modules/default.php
@@ -11,7 +11,6 @@
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
-use Joomla\CMS\Filesystem\File;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Multilanguage;
use Joomla\CMS\Language\Text;
@@ -28,7 +27,7 @@
$editorText = false;
$moduleXml = JPATH_SITE . '/modules/' . $this->item['module'] . '/' . $this->item['module'] . '.xml';
-if (File::exists($moduleXml)) {
+if (is_file($moduleXml)) {
$xml = simplexml_load_file($moduleXml);
if (isset($xml->customContent)) {
diff --git a/installation/src/Helper/DatabaseHelper.php b/installation/src/Helper/DatabaseHelper.php
index 3f8920f3e8869..b3bd243a89e37 100644
--- a/installation/src/Helper/DatabaseHelper.php
+++ b/installation/src/Helper/DatabaseHelper.php
@@ -273,7 +273,7 @@ public static function validateConnectionParameters($options)
return Text::sprintf('INSTL_DATABASE_ENCRYPTION_MSG_FILE_FIELD_EMPTY', Text::_('INSTL_DATABASE_ENCRYPTION_CA_LABEL'));
}
- if (!File::exists(Path::clean($options->db_sslca))) {
+ if (!is_file(Path::clean($options->db_sslca))) {
return Text::sprintf('INSTL_DATABASE_ENCRYPTION_MSG_FILE_FIELD_BAD', Text::_('INSTL_DATABASE_ENCRYPTION_CA_LABEL'));
}
} else {
@@ -290,7 +290,7 @@ public static function validateConnectionParameters($options)
return Text::sprintf('INSTL_DATABASE_ENCRYPTION_MSG_FILE_FIELD_EMPTY', Text::_('INSTL_DATABASE_ENCRYPTION_KEY_LABEL'));
}
- if (!File::exists(Path::clean($options->db_sslkey))) {
+ if (!is_file(Path::clean($options->db_sslkey))) {
return Text::sprintf('INSTL_DATABASE_ENCRYPTION_MSG_FILE_FIELD_BAD', Text::_('INSTL_DATABASE_ENCRYPTION_KEY_LABEL'));
}
@@ -298,7 +298,7 @@ public static function validateConnectionParameters($options)
return Text::sprintf('INSTL_DATABASE_ENCRYPTION_MSG_FILE_FIELD_EMPTY', Text::_('INSTL_DATABASE_ENCRYPTION_CERT_LABEL'));
}
- if (!File::exists(Path::clean($options->db_sslcert))) {
+ if (!is_file(Path::clean($options->db_sslcert))) {
return Text::sprintf('INSTL_DATABASE_ENCRYPTION_MSG_FILE_FIELD_BAD', Text::_('INSTL_DATABASE_ENCRYPTION_CERT_LABEL'));
}
} else {
@@ -403,7 +403,7 @@ public static function checkRemoteDbHost($options)
if (
Factory::getSession()->get('remoteDbFileWrittenByJoomla', false) === true
- && File::exists(JPATH_INSTALLATION . '/' . $remoteDbFile)
+ && is_file(JPATH_INSTALLATION . '/' . $remoteDbFile)
) {
// Add the general message
Factory::getApplication()->enqueueMessage($generalRemoteDatabaseMessage, 'warning');
@@ -422,7 +422,7 @@ public static function checkRemoteDbHost($options)
return false;
}
- if (Factory::getSession()->get('remoteDbFileUnwritable', false) === true && !File::exists(JPATH_INSTALLATION . '/' . $remoteDbFile)) {
+ if (Factory::getSession()->get('remoteDbFileUnwritable', false) === true && !is_file(JPATH_INSTALLATION . '/' . $remoteDbFile)) {
// Add the general message
Factory::getApplication()->enqueueMessage($generalRemoteDatabaseMessage, 'warning');
diff --git a/libraries/src/Log/Logger/FormattedtextLogger.php b/libraries/src/Log/Logger/FormattedtextLogger.php
index b57766d3db2f9..d513fbf8515fe 100644
--- a/libraries/src/Log/Logger/FormattedtextLogger.php
+++ b/libraries/src/Log/Logger/FormattedtextLogger.php
@@ -259,7 +259,7 @@ protected function generateFileHeader()
protected function initFile()
{
// We only need to make sure the file exists
- if (File::exists($this->path)) {
+ if (is_file($this->path)) {
return;
}
diff --git a/plugins/filesystem/local/src/Adapter/LocalAdapter.php b/plugins/filesystem/local/src/Adapter/LocalAdapter.php
index da9c95003cfd3..bfaa62bc6c745 100644
--- a/plugins/filesystem/local/src/Adapter/LocalAdapter.php
+++ b/plugins/filesystem/local/src/Adapter/LocalAdapter.php
@@ -288,7 +288,7 @@ public function updateFile(string $name, string $path, $data)
{
$localPath = $this->getLocalPath($path . '/' . $name);
- if (!File::exists($localPath)) {
+ if (!is_file($localPath)) {
throw new FileNotFoundException();
}
@@ -324,10 +324,6 @@ public function delete(string $path)
$thumbnailPaths = $this->getLocalThumbnailPaths($localPath);
if (is_file($localPath)) {
- if (!File::exists($localPath)) {
- throw new FileNotFoundException();
- }
-
if ($this->thumbnails && !empty($thumbnailPaths['fs']) && is_file($thumbnailPaths['fs'])) {
File::delete($thumbnailPaths['fs']);
}
diff --git a/plugins/system/tasknotification/tasknotification.php b/plugins/system/tasknotification/tasknotification.php
index e5acb1d8c64ee..3de75000b93f8 100644
--- a/plugins/system/tasknotification/tasknotification.php
+++ b/plugins/system/tasknotification/tasknotification.php
@@ -12,7 +12,6 @@
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Factory;
-use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Filesystem\Path;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Language\Text;
@@ -118,7 +117,9 @@ public function injectTaskNotificationFieldset(EventInterface $event): bool
return false;
}
- if (!File::exists($formFile)) {
+ $formFile = Path::clean($formFile);
+
+ if (!is_file($formFile)) {
return false;
}
@@ -302,7 +303,6 @@ private function sendMail(string $template, array $data, string $attachment = ''
if (
!empty($attachment)
- && File::exists($attachment)
&& is_file($attachment)
) {
// @todo we allow multiple files [?]