From dd1187198391f9645ac6636c82cb49577ccca6b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9stor=20Soriano?= Date: Wed, 13 Nov 2024 16:24:58 +0100 Subject: [PATCH] Remove trigger_error from WooCommerce::__set (#52764) --- plugins/woocommerce/changelog/pr-52764 | 4 ++++ plugins/woocommerce/includes/class-woocommerce.php | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 plugins/woocommerce/changelog/pr-52764 diff --git a/plugins/woocommerce/changelog/pr-52764 b/plugins/woocommerce/changelog/pr-52764 new file mode 100644 index 00000000000..07b45a50a1f --- /dev/null +++ b/plugins/woocommerce/changelog/pr-52764 @@ -0,0 +1,4 @@ +Significance: patch +Type: tweak + +Replace trigger_error in WooCommerce::__set with an exception diff --git a/plugins/woocommerce/includes/class-woocommerce.php b/plugins/woocommerce/includes/class-woocommerce.php index 123b3467f61..cef65939ca4 100644 --- a/plugins/woocommerce/includes/class-woocommerce.php +++ b/plugins/woocommerce/includes/class-woocommerce.php @@ -209,13 +209,13 @@ final class WooCommerce { * * @param string $key Property name. * @param mixed $value Property value. + * @throws Exception Attempt to access a property that's private or protected. */ public function __set( string $key, $value ) { if ( 'api' === $key ) { $this->api = $value; } elseif ( property_exists( $this, $key ) ) { - // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error - trigger_error( 'Cannot access private property WooCommerce::$' . esc_html( $key ), E_USER_ERROR ); + throw new Exception( 'Cannot access private property ' . __CLASS__ . '::$' . esc_html( $key ) ); } else { $this->$key = $value; }