• Resolved Jonathandejong

    (@jonathandejong)


    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() in class-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 695 if ( 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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Kento

    (@proaktion)

    Hi,

    Thanks for reporting that, the fix you propose sounds correct – I’ll have a further look and include a fix.

    Cheers

    Plugin Author Kento

    (@proaktion)

    I’ve checked this and this is not an issue with Groups but with inconsistencies introduced by creating invalid entries in the postmeta table, either by inserting null entries for groups-read or invalid group IDs.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Bug report: empty group-read meta return false incorrectly’ is closed to new replies.