Skip to content

Commit

Permalink
[user-entity] [site-entity] [plugin-plan-entity] Fix PHP 8.2 deprecat…
Browse files Browse the repository at this point in the history
…ion warning adding missing property to FS_Site class and using magic functions in FS_User class. FS_Plugin_Plan has been fixed in June.
  • Loading branch information
DanieleAlessandra committed Nov 11, 2024
1 parent b76f277 commit 5a9deef
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
1 change: 0 additions & 1 deletion includes/entities/class-fs-plugin-plan.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
/**
* Class FS_Plugin_Plan
*
* @property FS_Pricing[] $pricing
*/
class FS_Plugin_Plan extends FS_Entity {

Expand Down
8 changes: 4 additions & 4 deletions includes/entities/class-fs-site.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
exit;
}

/**
* @property int $blog_id
*/
#[AllowDynamicProperties]
class FS_Site extends FS_Scope_Entity {
/**
* @var number
*/
public $site_id;
/**
* @var number
*/
public $blog_id;
/**
* @var number
*/
Expand Down
28 changes: 28 additions & 0 deletions includes/entities/class-fs-user.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,34 @@ function __construct( $user = false ) {
parent::__construct( $user );
}

/**
* @return void
*
* This function removes the deprecated 'is_beta' property from the serialized data.
* Should clean up the serialized data to avoid PHP 8.2 warning on next execution.
*/
public function __wakeup() {
if ( isset($this->is_beta) ) {
// If we enter here, and we are running PHP 8.2, we already had the warning. But we sanitize data for next execution.
unset( $this->is_beta );
}
}

/**
* @param $pDeserializedArray
* @return void
*
* This function is used to unserialize the object to avoid the PHP 8.2 warning.
* Does not work with private properties, but there are no private properties in this class.
*/
public function __unserialize( $pDeserializedArray ) {
foreach ( $pDeserializedArray as $key => $value ) {
if ( property_exists( $this, $key ) ) {
$this->{$key} = $value;
}
}
}

function get_name() {
return trim( ucfirst( trim( is_string( $this->first ) ? $this->first : '' ) ) . ' ' . ucfirst( trim( is_string( $this->last ) ? $this->last : '' ) ) );
}
Expand Down
2 changes: 1 addition & 1 deletion start.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* @var string
*/
$this_sdk_version = '2.9.0';
$this_sdk_version = '2.9.1';

#region SDK Selection Logic --------------------------------------------------------------------

Expand Down

0 comments on commit 5a9deef

Please sign in to comment.