Skip to content

Commit

Permalink
Merge pull request #877 from M0rgan01/drop_server_configuration
Browse files Browse the repository at this point in the history
Drop server performance configuration
  • Loading branch information
M0rgan01 authored Sep 10, 2024
2 parents e1f1d6a + 815b581 commit 0bc86e3
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 52 deletions.
1 change: 0 additions & 1 deletion classes/Analytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ public function getProperties($type)
'upgrade_channel' => $this->upgradeConfiguration->getChannel(),
'backup_files_and_databases' => $this->upgradeConfiguration->shouldBackupFilesAndDatabase(),
'backup_images' => $this->upgradeConfiguration->shouldBackupImages(),
'server_performance' => $this->upgradeConfiguration->getPerformanceLevel(),
'disable_non_native_modules' => $this->upgradeConfiguration->shouldDeactivateCustomModules(),
'upgrade_default_theme' => $this->upgradeConfiguration->shouldUpdateDefaultTheme(),
'switch_to_default_theme' => $this->upgradeConfiguration->shouldSwitchToDefaultTheme(),
Expand Down
28 changes: 9 additions & 19 deletions classes/Parameters/UpgradeConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
class UpgradeConfiguration extends ArrayCollection
{
const UPGRADE_CONST_KEYS = [
'PS_AUTOUP_PERFORMANCE',
'PS_AUTOUP_CUSTOM_MOD_DESACT',
'PS_AUTOUP_UPDATE_DEFAULT_THEME',
'PS_AUTOUP_CHANGE_DEFAULT_THEME',
Expand All @@ -51,7 +50,6 @@ class UpgradeConfiguration extends ArrayCollection
];

const PS_CONST_DEFAULT_VALUE = [
'PS_AUTOUP_PERFORMANCE' => 1,
'PS_AUTOUP_CUSTOM_MOD_DESACT' => 1,
'PS_AUTOUP_UPDATE_DEFAULT_THEME' => 1,
'PS_AUTOUP_CHANGE_DEFAULT_THEME' => 0,
Expand All @@ -64,13 +62,13 @@ class UpgradeConfiguration extends ArrayCollection
/**
* Performance settings, if your server has a low memory size, lower these values.
*
* @var array<string, int[]>
* @var array<string, int>
*/
private const PERFORMANCE_VALUES = [
'loopFiles' => [400, 800, 1600], // files
'loopTime' => [6, 12, 25], // seconds
'maxBackupFileSize' => [15728640, 31457280, 62914560], // bytes
'maxWrittenAllowed' => [4194304, 8388608, 16777216], // bytes
'loopFiles' => 400, // files
'loopTime' => 6, // seconds
'maxBackupFileSize' => 15728640, // bytes
'maxWrittenAllowed' => 4194304, // bytes
];

/**
Expand Down Expand Up @@ -102,39 +100,31 @@ public function getChannel(): string
*/
public function getNumberOfFilesPerCall(): int
{
return $this::PERFORMANCE_VALUES['loopFiles'][$this->getPerformanceLevel()];
return $this::PERFORMANCE_VALUES['loopFiles'];
}

/**
* @return int Number of seconds allowed before having to make another request
*/
public function getTimePerCall(): int
{
return $this::PERFORMANCE_VALUES['loopTime'][$this->getPerformanceLevel()];
return $this::PERFORMANCE_VALUES['loopTime'];
}

/**
* @return int Kind of reference for SQL file creation, giving a file size before another request is needed
*/
public function getMaxSizeToWritePerCall(): int
{
return $this::PERFORMANCE_VALUES['maxWrittenAllowed'][$this->getPerformanceLevel()];
return $this::PERFORMANCE_VALUES['maxWrittenAllowed'];
}

/**
* @return int Max file size allowed in backup
*/
public function getMaxFileToBackup(): int
{
return $this::PERFORMANCE_VALUES['maxBackupFileSize'][$this->getPerformanceLevel()];
}

/**
* @return int level of performance selected (0 for low, 2 for high)
*/
public function getPerformanceLevel(): int
{
return $this->get('PS_AUTOUP_PERFORMANCE') - 1;
return $this::PERFORMANCE_VALUES['maxBackupFileSize'];
}

public function shouldBackupFilesAndDatabase(): bool
Expand Down
19 changes: 0 additions & 19 deletions classes/Twig/Form/UpgradeOptionsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,6 @@ public function __construct(Translator $translator, FormRenderer $formRenderer)
$this->formRenderer = $formRenderer;

$this->fields = [
'PS_AUTOUP_PERFORMANCE' => [
'title' => $translator->trans(
'Server performance'
),
'cast' => 'intval',
'validation' => 'isInt',
'defaultValue' => '1',
'type' => 'select', 'desc' => $translator->trans(
'Unless you are using a dedicated server, select "Low".'
) . '<br />' .
$translator->trans(
'A high value can cause the upgrade to fail if your server is not powerful enough to process the upgrade tasks in a short amount of time.'
),
'choices' => [
1 => $translator->trans('Low (recommended)'),
2 => $translator->trans('Medium'),
3 => $translator->trans('High'),
],
],
'PS_AUTOUP_CUSTOM_MOD_DESACT' => [
'title' => $translator->trans('Disable non-native modules'),
'cast' => 'intval',
Expand Down
10 changes: 0 additions & 10 deletions controllers/admin/AdminSelfUpgradeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,16 +216,6 @@ private function _setFields()
],
];
$this->_fieldsUpgradeOptions = [
'PS_AUTOUP_PERFORMANCE' => [
'title' => $this->trans('Server performance'),
'cast' => 'intval',
'validation' => 'isInt',
'defaultValue' => '1',
'type' => 'select',
'desc' => $this->trans('Unless you are using a dedicated server, select "Low".') . '<br />' .
$this->trans('A high value can cause the upgrade to fail if your server is not powerful enough to process the upgrade tasks in a short amount of time.'),
'choices' => [1 => $this->trans('Low (recommended)'), 2 => $this->trans('Medium'), 3 => $this->trans('High')],
],
'PS_AUTOUP_CUSTOM_MOD_DESACT' => [
'title' => $this->trans('Disable non-native modules'),
'cast' => 'intval',
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/AnalyticsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public function testProperties()
->setInstallVersion('8.8.808')
->setRestoreName('V1.2.3_blablabla-🐶');
$upgradeConfiguration = (new UpgradeConfiguration([
'PS_AUTOUP_PERFORMANCE' => 5,
'PS_AUTOUP_CUSTOM_MOD_DESACT' => 0,
'PS_AUTOUP_UPDATE_DEFAULT_THEME' => 1,
'PS_AUTOUP_CHANGE_DEFAULT_THEME' => 1,
Expand Down Expand Up @@ -93,7 +92,6 @@ public function testProperties()
'upgrade_channel' => 'major',
'backup_files_and_databases' => true,
'backup_images' => false,
'server_performance' => 4,
'disable_non_native_modules' => false,
'upgrade_default_theme' => true,
'switch_to_default_theme' => true,
Expand Down
1 change: 0 additions & 1 deletion tests/unit/Progress/CompletionCalculatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ private function getCompletionCalculator(bool $withBackup): CompletionCalculator
{
return new CompletionCalculator(
new UpgradeConfiguration([
'PS_AUTOUP_PERFORMANCE' => 5,
'PS_AUTOUP_CUSTOM_MOD_DESACT' => 0,
'PS_AUTOUP_UPDATE_DEFAULT_THEME' => 1,
'PS_AUTOUP_CHANGE_DEFAULT_THEME' => 1,
Expand Down

0 comments on commit 0bc86e3

Please sign in to comment.