mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-11-04 19:17:46 +09:00
Remove installer from production debug deployments (#4322)
🔒 Remove installer from production debug deployments
This commit is contained in:
1 parent
0540aaefc3
commit
8484943ad6
3 files changed
+4
-22
No files matched your search
@@ -348,12 +348,11 @@ class UpdateFinalization implements InjectionAwareInterface
|
||||
|
||||
/**
|
||||
* Mirrors checkInstaller()'s guard in load.php: skipped for explicit dev/test
|
||||
* environments and while debugging, so those instances keep the installer.
|
||||
* environments, so those instances keep the installer.
|
||||
*/
|
||||
private function shouldRemoveInstallDirectory(): bool
|
||||
{
|
||||
// @phpstan-ignore booleanNot.alwaysTrue (DEBUG is a runtime constant)
|
||||
return Environment::isProduction() && !DEBUG;
|
||||
return Environment::isProduction();
|
||||
}
|
||||
|
||||
private function getAvailablePatchCount(): ?int
|
||||
|
||||
+2
-12
@@ -47,18 +47,8 @@ function checkInstaller(): void
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if /install directory still exists after installation has been completed.
|
||||
if ($filesystem->exists(PATH_CONFIG) && $filesystem->exists(Path::join('install', 'install.php'))) {
|
||||
// Throw exception only if debug mode is NOT enabled.
|
||||
if (!empty(Config::getProperty('debug_and_monitoring.debug'))) {
|
||||
throw new Exception('For security reasons, you have to delete the install directory before you can use FOSSBilling.', 2);
|
||||
}
|
||||
}
|
||||
|
||||
// If the config file exists and not install.php, but the install folder does, perform some cleanup.
|
||||
// The guard above already excludes dev/test, so this only skips DEBUG instances.
|
||||
// @phpstan-ignore booleanNot.alwaysTrue (DEBUG is a runtime constant)
|
||||
if ($filesystem->exists(PATH_CONFIG) && $filesystem->exists(Path::normalize('install')) && !DEBUG) {
|
||||
// If the config file and install directory both exist, installation has completed.
|
||||
if ($filesystem->exists(PATH_CONFIG) && $filesystem->exists(Path::normalize('install'))) {
|
||||
// Bootstrap runs before the DI logger and PHP error log are configured.
|
||||
error_log('Removing the install directory now that installation is complete.');
|
||||
$filesystem->remove('install');
|
||||
|
||||
@@ -5,20 +5,13 @@ declare(strict_types=1);
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\Filesystem\Path;
|
||||
|
||||
/**
|
||||
* Stubs the global $filesystem used by checkInstaller() so the test never touches real
|
||||
* disk. The installer entry point is reported as missing so the exception-throwing branch,
|
||||
* which reads the real config via Config::getProperty(), is skipped.
|
||||
*/
|
||||
function runCheckInstallerWithStubbedFilesystem(bool $expectRemoval): void
|
||||
{
|
||||
$configPath = PATH_CONFIG;
|
||||
$installerEntryPoint = Path::join('install', 'install.php');
|
||||
$installDir = Path::normalize('install');
|
||||
|
||||
$mock = Mockery::mock(Filesystem::class);
|
||||
$mock->shouldReceive('exists')->with($configPath)->andReturn(true);
|
||||
$mock->shouldReceive('exists')->with($installerEntryPoint)->andReturn(false);
|
||||
$mock->shouldReceive('exists')->with($installDir)->andReturn(true);
|
||||
|
||||
if ($expectRemoval) {
|
||||
|
||||
Reference in new issue
Block a user