WP and Woo w/ HPOS are recent versions. Running PHP 7.4
(1) Do you have an answer for why WP/WOO's maybe_serialize doesn't start with the a: ... serialized data as described, above? Instead, it's 2 sets of serialized data, not one.
I used maybe_serialize([array here]) and the actual data in the database start with
s:214"
and ends with
";
The actual serialized data are in between. (Note: The "214" depends on the size of the array keys and values).
If I used PHP's serialize command before sending it to the database, actual serialized data are stored as you described without the starting s:214" and ending ";
Why is that?
In an external program needing the data, if I send the serialized data through PHP's unserialize, it won't unserialize. (Try it at unserialize.com). It has to be done a second time (taking up unnecessary resources and knowledge that it's double-serialized. Future programmers may not be aware of that.).
(2) In the above example, the serialized data are $order->update_meta_data('item_shipping_data', $data_serialized);
QUESTION Do I really need to serialize or maybe_serialize the data before running $order->update_meta_data()?
QUESTION for reading the data - does WP/Woo automatically unserialize it using $order->get_meta('meta_key_here');
(3) One step further, using PHP's serialize, In WP/Woo how would I add $mysqli->real_escape_string() to cleanse the serialized data for the database in WP/Woo to avoid the double serializing? This question is for other places we may need to store serialized data other than $order->update_meta_data().
Thank you for your thoughtful answers!