Skip to content
Merged
67 changes: 65 additions & 2 deletions administrator/components/com_admin/script.php
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,6 @@ public function deleteUnexistingFiles()
'/media/editors/tinymce/skins/lightgray/fonts/tinymce.dev.svg',
'/media/editors/tinymce/skins/lightgray/img/wline.gif',
'/media/mod_languages/images/km_kr.gif',
'/media/mod_languages/images/si_LK.gif',
'/plugins/editors/codemirror/styles.css',
'/plugins/editors/codemirror/styles.min.css',

Expand All @@ -1539,7 +1538,6 @@ public function deleteUnexistingFiles()
'/libraries/simplepie/idn/idna_convert.class.php',
'/libraries/simplepie/idn/npdata.ser',
'/libraries/simplepie/simplepie.php',
'/media/mod_languages/images/si_lk.gif',
'/media/system/js/permissions.min.js',
'/plugins/editors/tinymce/fields/skins.php',
'/plugins/user/profile/fields/dob.php',
Expand Down Expand Up @@ -2324,6 +2322,8 @@ public function deleteUnexistingFiles()
{
JFile::delete(JPATH_ROOT . '/administrator/manifests/packages/pkg_weblinks.xml');
}

$this->fixFilenameCasing();
}

/**
Expand Down Expand Up @@ -2657,4 +2657,67 @@ private function cleanJoomlaCache()
$model->setState('client_id', 1);
$model->clean();
}

/**
* Renames or removes incorrectly cased files.
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
protected function fixFilenameCasing()
{
$files = array(
'libraries/src/Filesystem/Support/Stringcontroller.php' => 'libraries/src/Filesystem/Support/StringController.php',
'libraries/vendor/paragonie/sodium_compat/src/Core/Xsalsa20.php' => 'libraries/vendor/paragonie/sodium_compat/src/Core/XSalsa20.php',
'media/mod_languages/images/si_LK.gif' => 'media/mod_languages/images/si_lk.gif',
);

foreach ($files as $old => $expected)
{
$oldRealpath = realpath(JPATH_ROOT . '/' . $old);

// On Unix without incorrectly cased file.
if ($oldRealpath === false)
{
continue;
}

$oldBasename = basename($oldRealpath);
$newRealpath = realpath(JPATH_ROOT . '/' . $expected);
$newBasename = basename($newRealpath);
$expectedBasename = basename($expected);

// On Windows or Unix with only the incorrectly cased file.
if ($newBasename !== $expectedBasename)
{
// Rename the file.
rename(JPATH_ROOT . '/' . $old, JPATH_ROOT . '/' . $old . '.tmp');
rename(JPATH_ROOT . '/' . $old . '.tmp', JPATH_ROOT . '/' . $expected);

continue;
}

// There might still be an incorrectly cased file on other OS than Windows.
if ($oldBasename === basename($old))
{
// Check if case-insensitive file system, eg on OSX.
if (fileinode($oldRealpath) === fileinode($newRealpath))
{
// Check deeper because even realpath or glob might not return the actual case.
if (!in_array($expectedBasename, scandir(dirname($newRealpath))))
{
// Rename the file.
rename(JPATH_ROOT . '/' . $old, JPATH_ROOT . '/' . $old . '.tmp');
rename(JPATH_ROOT . '/' . $old . '.tmp', JPATH_ROOT . '/' . $expected);
}
}
else
{
// On Unix with both files: Delete the incorrectly cased file.
unlink(JPATH_ROOT . '/' . $old);
}
}
}
}
}
2 changes: 1 addition & 1 deletion libraries/src/Filesystem/Streams/StreamString.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

defined('JPATH_PLATFORM') or die;

use Joomla\CMS\Filesystem\Support\Stringcontroller;
use Joomla\CMS\Filesystem\Support\StringController;

/**
* String Stream Wrapper
Expand Down