mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-11-24 00:05:00 +00:00
Merge "Tracking category for modules saved with errors"
This commit is contained in:
commit
7cab36cea5
|
@ -64,6 +64,8 @@ $1',
|
|||
'scribunto-luastandalone-gone' => 'Lua error: Internal error: The interpreter has already exited.',
|
||||
'scribunto-luastandalone-signal' => 'Lua error: Internal error: The interpreter has terminated with signal "$2".',
|
||||
'scribunto-luastandalone-exited' => 'Lua error: Internal error: The interpreter exited with status $2.',
|
||||
|
||||
'scribunto-module-with-errors-category' => 'Scribunto modules with errors',
|
||||
);
|
||||
|
||||
/** Message documentation (Message documentation)
|
||||
|
@ -172,6 +174,11 @@ Parameters:
|
|||
'scribunto-luastandalone-exited' => 'Exception message. Parameters:
|
||||
* $1 - (Unused)
|
||||
* $2 - an exit status',
|
||||
|
||||
'scribunto-module-with-errors-category' => 'Name of [[mw:Help:Tracking categories|tracking category]] where modules saved with errors are listed.
|
||||
|
||||
See also:
|
||||
* {{msg-mw|scribunto-ignore-errors}}',
|
||||
);
|
||||
|
||||
/** Afrikaans (Afrikaans)
|
||||
|
|
|
@ -64,6 +64,32 @@ class ScribuntoContent extends TextContent {
|
|||
$output->addTemplate( $doc, $doc->getArticleID(), $doc->getLatestRevID() );
|
||||
}
|
||||
|
||||
// Validate the script, and include an error message and tracking
|
||||
// category if it's invalid
|
||||
$engine = Scribunto::newDefaultEngine();
|
||||
$engine->setTitle( $title );
|
||||
$status = $engine->validate( $text, $title->getPrefixedDBkey() );
|
||||
if( !$status->isOK() ) {
|
||||
$output->setText( $output->getText() .
|
||||
Html::rawElement( 'div', array( 'class' => 'errorbox' ),
|
||||
$status->getHTML( 'scribunto-error-short', 'scribunto-error-long' )
|
||||
)
|
||||
);
|
||||
$catmsg = wfMessage( 'scribunto-module-with-errors-category' )
|
||||
->title( $title )->inContentLanguage();
|
||||
if ( !$catmsg->isDisabled() ) {
|
||||
$cat = Title::makeTitleSafe( NS_CATEGORY, $catmsg->text() );
|
||||
if ( $cat ) {
|
||||
$sort = (string)$output->getProperty( 'defaultsort' );
|
||||
$output->addCategory( $cat->getDBkey(), $sort );
|
||||
} else {
|
||||
wfDebug( __METHOD__ . ": [[MediaWiki:scribunto-module-with-errors-category]] " .
|
||||
"is not a valid title!\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !$generateHtml ) {
|
||||
// We don't need the actual HTML
|
||||
$output->setText( '' );
|
||||
|
@ -71,7 +97,6 @@ class ScribuntoContent extends TextContent {
|
|||
}
|
||||
|
||||
// Add HTML for the actual script
|
||||
$engine = Scribunto::newDefaultEngine();
|
||||
$language = $engine->getGeSHiLanguage();
|
||||
if( $wgScribuntoUseGeSHi && $language ) {
|
||||
$geshi = SyntaxHighlight_GeSHi::prepare( $text, $language );
|
||||
|
|
Loading…
Reference in a new issue