Skip to content

Location fetch can be a PHP performance bottleneck #29

Description

@bfintal

get_values() for the post/page location rules loads every post/page:

// src/locations/class-location-post.php (also class-location-page.php)
$posts = get_posts( [
	'post_type' => $post_type->name,
	'posts_per_page' => -1,
	...
] );

Exposed via /interact/v1/get_location_rules/{type} and fired per LocationRule, on mount and on every param change, with no client caching/dedup:

// src/editor/components/location-rules/index.js
useEffect( () => {
	apiFetch( { path: `/interact/v1/get_location_rules/${ param }`, method: 'GET' } )...
}, [ param ] )
  • Multiple rules => multiple parallel unbounded queries + large payloads.
  • Scales badly with site size (thousands of posts).

Recommendation: cache/memoize responses client-side keyed by param

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions