Skip to content

Provide revision content to PagePropertyProviderContext#982

Open
JeroenDeDauw wants to merge 2 commits into
masterfrom
provide-content-to-page-property-providers
Open

Provide revision content to PagePropertyProviderContext#982
JeroenDeDauw wants to merge 2 commits into
masterfrom
provide-content-to-page-property-providers

Conversation

@JeroenDeDauw

Copy link
Copy Markdown
Member

Result of back and forth with @JeroenDeDauw on the design direction.
Context: the NeoWiki codebase and the discussion on the issue.
Written by Claude Code, Fable 5

Fixes #979

PagePropertiesBuilder already loaded the revision's main slot content and parsed it to extract categories, but threw everything else away. Providers wanting to derive Page Properties from the content had to re-fetch and re-parse it themselves - and since the context carries no revision ID, they could only look up the latest revision of the page, which is redundant work and subtly racy.

The context now additionally exposes:

  • content - the serialized main slot content, e.g. the wikitext
  • contentModel - e.g. "wikitext"
  • parserProperties - the MediaWiki page properties recorded while parsing the content (e.g. "defaultsort", or values set by parser hooks via ParserOutput::setPageProperty)

Design notes:

  • The context is a Domain value object holding only scalars and arrays. Exposing RevisionRecord, Content, or ParserOutput directly would put MediaWiki core classes into the Domain layer and make provider tests heavyweight. The relevant data is flattened instead, following the approach already used for categories.
  • parserProperties covers the template-expansion-safe path: extensions whose parser hooks already record values during the parse can read them back in their provider instead of re-analyzing raw markup. The parse NeoWiki already performs for categories is reused, so no additional parse happens.
  • When the content is unavailable (e.g. suppressed), content and contentModel are empty strings and parserProperties is empty, matching the existing behavior of categories.

Note: content-derived properties refresh only when a new revision is stored, so values coming from transcluded templates can go stale - the same existing limitation as categories.

Fixes #979

PagePropertiesBuilder already loaded the revision's main slot content and
parsed it to extract categories, but threw everything else away. Providers
wanting to derive Page Properties from the content had to re-fetch and
re-parse it themselves - and since the context carries no revision ID, they
could only look up the latest revision of the page, which is redundant work
and subtly racy.

The context now additionally exposes:

* `content` - the serialized main slot content, e.g. the wikitext
* `contentModel` - e.g. "wikitext"
* `parserProperties` - the MediaWiki page properties recorded while parsing
  the content (e.g. "defaultsort", or values set by parser hooks via
  ParserOutput::setPageProperty)

Design notes:

* The context is a Domain value object holding only scalars and arrays.
  Exposing RevisionRecord, Content, or ParserOutput directly would put
  MediaWiki core classes into the Domain layer and make provider tests
  heavyweight. The relevant data is flattened instead, following the
  approach already used for `categories`.
* `parserProperties` covers the template-expansion-safe path: extensions
  whose parser hooks already record values during the parse can read them
  back in their provider instead of re-analyzing raw markup. The parse
  NeoWiki already performs for categories is reused, so no additional parse
  happens.
* When the content is unavailable (e.g. suppressed), `content` and
  `contentModel` are empty strings and `parserProperties` is empty,
  matching the existing behavior of `categories`.

Note: content-derived properties refresh only when a new revision is
stored, so values coming from transcluded templates can go stale - the same
existing limitation as categories.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@JeroenDeDauw JeroenDeDauw marked this pull request as ready for review July 3, 2026 17:06
@JeroenDeDauw JeroenDeDauw requested a review from osnard July 3, 2026 17:07
Follow-up polish on the extending.md guidance for the new context fields:
recommend deriving Page Properties from the robust parse products
(categories, parserProperties) and frame raw content/contentModel as the
escape hatch for custom, non-wikitext content models rather than the default.
Also carries the "parserProperties is a parse input, not the NeoWiki Page
Properties you return" disambiguation into the docs, where provider authors
actually read it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
public string $lastEditor,
public string $content,
public string $contentModel,
public array $parserProperties,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@osnard unsure if this is sufficient for your use cases and which of those you actually need? Perhaps just parserProperties?

@JeroenDeDauw JeroenDeDauw added the BlueSpice Capabilities specific to, or particularly relevant for, BlueSpice label Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BlueSpice Capabilities specific to, or particularly relevant for, BlueSpice

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide revision content to PagePropertyProviderContext

1 participant