Skip to content

Conversation

@mboynes
Copy link
Contributor

@mboynes mboynes commented Oct 10, 2017

Replaces #617, props @david-binda

Copy link
Member

@dlh01 dlh01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The similar logic seems to suggest a shared method on Fieldmanager_Context_Storable might be useful, like sanitize_scalar_value(). Up to you, though.

protected function update_data( $post_id, $meta_key, $meta_value, $data_prev_value = '' ) {
// Meta is always stored as a string, so if this is a scalar value, cast
// it as a string to ensure that `update_metadata()` is able to correctly
// compare the current value against the previous value.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps should follow docs standards for inline comments: https://make.wordpress.org/core/handbook/best-practices/inline-documentation-standards/php/#5-2-multi-line-comments (applies throughout)?

*/
protected function update_data( $data_id, $option_name, $option_value, $option_prev_value = '' ) {
// Meta is always stored as a string, so if this is a scalar value, cast
// it as a string to ensure that `update_metadata()` is able to correctly
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be *_option() instead of _metadata, and the earlier reference to "Meta is" be "Options are"?

@mboynes
Copy link
Contributor Author

mboynes commented Oct 10, 2017

Thanks for the suggestion @dlh01. Not sure why I didn't consider that, it seems so obvious in retrospect. That also made it more testable, of course.

@mboynes mboynes merged commit 4519316 into master Oct 11, 2017
@renatonascalves renatonascalves deleted the feature/cast-meta-values-to-string branch February 21, 2019 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants