Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.0] Fix Composer Deprecation Notices #31804

Merged
merged 12 commits into from
Jan 27, 2021
67 changes: 67 additions & 0 deletions administrator/components/com_admin/script.php
Original file line number Diff line number Diff line change
Expand Up @@ -6280,6 +6280,8 @@ public function deleteUnexistingFiles($dryRun = false, $suppressOutput = false)
}
}

$this->fixFilenameCasing();

if ($suppressOutput === false && \count($status['folders_errors']))
{
echo implode('<br/>', $status['folders_errors']);
Expand Down Expand Up @@ -7142,4 +7144,69 @@ private function convertBlogLayouts()
$configModel->save($data);
}
}

/*
* Renames or removes incorrectly cased files.
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
protected function fixFilenameCasing()
{
$files = array(
// 3.10 changes
'libraries/src/Filesystem/Support/Stringcontroller.php' => 'libraries/src/Filesystem/Support/StringController.php',
'libraries/src/Form/Rule/SubFormRule.php' => 'libraries/src/Form/Rule/SubformRule.php',
// __DEPLOY_VERSION__
'media/vendor/skipto/js/skipTo.js' => '/media/vendor/skipto/js/skipto.js',
wilsonge marked this conversation as resolved.
Show resolved Hide resolved
);

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