Site is updated to Bricks 1.9 and the latest Metabox AIO version.
On my production site I have 2 different Metabox Relationship queries. Both have stopped working and return no data in the Bricks Editor or on the frontend. They were working maybe 2 weeks or so ago for sure but I am not sure when they stopped working (or what Bricks version it was).
One of the relationship queries is for a FAQ CPT related to a Services CPT.
The relationships are visible and can be edited when I edit the Service CPT in the WordPress Admin. So Metabox has no problems with them.
I have cleared the cache repeatedly and disabled it and it still doesn’t work.
Using the Query Monitor plugin I looked for queries executed on the page for the FAQ CPT (called ess_faqs). I found this one:
SELECT wp_posts.ID
FROM wp_posts
INNER JOIN wp_mb_relationships AS mbr
ON (mbr.to = wp_posts.ID
AND mbr.type = 'services-faq'
AND mbr.from IN (962))
WHERE 1=1
AND ((wp_posts.post_type = 'ess_faqs'
AND (wp_posts.post_status = 'publish'
OR wp_posts.post_status = 'private')))
GROUP BY `mbr_services-faq_from`, wp_posts.ID
ORDER BY mbr.order_from
If you look at the query you can see that it will fail since the Group By has a field in it mbr_services-faq_from
that does not exist in the SELECT.
The funny thing is I have a development site with virtually the same website. It has the same Bricks and Metabox data and versions. This site works. When I enable the Query Monitor Plugin on it and view the queries they are slightly different.
SELECT wp_posts.* , mbr.from AS `mbr_services-faq_from`
FROM wp_posts
INNER JOIN wp_mb_relationships AS mbr
ON (mbr.to = wp_posts.ID
AND mbr.type = 'services-faq'
AND mbr.from IN (962))
WHERE 1=1
AND ((wp_posts.post_type = 'ess_faqs'
AND (wp_posts.post_status = 'publish'
OR wp_posts.post_status = 'private')))
GROUP BY `mbr_services-faq_from`, wp_posts.ID
ORDER BY mbr.order_from
As you can see there are more fields in the SELECT which allows the GROUP BY to work and the query to execute properly.
What would cause Bricks on the production site to produce slightly different queries that would fail to execute?
Also the other relationship query I have on the site is on a different page and use different CPTs. It has the same SQL statement issue where some fields are missing from the SELECT statement and results in no records being returned.
Thanks