I am trying to: I searched for a Spanish speaking counselor who specializes in marriage and is located within a 25 mile radius of 33173. This search pulled 27 counselors with several counselors out of state.
Link to a page where the issue can be seen: hidden link
I expected to see: 1 counselor found in multiple locations
Instead, I got:
I have a view for searching and displaying the results with a map, and the
search includes a "within X miles of location". Most of the time, this works
fine. However, sometimes I've seen results that were far outside the location
range. I've been able to determine that when this happens, the URL the browser
requested was correct, including the relevant toolset_maps_distance_radius,
toolset_maps_distance_unit, and toolset_maps_distance_center parameters. When
I look at the javascript console, I can see the actual SQL query, and when it
fails, the SQL query does NOT include ST_Distance_Sphere in the where and order
by clauses. When it works, it's in both. Additionally, when it fails, "OR
wp_posts.post_status = 'private'" is added to the where clause, which I believe
would include any private posts, instead of only the published posts.
To be clear, here's a sample URL for both success and failure:
hidden link
This is the SQL query logged when it works:
wpv_filter_get_posts] SELECT wp_posts.* FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) LEFT JOIN wp_term_relationships AS tt1 ON (wp_posts.ID = tt1.object_id) INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id )
INNER JOIN wp_postmeta AS tmapsmeta ON ( wp_posts.ID = tmapsmeta.post_id )
LEFT JOIN wp_toolset_maps_address_cache ON wp_toolset_maps_address_cache.address_passed = tmapsmeta.meta_value
WHERE 1=1 AND (
wp_term_relationships.term_taxonomy_id IN (723)
AND
tt1.term_taxonomy_id IN (653)
) AND (
wp_postmeta.meta_key = 'wpcf-address'
) AND wp_posts.post_type = 'yyyy' AND ((wp_posts.post_status = 'publish'))
AND ST_Distance_Sphere(ST_PointFromText('POINT(-80.360297 25.7038331)'), wp_toolset_maps_address_cache.point) < 40233.6
GROUP BY wp_posts.ID ORDER BY ST_Distance_Sphere(ST_PointFromText('POINT(-80.360297 25.7038331)'), wp_toolset_maps_address_cache.point) ASC
This is the SQL query logged when it fails:
wpv_filter_get_posts] SELECT wp_posts.* FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) LEFT JOIN wp_term_relationships AS tt1 ON (wp_posts.ID = tt1.object_id) INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id )
INNER JOIN wp_postmeta AS tmapsmeta ON ( wp_posts.ID = tmapsmeta.post_id )
LEFT JOIN wp_toolset_maps_address_cache ON wp_toolset_maps_address_cache.address_passed = tmapsmeta.meta_value
WHERE 1=1 AND (
wp_term_relationships.term_taxonomy_id IN (723)
AND
tt1.term_taxonomy_id IN (653)
) AND (
wp_postmeta.meta_key = 'wpcf-address'
) AND wp_posts.post_type = 'yyyy' AND ((wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private'))
GROUP BY wp_posts.ID ORDER BY wp_postmeta.meta_value ASC
Please note I replaced some values with xxxx or yyyy, but they are exactly what
I expect and are the same for both failure and success cases.
Any ideas what might be causing this seemingly random failure? I haven't found
any customized code that attempts to change the query, so it appears to be a
bug in toolset?