Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/storage layer optimization #662

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 0 additions & 38 deletions includes/entities/class-fs-affiliate-terms.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,6 @@ class FS_AffiliateTerms extends FS_Scope_Entity {
* @var string Enum: `affiliation` or `rewards`. Defaults to `affiliation`.
*/
public $type;
/**
* @var string Enum: `payout` or `credit`. Defaults to `payout`.
*/
public $reward_type;
/**
* If `first`, the referral will be attributed to the first visited source containing the affiliation link that
* was clicked.
*
* @var string Enum: `first` or `last`. Defaults to `first`.
*/
public $referral_attribution;
/**
* @var int Defaults to `30`, `0` for session cookie, and `null` for endless cookie (until cookies are cleaned).
*/
Expand All @@ -51,39 +40,12 @@ class FS_AffiliateTerms extends FS_Scope_Entity {
* the initial upgrade/purchase.
*/
public $commission_renewals_days;
/**
* @var int Only cents and no percentage. In US cents, e.g.: 100 = $1.00. Defaults to `null`.
*/
public $install_commission;
/**
* @var string Required default target link, e.g.: pricing page.
*/
public $default_url;
/**
* @var string One of the following: 'all', 'new_customer', 'new_user'.
* If 'all' - reward for any user type.
* If 'new_customer' - reward only for new customers.
* If 'new_user' - reward only for new users.
*/
public $reward_customer_type;
/**
* @var int Defaults to `0` (affiliate only on directly affiliated links). `null` if an affiliate will get
* paid for all customers' lifetime payments. If greater than `0`, an affiliate will get paid for all
* customer payments for `future_payments_days` days after the initial payment.
*/
public $future_payments_days;
/**
* @var bool If `true`, allow referrals from social sites.
*/
public $is_social_allowed;
/**
* @var bool If `true`, allow conversions without HTTP referrer header at all.
*/
public $is_app_allowed;
/**
* @var bool If `true`, allow referrals from any site.
*/
public $is_any_site_allowed;
/**
* @var string $plugin_title Title of the plugin. This is used in case we are showing affiliate form for a Bundle instead of the `plugin` in context.
*/
Expand Down
14 changes: 1 addition & 13 deletions includes/entities/class-fs-billing.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ class FS_Billing extends FS_Entity {

#region Properties

/**
* @var int
*/
public $entity_id;
/**
* @var string (Enum) Linked entity type. One of: developer, plugin, user, install
*/
public $entity_type;
/**
* @var string
*/
Expand Down Expand Up @@ -62,10 +54,6 @@ class FS_Billing extends FS_Entity {
* @var string
*/
public $address_city;
/**
* @var string
*/
public $address_country;
/**
* @var string Two chars country code.
*/
Expand All @@ -75,7 +63,7 @@ class FS_Billing extends FS_Entity {
*/
public $address_state;
/**
* @var number Numeric ZIP code (cab be with leading zeros).
* @var number Numeric ZIP code (can be with leading zeros).
*/
public $address_zip;

Expand Down
51 changes: 49 additions & 2 deletions includes/entities/class-fs-entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function fs_get_object_public_vars( $object ) {
return get_object_vars( $object );
}

class FS_Entity {
class FS_Entity implements Serializable {
/**
* @var number
*/
Expand Down Expand Up @@ -156,4 +156,51 @@ static function is_valid_id($id){
public static function get_class_name() {
return get_called_class();
}
}

#--------------------------------------------------------------------------------
#region Serializable
#--------------------------------------------------------------------------------

/**
* @inheritDoc
*/
public function serialize() {
$entity = fs_get_object_public_vars( $this );

$compressed = new stdClass();
foreach ( $entity as $p => $v ) {
if ( ! is_null( $v ) ) {
$compressed->{$p} = $v;
}
}

return json_encode( $compressed );
}

/**
* @inheritDoc
*/
public function unserialize( $data ) {
if ( is_serialized( $data ) ) {
// Backward compatibility.
return unserialize( $data );
}

$class_name = get_called_class();
$entity = new $class_name();

$compressed = json_decode( $data, true );

if ( ! empty( $compressed ) ) {
foreach ( $compressed as $p => $v ) {
if ( property_exists( $entity, $p ) ) {
$entity->{$p} = $v;
}
}
}

return $entity;
}

#endregion
}
26 changes: 0 additions & 26 deletions includes/entities/class-fs-payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ class FS_Payment extends FS_Entity {
* @var number
*/
public $install_id;
/**
* @var number
*/
public $subscription_id;
/**
* @var number
*/
Expand All @@ -53,28 +49,6 @@ class FS_Payment extends FS_Entity {
* @var number
*/
public $bound_payment_id;
/**
* @var string
*/
public $external_id;
/**
* @var string
*/
public $gateway;
/**
* @var string ISO 3166-1 alpha-2 - two-letter country code.
*
* @link http://www.wikiwand.com/en/ISO_3166-1_alpha-2
*/
public $country_code;
/**
* @var string
*/
public $vat_id;
/**
* @var float Actual Tax / VAT in $$$
*/
public $vat;
/**
* @var int Payment source.
*/
Expand Down
7 changes: 0 additions & 7 deletions includes/entities/class-fs-plugin-license.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ class FS_Plugin_License extends FS_Entity {
* @var number
*/
public $plan_id;
/**
* @author Leo Fajardo (@leorw)
* @since 2.3.0
*
* @var string
*/
public $parent_plan_name;
/**
* @author Leo Fajardo (@leorw)
* @since 2.3.0
Expand Down
12 changes: 0 additions & 12 deletions includes/entities/class-fs-plugin-plan.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ class FS_Plugin_Plan extends FS_Entity {
* @var string
*/
public $description;
/**
* @var bool Defaults to true. If true, allow unlimited localhost installs with the same license.
*/
public $is_free_localhost;
/**
* @var bool Defaults to true. If false, don't block features after license expiry - only block updates and
* support.
Expand All @@ -48,10 +44,6 @@ class FS_Plugin_Plan extends FS_Entity {
* @var int
*/
public $license_type;
/**
* @var bool
*/
public $is_https_support;
/**
* @var int Trial days.
*/
Expand Down Expand Up @@ -84,10 +76,6 @@ class FS_Plugin_Plan extends FS_Entity {
* @var bool Is personal success manager supported with the plan.
*/
public $is_success_manager;
/**
* @var bool Is featured plan.
*/
public $is_featured;

#endregion Properties

Expand Down
8 changes: 0 additions & 8 deletions includes/entities/class-fs-plugin-tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,6 @@ class FS_Plugin_Tag extends FS_Entity {
* @var string
*/
public $tested_up_to_version;
/**
* @var bool
*/
public $has_free;
/**
* @var bool
*/
public $has_premium;
/**
* @var string One of the following: `pending`, `beta`, `unreleased`.
*/
Expand Down
32 changes: 0 additions & 32 deletions includes/entities/class-fs-subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,10 @@ class FS_Subscription extends FS_Entity {
* @var number
*/
public $license_id;
/**
* @var float
*/
public $total_gross;
/**
* @var float
*/
public $amount_per_cycle;
/**
* @var int # of months
*/
public $billing_cycle;
/**
* @var float
*/
public $outstanding_balance;
/**
* @var int
*/
public $failed_payments;
/**
* @var string
*/
public $gateway;
/**
* @var string
*/
public $external_id;
/**
* @var string|null
*/
Expand All @@ -72,14 +48,6 @@ class FS_Subscription extends FS_Entity {
* @var string|null Datetime of the cancellation.
*/
public $canceled_at;
/**
* @var string|null
*/
public $vat_id;
/**
* @var string Two characters country code
*/
public $country_code;

#endregion Properties

Expand Down
8 changes: 0 additions & 8 deletions includes/entities/class-fs-user.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ class FS_User extends FS_Scope_Entity {
* @var bool
*/
public $is_verified;
/**
* @var string|null
*/
public $customer_id;
/**
* @var float
*/
public $gross;

#endregion Properties

Expand Down