Skip to content

fix(search): resolve every schema's real register in cross-schema unified search#2019

Open
MWest2020 wants to merge 2 commits into
fix/cross-schema-search-column-in-limitsfrom
feat/unified-search-register-resolution
Open

fix(search): resolve every schema's real register in cross-schema unified search#2019
MWest2020 wants to merge 2 commits into
fix/cross-schema-search-column-in-limitsfrom
feat/unified-search-register-resolution

Conversation

@MWest2020

Copy link
Copy Markdown
Member

Heropend na de migratie van Codeberg naar GitHub (2026-07-14).
Origineel, met review-historie: https://codeberg.org/Conduction/openregister/pulls/234

…fied search

Completes the unified-search fix begun in #233. Even with the column/IN-limit
crashes gone, OpenRegister objects still never appeared in Nextcloud's top-bar
search. Two stacked causes:

1. ROOT CAUSE — ObjectService::searchObjectsPaginated auto-injected
   `_register = currentRegister` into every query. For a cross-schema search
   (the unified-search provider passes a `@self.schema` array and no register)
   this scoped the WHOLE search to one ambient register, so objects in every
   other register were invisible. Now the auto-inject is skipped whenever the
   query is multi-schema (`@self.schema` array / `_schemas` / `@self.schemas`).

2. MagicMapper::searchObjectsPaginatedMultiSchema built its schema->register
   map via registerMapper::findAll, which applies an organisation filter that
   collapsed the candidate set to a single register. It now builds the map from
   a DIRECT query over all registers and loads matched register entities lazily
   via find(_multitenancy:false, _rbac:false), so each searched schema is paired
   with its REAL owning register (correct magic table). Schema-membership
   parsing is extracted to extractSchemaIds() with list-vs-id-keyed-map handling.

Verified live: searching "Rex" now returns the pet OBJECT (register 2411 /
schema 4309) alongside its file and calendar event, over ~1000 searchable
schemas, with no 54011 / 1000-IN errors.

Magic tables only — no secondary index; Solr/Elasticsearch stay deprecated for
unified search (docs/features/search-and-faceting.md updated).

Quality: phpcs/phpstan/psalm clean on changed files (baseline counts adjusted
for the env-independent find() named-arg pattern); unit tests for
extractSchemaIds. Batching (opsx §2) deferred as hardening — the single union
now works at scale.
OpenRegister object results in Nextcloud's top-bar search showed no icon
(the deep-link fallback `icon-openregister` is a CSS class the search
dropdown does not render). Schemas already carry an `icon` field (an MDI
name); this surfaces it.

- MdiIconRenderer: renders a curated set of @mdi/js glyphs (the pet-store
  sample icons + common entity icons) to a standalone SVG / data URI.
- IconController + route GET /api/icon/mdi/{name}: serves the glyph as a
  same-origin SVG image (public, cacheable). Nextcloud search only paints a
  thumbnail from a real URL, so the icon is passed as the entry thumbnail.
- ObjectsProvider: when a schema has an icon, use it (square glyph) ahead of
  the generic app icon; resolve schema/register display metadata with
  _multitenancy/_rbac bypassed so a result whose schema lives in another
  organisation still resolves its real name + icon instead of falling back
  to the bare numeric id.

Verified live: searching "Rex" returns the pet with its Dog glyph and the
"· Pet" schema label. phpcs/phpstan/psalm clean on changed files; unit test
for MdiIconRenderer (normalisation, svg/dataUri, unknown→null).
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.

2 participants