Skip to content

Commit

Permalink
Merge pull request #7941 from Sesquipedalian/tasks_upgrader
Browse files Browse the repository at this point in the history
Renames tasks directory to Tasks during upgrade
  • Loading branch information
jdarwood007 authored Dec 5, 2023
2 parents f64c907 + 0d12121 commit 126c850
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions other/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -1839,6 +1839,36 @@ function DeleteUpgrade()
'upgradeData' => null,
);

// Fix case of Tasks directory.
if (
is_dir(Config::$tasksdir)
&& basename(Config::$tasksdir) !== 'Tasks'
&& is_writable(Config::$tasksdir)
&& is_writable(dirname(Config::$tasksdir))
) {
// Do 'tasks' and 'Tasks' both exist?
if (
!empty(fileinode(realpath(dirname(Config::$tasksdir) . '/tasks')))
&& !empty(fileinode(realpath(dirname(Config::$tasksdir) . '/Tasks')))
&& fileinode(realpath(Config::$tasksdir)) !== fileinode(realpath(dirname(Config::$tasksdir) . '/Tasks'))
) {
// Move everything in 'Tasks' to 'tasks'.
foreach (glob(realpath(dirname(Config::$tasksdir) . '/Tasks') . DIRECTORY_SEPARATOR . '*') as $path) {
rename($path, realpath(Config::$tasksdir) . DIRECTORY_SEPARATOR . basename($path));
}

// Now delete 'Tasks'.
rmdir(realpath(dirname(Config::$tasksdir) . '/Tasks'));
}

// Rename 'tasks' to 'Tasks'.
// Do this in two steps to make sure it works on case insensitive file systems.
rename(Config::$tasksdir, dirname(Config::$tasksdir) . DIRECTORY_SEPARATOR . 'Tasks_temp');
rename(dirname(Config::$tasksdir) . DIRECTORY_SEPARATOR . 'Tasks_temp', dirname(Config::$tasksdir) . DIRECTORY_SEPARATOR . 'Tasks');

$changes['tasksdir'] = dirname(Config::$tasksdir) . '/Tasks';
}

// Are we in maintenance mode?
if (isset($upcontext['user']['main']))
{
Expand Down

0 comments on commit 126c850

Please sign in to comment.