From 4a150d4cca6f76ddbf419e58a80e807255623402 Mon Sep 17 00:00:00 2001 From: Daniele Alessandra Date: Wed, 22 Oct 2025 13:13:00 +0200 Subject: [PATCH 1/2] Added serialize and unseralize magic functions to user class for PHP 8.5+ compatibility --- includes/entities/class-fs-user.php | 52 +++++++++++++++++++++++++++++ start.php | 2 +- 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/includes/entities/class-fs-user.php b/includes/entities/class-fs-user.php index 3aed0982..679acbda 100755 --- a/includes/entities/class-fs-user.php +++ b/includes/entities/class-fs-user.php @@ -61,6 +61,58 @@ function __wakeup() { } } + + /** + * Prepare object data for serialization. + * Only includes explicitly declared properties. + * + * @return array Serialized data + */ + public function __serialize() + { + // Only serialize properties declared in this class. + $props = array('email', 'first', 'last', 'is_verified', 'customer_id', 'gross'); + $out = array(); + foreach ($props as $p) + { + if (property_exists($this, $p)) + $out[$p] = $this->$p; + + } + + return $out; + } + + /** + * Restore object state from serialized data. + * Safely populates known properties only. + * + * @param array $data Serialized data + * + * @return void + */ + public function __unserialize(array $data) + { + // Populate only known properties for forward-compat and safety. + if (array_key_exists('email', $data)) + $this->email = $data['email']; + + if (array_key_exists('first', $data)) + $this->first = $data['first']; + + if (array_key_exists('last', $data)) + $this->last = $data['last']; + + if (array_key_exists('is_verified', $data)) + $this->is_verified = (bool) $data['is_verified']; + + if (array_key_exists('customer_id', $data)) + $this->customer_id = $data['customer_id']; + + if (array_key_exists('gross', $data)) + $this->gross = (float) $data['gross']; + } + function get_name() { return trim( ucfirst( trim( is_string( $this->first ) ? $this->first : '' ) ) . ' ' . ucfirst( trim( is_string( $this->last ) ? $this->last : '' ) ) ); } diff --git a/start.php b/start.php index 0e31f206..82163897 100644 --- a/start.php +++ b/start.php @@ -15,7 +15,7 @@ * * @var string */ - $this_sdk_version = '2.12.2.1'; + $this_sdk_version = '2.12.2.2'; #region SDK Selection Logic -------------------------------------------------------------------- From 153b705c85b8cfbfd71a34f2a0617187d170a8a4 Mon Sep 17 00:00:00 2001 From: Daniele Alessandra Date: Wed, 22 Oct 2025 13:59:45 +0200 Subject: [PATCH 2/2] Intentionally exclude __serialize and __unserialize warnings from PHPCompatibility checks, since these methods are officially supported as of PHP 7.4. The SDK keeps __sleep / __wakeup for legacy compatibility, so the exclusion is deliberate and safe. --- phpcs.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/phpcs.xml b/phpcs.xml index 35f2ef84..ff6f7cd7 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -95,7 +95,10 @@ - + + + +