Skip to content

Commit

Permalink
Merge pull request #187 from ProfessionalWiki/onEditFilter
Browse files Browse the repository at this point in the history
Optimize onEditFilter
  • Loading branch information
JeroenDeDauw authored Jan 6, 2025
2 parents c0ac096 + 0a47a47 commit 3141a73
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/EntryPoints/MediaWikiHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ public static function onContentHandlerDefaultModelFor( Title $title, ?string &$
}

public static function onEditFilter( EditPage $editPage, ?string $text, ?string $section, string &$error ): void {
if ( !is_string( $text ) || !WikibaseExportExtension::getInstance()->isConfigTitle( $editPage->getTitle() ) ) {
return;
}

$validator = ConfigJsonValidator::newInstance();

if ( is_string( $text )
&& WikibaseExportExtension::getInstance()->isConfigTitle( $editPage->getTitle() )
&& !$validator->validate( $text )
) {
if ( !$validator->validate( $text ) ) {
$errors = $validator->getErrors();
$error = \Html::errorBox(
wfMessage( 'wikibase-export-config-invalid', count( $errors ) )->escaped() .
Expand Down

0 comments on commit 3141a73

Please sign in to comment.