Bug report: empty group-read meta return false incorrectly
-
Hi!
I’ve been researching why a customers newly imported products (WooCommerce) would not show up for guest visitors. After digging through the code I found the issue.
In
get_read_group_ids()
inclass-groups-post-access.php
on row 650 you fetch the groups-read meta. However you fetch it as an array (third parameter defaults to false) which means that even if the meta_value is empty it’ll return an array with an empty [0] key. You then do a check on row 695if ( empty( $group_ids ) ) {
which will in that case falsely fail because it’s not empty…
So the solution here would be to either make sure you set the third parameter to true and make sure the value is always an array if it’s not empty/falsy OR improve that if statement to also accommodate for the above situation.For now I worked around it by SQL deleting all empty group-read values. But should we do another import the same thing will happen again.
P.S: For future compatibility with WC I recommend you look into using the CRUD functions for working with products ?? https://github.com/woocommerce/woocommerce/wiki/CRUD-Objects-in-3.0
- The topic ‘Bug report: empty group-read meta return false incorrectly’ is closed to new replies.