From 35d8233e061b07d95e3eb76ee17ec73f1d365e52 Mon Sep 17 00:00:00 2001 From: Philipp Stracker Date: Fri, 21 Mar 2025 18:02:51 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=92=EF=B8=8F=20Enforce=20the=20?= =?UTF-8?q?=E2=80=9Cdo=20not=20update=E2=80=9D=20rule?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per definition, an installation path cannot be changed after it’s set. This change enforces the rule on the lowest level --- .../ppcp-settings/src/Data/GeneralSettings.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/modules/ppcp-settings/src/Data/GeneralSettings.php b/modules/ppcp-settings/src/Data/GeneralSettings.php index 372a4db2f..1f4649f2c 100644 --- a/modules/ppcp-settings/src/Data/GeneralSettings.php +++ b/modules/ppcp-settings/src/Data/GeneralSettings.php @@ -267,13 +267,26 @@ class GeneralSettings extends AbstractDataModel { } /** - * Sets the branded experience installation path. + * Sets the installation path. This function will only set the installation + * path a single time and ignore subsequent calls. * - * @param string $installation_path The branded experience installation path. + * Short: The installation path cannot be updated once it's defined. + * + * @param string $installation_path The installation path. * * @return void */ public function set_installation_path( string $installation_path ) : void { + // The installation path can be set only once. + if ( InstallationPathEnum::is_valid( $this->data['installation_path'] ?? '' ) ) { + return; + } + + // Ignore invalid installation paths. + if ( ! $installation_path || ! InstallationPathEnum::is_valid( $installation_path ) ) { + return; + } + $this->data['installation_path'] = $installation_path; }