Automattic / zoninator

Curation made easy! Create "zones" then add and order your content straight from the WordPress Dashboard.
https://wordpress.org/plugins/zoninator/
GNU General Public License v2.0
85 stars 50 forks source link

Serializes the description field after apply filters #68

Open sathyapulse opened 6 years ago

sathyapulse commented 6 years ago

The zoninator_insert_zone and zoninator_update_zone hook sends the serialized description data and it requires additional code to unserialize, add additional fields and serialize data again. The PR addresses the problem by serializing the data after the apply_filters hook so that we can make sure the data is serialized always.

philipjohn commented 6 years ago

Hi @sathyapulse, thanks for this.

Can you provide more detail about the issue this resolves please, including exact steps to reproduce?

sathyapulse commented 6 years ago

@philipjohn It doesn't solve any issues but improvement. It's just to avoid additional code from the developers end as well as make sure the data is serialised while saving to database.

Let's say we are extending the fields with the action hook zoninator_post_zone_fields in here. We need to include the new field values while inserting and updating the zone with the filter hooks here and here. The data is serialised before apply_filters in insert and update functions. In the add_filter, developers needs to unserialise data, insert the new field values, serialise data again and return. The new code will send the array to apply_filters and developers can directly insert the data and plugin will make sure the data is serialised.

I think it will not create any issues with the existing code of developers since the we are using maybe_serialize function.

GaryJones commented 2 months ago

I think it will not create any issues with the existing code of developers since the we are using maybe_serialize function.

I think you're right, but it still feels like this should be considered to have the potential to be a breaking change, and so would need to wait for a major release.