mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
🔒️ Enforce the “do not update” rule
Per definition, an installation path cannot be changed after it’s set. This change enforces the rule on the lowest level
This commit is contained in:
parent
afbc79c0c5
commit
35d8233e06
1 changed files with 15 additions and 2 deletions
|
@ -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
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function set_installation_path( string $installation_path ) : 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;
|
$this->data['installation_path'] = $installation_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue