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

Store less data in post meta #217

Closed
remcotolsma opened this issue Sep 30, 2021 · 5 comments
Closed

Store less data in post meta #217

remcotolsma opened this issue Sep 30, 2021 · 5 comments

Comments

@remcotolsma
Copy link
Member

remcotolsma commented Sep 30, 2021

@rvdsteege made a overview of meta usage:
https://docs.google.com/spreadsheets/d/1CJHnHcr9s8lkh4Fq9HQmlAThCK69eXiTC3UktyeQKYw/edit?usp=sharing

Pronamic Pay meta

Payments

select p.ID, p.post_title, m.meta_key, m.meta_value from wp_posts as `p` left join wp_postmeta as `m` ON m.post_id = p.ID where p.post_type=‘pronamic_payment’ and m.meta_key LIKE ‘_pronamic%’ group by m.meta_key order by m.meta_key ASC
Key In JSON In post meta
_pronamic_payment_action_url
_pronamic_payment_address
_pronamic_payment_adyen_details_result
_pronamic_payment_adyen_payment_response
_pronamic_payment_adyen_sdk_version
_pronamic_payment_amount
_pronamic_payment_city
_pronamic_payment_config_id
_pronamic_payment_consumer_account_number
_pronamic_payment_consumer_bic
_pronamic_payment_consumer_iban
_pronamic_payment_consumer_name
_pronamic_payment_country
_pronamic_payment_currency
_pronamic_payment_customer_name
_pronamic_payment_description
_pronamic_payment_email
_pronamic_payment_end_date ✅ (also through periods)
_pronamic_payment_entrance_code
_pronamic_payment_first_name
_pronamic_payment_issuer
_pronamic_payment_key
_pronamic_payment_language
_pronamic_payment_last_name
_pronamic_payment_locale
_pronamic_payment_method
_pronamic_payment_mollie_change_payment_state_url
_pronamic_payment_mollie_customer_id
_pronamic_payment_omnikassa_2_merchant_order_id
_pronamic_payment_order_id
_pronamic_payment_recurring
_pronamic_payment_recurring_type
_pronamic_payment_source
_pronamic_payment_source_id
_pronamic_payment_start_date ✅ (also through periods)
_pronamic_payment_status
_pronamic_payment_subscription_id ✅ through periods
_pronamic_payment_telephone_number
_pronamic_payment_transaction_id
_pronamic_payment_user_agent
_pronamic_payment_user_ip
_pronamic_payment_version
_pronamic_payment_woocommerce_payment_method
_pronamic_payment_woocommerce_payment_method_title
_pronamic_payment_zip

Subscriptions

select p.ID, p.post_title, m.meta_key, m.meta_value from wp_posts as `p` left join wp_postmeta as `m` ON m.post_id = p.ID where p.post_type=‘pronamic_pay_subscr’ and m.meta_key LIKE ‘_pronamic%’ group by m.meta_key order by m.meta_key ASC
Key In JSON In post meta
_pronamic_subscription_amount ✅ through fases
_pronamic_subscription_config_id
_pronamic_subscription_currency ✅ through fases
_pronamic_subscription_customer_name
_pronamic_subscription_description
_pronamic_subscription_email
_pronamic_subscription_end_date
_pronamic_subscription_expiry_date
_pronamic_subscription_key
_pronamic_subscription_mollie_customer_id
_pronamic_subscription_mollie_mandate_id
_pronamic_subscription_next_payment
_pronamic_subscription_next_payment_delivery_date
_pronamic_subscription_payment_method
_pronamic_subscription_source
_pronamic_subscription_source_id
_pronamic_subscription_start_date ✅ through fases
_pronamic_subscription_status

#212 (comment)

@rvdsteege
Copy link
Member

Should we also remove some meta?

  • _pronamic_payment_entrance_code → only in use by iDEAL Advanced and Sisow gateways;
  • _pronamic_payment_key and _pronamic_subscription_key → could maybe be stored as post_password (until custom tables arrive), as WooCommerce also seems to be doing;
  • do we still need _pronamic_payment_start_date and _pronamic_payment_end_date, or retrieve these from associated period?

I assume we'll keep gateway and extension specific meta in post meta? Or introduce integrations or gateway and extension properties, which can be used for these types of meta?

Note: if we remove meta, some data might not end up in privacy data export, even though it is stored in the JSON. Should add some kind of export based on the payment/subscription object, as is the case with anonymisation.

@remcotolsma
Copy link
Member Author

remcotolsma commented Sep 30, 2021

I assume we'll keep gateway and extension specific meta in post meta? Or introduce integrations or gateway and extension properties, which can be used for these types of meta?

Yes, just a simple private $meta; property in Payment and Subscription with type array<string, mixed> via MetaTrait?

{
  "id":1,
  "status":"Open",
  "meta": {
    "entrance_code": "",
    "adyen_details_result": "",
    "adyen_payment_response": "",
    "adyen_sdk_version": "",
    "woocommerce_payment_method": "",
    "woocommerce_payment_method_title": "",
    "omnikassa_2_merchant_order_id": "",
    "mollie_customer_id": "",
    "mollie_change_payment_state_url": ""
}

@remcotolsma
Copy link
Member Author

I noticed we already have a $payment->get_meta( $key ) and $payment->set_meta( $key, $value ) talking directly to get_post_meta( ... ) and update_post_meta( ... ). We could use these existing functions to read/write the meta values from the object property private $meta with a fallback from post meta.

@remcotolsma
Copy link
Member Author

I think we've come a long way with this, I only noticed some unnecessary null meta values in a production environment:

Schermafbeelding 2021-11-03 om 11 41 57

@remcotolsma
Copy link
Member Author

think we've come a long way with this, I only noticed some unnecessary null meta values in a production environment:

Fixed in:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants