Skip to content

Add View namespace and storage layer#657

Merged
JeroenDeDauw merged 1 commit intomasterfrom
view-namespace-storage
Mar 14, 2026
Merged

Add View namespace and storage layer#657
JeroenDeDauw merged 1 commit intomasterfrom
view-namespace-storage

Conversation

@alistair3149
Copy link
Member

@alistair3149 alistair3149 commented Mar 6, 2026

Went through the browser steps manually and automatically.

Result of extensive back and forth with @alistair3149.
Context: the NeoWiki codebase, ADR 018 (Views), and the View domain model from PR #655.
Written by Claude Code, Opus 4.6

Summary

  • Register View namespace (7476) with NeoWikiView content model and neowiki-view-edit permission
  • Add ViewContent / ViewContentHandler (extends JsonContentHandler, shows JSON on View pages)
  • Add JSON Schema validation for View content (ViewContentValidator) with edit-time rejection
  • Add ViewPersistenceDeserializer to convert stored JSON into domain View objects
  • Add ViewLookup interface and WikiPageViewLookup implementation
  • Register talk namespaces for both Schema (7475) and View (7477) to fix PageAssertionException on delete actions
  • Wire up hooks: onEditFilter, onContentModelCanBeUsedOn, onCodeEditorGetPageLanguage

Test plan

  • PHPStan clean
  • PHPCS clean
  • ViewContentValidatorTest (10 tests) passes
  • ViewPersistenceDeserializerTest (3 tests) passes
  • Browser tested: saving valid View JSON succeeds, invalid JSON ({}) rejected with error
  • Browser tested: View page displays JSON content in table format
  • Browser tested: delete action works (no more PageAssertionException)

🤖 Generated with Claude Code

Introduces the storage infrastructure for Views (ADR 18):

- View namespace (NS_NEOWIKI_VIEW = 7476) with neowiki-view-edit permission
- ViewContent and ViewContentHandler for JSON storage
- viewContentSchema.json and ViewContentValidator for edit-time validation
- ViewPersistenceDeserializer to convert stored JSON into domain objects
- ViewLookup interface and WikiPageViewLookup implementation
- Edit validation hook for the View namespace

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
$namespaceNames['en'] = [
NeoWikiExtension::NS_SCHEMA => 'Schema'
NeoWikiExtension::NS_SCHEMA => 'Schema',
NeoWikiExtension::NS_SCHEMA + 1 => 'Schema_talk',
Copy link
Member Author

Choose a reason for hiding this comment

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

Technically out of scope of this PR, but might as well fix it altogether.
Previously, deleting a schema page will throw an exception because of the lack of talk namespace,


$contentValidator = ViewContentValidator::newInstance();

if ( !$contentValidator->validate( $text ) ) {
Copy link
Member

Choose a reason for hiding this comment

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

$text can be null but validate requires string. Or is $text in practice never null?

Copy link
Member Author

@alistair3149 alistair3149 Mar 16, 2026

Choose a reason for hiding this comment

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

$text is ?string and validate() requires string, so this is a real type mismatch. The same issue exists in validateSchemaEdit (line 192) which predates this PR. In practice $text is likely never null in this hook.

@JeroenDeDauw JeroenDeDauw merged commit 8256320 into master Mar 14, 2026
6 checks passed
@JeroenDeDauw JeroenDeDauw deleted the view-namespace-storage branch March 14, 2026 22:57
alistair3149 added a commit that referenced this pull request Mar 16, 2026
The EditFilter hook provides $text as ?string, but the content
validators require string. Guard against null in onEditFilter
and narrow the parameter types of the private methods.

Follows-up to #657

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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