Skip to content
Open
Show file tree
Hide file tree
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

This file was deleted.

68 changes: 68 additions & 0 deletions setup/includes/upgrades/common/3.3.0-cleanup-files.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

Check failure on line 1 in setup/includes/upgrades/common/3.3.0-cleanup-files.php

View workflow job for this annotation

GitHub Actions / phpcs

Header blocks must be separated by a single blank line

Check warning on line 1 in setup/includes/upgrades/common/3.3.0-cleanup-files.php

View workflow job for this annotation

GitHub Actions / phpcs

A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 32 and the first side effect is on line 9.
/**
* Common upgrade script for 3.3 to clean up files
*
* @var $modx modX
*
* @package setup
*/
$paths = [
'assets' => $modx->getOption('assets_path', null, MODX_ASSETS_PATH),
'base' => $modx->getOption('base_path', null, MODX_BASE_PATH),
'connectors' => $modx->getOption('connectors_path', null, MODX_CONNECTORS_PATH),
'core' => $modx->getOption('core_path', null, MODX_CORE_PATH),
'manager' => $modx->getOption('manager_path', null, MODX_MANAGER_PATH),
'processors' => $modx->getOption('processors_path', null, MODX_PROCESSORS_PATH),
];

$cleanup = [
'assets' => [],
'base' => [],
'connectors' => [],
'core' => [],
'manager' => [
'assets/modext/widgets/system/sqlsrv/modx.grid.databasetables.js',
],
];

$removedFiles = 0;
$removedDirs = 0;

if (!function_exists('recursiveRemoveDir')) {
function recursiveRemoveDir($dir)
{
$files = array_diff(scandir($dir), ['.', '..']);
foreach ($files as $file) {
(is_dir("$dir/$file")) ? recursiveRemoveDir("$dir/$file") : unlink("$dir/$file");
}

return rmdir($dir);
}
}

// Loop through legacy files/folders to clean up
foreach ($cleanup as $folder => $files) {
foreach ($files as $file) {
$legacyFile = $paths[$folder].$file;

Check failure on line 46 in setup/includes/upgrades/common/3.3.0-cleanup-files.php

View workflow job for this annotation

GitHub Actions / phpcs

Expected at least 1 space after &quot;.&quot;; 0 found

Check failure on line 46 in setup/includes/upgrades/common/3.3.0-cleanup-files.php

View workflow job for this annotation

GitHub Actions / phpcs

Expected at least 1 space before &quot;.&quot;; 0 found
if (file_exists($legacyFile) === true) {
if (is_dir($legacyFile) === true) {
// Remove legacy directory
recursiveRemoveDir($legacyFile);
++$removedDirs;
} else {
// Remove legacy file
unlink($legacyFile);
++$removedFiles;
}
}
}
}

$this->runner->addResult(
modInstallRunner::RESULT_SUCCESS,
'<p class="ok">' . $this->install->lexicon('legacy_cleanup_complete') .
'<br /><small>' . $this->install->lexicon(
'legacy_cleanup_count',
['files' => $removedFiles, 'folders' => $removedDirs]
) . '</small></p>'
);
Loading