There are JSON functions: https://dev.mysql.com/doc/refman/8.3/en/json-search-functions.html can be used to search in complex data with MySQL. In the case of meta keys and values it is an issue that with too many keys the database becomes bloated, so better to store the values in an associative array and use only a single key. Currently this array is PHP serialized. Since MySQL does not support PHP unserialization and searching this makes developer's life pretty hard, which leads to hacks like this. https://www.youtube.com/watch?v=jUjjAYpkiKg I thought that maybe we could use JSON serialization format and the built-in MySQL JSON functions to search and sort this kind of associative arrays. Is this implemented in Wordpress atm? If not, then what do you suggest, how to implement it in theory?
-
1WordPress core doesn't currently implement JSON serialization for meta values. So the custom way is to modify database schema yourself, migration of current data (if any) to JSON format schema, and change the WP core or add filters to modify queries to match your updated schema. This needs time and attention.– Aqsa J.Commented Apr 7 at 3:54
-
@AqsaJ. I might open a feature request for it. Thanks!– inf3rnoCommented Apr 7 at 9:25
-
core.trac.wordpress.org/ticket/60950#ticket– inf3rnoCommented Apr 7 at 9:44
-
1Following that now.– Aqsa J.Commented Apr 7 at 10:29
Add a comment
|
1 Answer
Currently this is not supported, but I added a feature request ticket which you can support here: https://core.trac.wordpress.org/ticket/60950#ticket