Skip to content

Make the custom fields limit configurable (setting + filter) - #16

Open
Pichinov-Jose wants to merge 2 commits into
SplashSync:2.0from
Pichinov-Jose:feature/configurable-custom-fields-limit
Open

Pichinov-Jose wants to merge 2 commits into
SplashSync:2.0from
Pichinov-Jose:feature/configurable-custom-fields-limit

Conversation

@Pichinov-Jose

Copy link
Copy Markdown

Problem

CustomFields::MAX_FIELDS hard-caps the number of custom fields exposed per object type at 200. On sites that rely heavily on custom fields (ACF & similar), every field past the cap silently disappears from the schema — and any server-side mapping bound to those fields stops syncing, with no error and no way to raise the limit.

Real-world case: a production catalog with ~500 eligible fields lost 246 product fields (schema went from 499 to 253 exposed fields) after an update reset a locally raised limit.

Change

Default behaviour is unchanged (200). The limit becomes configurable:

  • CustomFields::getLimit() reads the new Custom Fields Limit setting (option splash_custom_fields_limit), passes it through a splash_custom_fields_limit filter, and falls back to MAX_FIELDS;
  • the custom fields parser (Post/CustomTrait) and the settings page descriptions use the effective limit;
  • a number field is added to the Products section of the settings page (the admin API already supports it).

Sizing notes

Measured on the catalog above with the limit raised to 1200: the Product schema (499 fields) builds in under 400 ms for a ~300 KB serialized schema — comfortably within webservice limits. The default stays low on purpose; the setting simply lets a site opt in to what its own catalog needs.

🤖 Generated with Claude Code

Pichinov-Jose and others added 2 commits September 5, 2026 21:20
The number of custom fields exposed per object type is capped by the
hard-coded CustomFields::MAX_FIELDS = 200. Sites relying heavily on
custom fields (ACF & similar) silently lose every field past the cap:
the fields disappear from the schema and any mapping bound to them
stops syncing, with nothing to raise the limit.

Keep 200 as the default and make the limit configurable:

- CustomFields::getLimit() reads the new "Custom Fields Limit" setting
  (option splash_custom_fields_limit) and passes it through a
  splash_custom_fields_limit filter, falling back to MAX_FIELDS;
- the custom fields parser and the settings page descriptions use the
  effective limit instead of the constant.

Measured on a live catalog with ~500 eligible fields: schema builds in
under 400 ms with a limit of 1200, for a ~300 KB serialized schema.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
WordPress get_meta_keys() scans the whole postmeta table, so every
object type was offered every meta of the site: order metas showed up
as Product custom fields, and meta keys with invalid identifiers
(spaces) triggered schema warnings on unrelated objects.

Restrict discovery to the metas actually attached to the object's post
type — 'product' also includes its variations. Objects without a known
post type keep the legacy site-wide behaviour.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Pichinov-Jose

Copy link
Copy Markdown
Author

Added a second commit (ffd114b): custom fields discovery is now scoped to the object's own post type. Core get_meta_keys() scans the whole postmeta table, so every object type was offered every meta of the site — order metas showed up as Product custom fields, and meta keys with invalid identifiers (e.g. legacy PayPal metas with spaces) triggered schema warnings on unrelated objects. product also includes its variations; objects without a known post type keep the legacy site-wide behaviour.

@Pichinov-Jose
Pichinov-Jose marked this pull request as ready for review September 8, 2026 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant