Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions administrator/components/com_admin/script.php
Original file line number Diff line number Diff line change
Expand Up @@ -6999,7 +6999,7 @@ protected function fixFilenameCasing()
$newBasename = basename($newRealpath);
$expectedBasename = basename($expected);

// On Windows with incorrectly cased file.
// On Windows or Unix with only the incorrectly cased file.
if ($newBasename !== $expectedBasename)
{
// Rename the file.
Expand All @@ -7009,10 +7009,25 @@ protected function fixFilenameCasing()
continue;
}

// On Unix with correctly and incorrectly cased files.
if ($oldBasename === basename($old) && $newBasename === $expectedBasename)
// There might still be an incorrectly cased file on other OS than Windows.
if ($oldBasename === basename($old))
{
unlink(JPATH_ROOT . '/' . $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);
}
}
}
}
Expand Down