Open pablinos opened 2 years ago
Thanks for this!
I think it's fine if things are not super performant, This is meant to run test suites so a little bit of overload is accepted (as we are removing a lot of overload by not having a database!).
Do you think you could write some tests for this? And then, from there, we can look at the best implementation
While testing some code that was setting post metadata, I was debugging it by outputting all the metadata for a post with a call to
get_post_meta( $post_id )
. I noticed that the tests started passing but I was still getting an empty array from theget_post_meta
call.Getting a specific key was working, which led me to look at the Metadata code here, which currently doesn't deal with the case of the key being an empty value.
This change refactors the
get
function, but is probably not optimal, as we change the shape of the object's metadata usingarray_reduce
on each call. It illustrates the issue, and I'm happy to optimise it if we want to go this route.