Update Extension.php

This commit is contained in:
paladox
2021-03-20 23:27:43 +00:00
committed by GitHub
parent 73eaefc78b
commit 095384e453

View File

@ -46,23 +46,18 @@ class Extension {
public static function onMultiContentSave( RenderedRevision $renderedRevision, User $user, CommentStoreComment $summary, $flags, Status $hookStatus ) { public static function onMultiContentSave( RenderedRevision $renderedRevision, User $user, CommentStoreComment $summary, $flags, Status $hookStatus ) {
$config = new Config(); $config = new Config();
if ( !$config->parseOnEdit ) return true; if ( !$config->parseOnEdit ) return true;
$title = $renderedRevision->getRevision()->getPageAsLinkTarget();
$slots = $renderedRevision->getRevision()->getSlots(); $revision = $renderedRevision->getRevision();
$content = $renderedRevision->getRevision()->getSlots()->getContent( SlotRecord::MAIN ); $slots = $revision->getSlots();
$articleID = $renderedRevision->getRevision()->getPageId(); $content = $slots->getContent( SlotRecord::MAIN );
$wikiPage = WikiPage::newFromID( $articleID );
if ( $wikiPage == null ) { $wikiPage = WikiPage::factory( $title );
return true;
}
$source = Source::createFromPageandContent( $wikiPage, $content, $config ); $source = Source::createFromPageandContent( $wikiPage, $content, $config );
$linker = new Linker( $config ); $linker = new Linker( $config );
$result = $linker->linkContent( $source ); $result = $linker->linkContent( $source );
if ( $result ) { if ( $result ) {
$source->setText( $result ); $content = $source->setText( $result );
$slots->setContent( 'main', $content );
$text = $source->getText($result);
$slots = $renderedRevision->getRevision()->getSlots();
$slots->setContent( 'main', ContentHandler::makeContent( $text, $title ) );
} }
return true; return true;