Revision policy
Choose which revision of a page NeoWiki publishes: to the graph stores; the RDF export; the Subject reads GET /neowiki/v0/subject/{subjectId}, .../referencingSubjects and GET /neowiki/v0/recently-edited-subjects; the Subject list, relation-target suggestions and Subject counts; and its own Schema, Layout, Mapping and configuration reads. Without a policy every page publishes its latest revision.
class ApprovalRevisionPolicy implements RevisionPolicy {
public function publishedRevision( RevisionRecord $revision ): ?RevisionRecord {
return $this->approvalLookup->lastApprovedRevisionOf( $revision->getPage() );
}
public function revisionIsReadableBy( RevisionRecord $revision, Authority $viewer ): bool {
return $this->approvalLookup->isApproved( $revision ) || $viewer->isAllowed( 'myext-see-drafts' );
}
}Register with NeoWikiRegistrar::setRevisionPolicy(); a second policy is refused with a warning on the NeoWiki log channel.
publishedRevision()receives the page's current revision and returns the one to publish, of the same page, ornull, which deletes the page's Page node and Subjects from the graph stores, makes the RDF export and the Subject reads answer not-found for it, and leaves its Subjects out of every referencing list, the Subject list, suggestions, counts andGET /neowiki/v0/recently-edited-subjects. A policy that throws counts as returningnull, with the error logged. It runs on every page save and rebuild and on every read above, so keep it cheap.revisionIsReadableBy()is asked when a REST caller names arevisionIdor asks forlatest(REST API); a refusal answers exactly like a revision that does not exist.
Approval changes outside an edit reach the graph stores and the subject indexes only through rebuild(). A newly registered policy reaches the graph stores only through a full rebuild, and the Subject list, suggestions, counts and "Referenced by" only through rebuilding the subject indexes.
A long-running process, such as a job runner or a maintenance script, does not see an approval change to a Schema it has already read. A change to which revision of a Mapping is published does not rebuild the graph stores holding its projection; pages reach it as they are next saved or rebuilt (#1392).
Editing reads the latest revision. So do ?action=subjects, GET /neowiki/v0/page/{pageId}/subjects, GET /neowiki/v0/page/{pageId}/mainSubject, the referenced Subjects on a revisionId read (#1390), the parse-time accessors, and the wiki's search index, which holds a page's Subjects the way MediaWiki holds its wikitext.