Merge "Tracking category for modules saved with errors"

This commit is contained in:
jenkins-bot 2013-12-10 00:12:35 +00:00 committed by Gerrit Code Review
commit 7cab36cea5
2 changed files with 33 additions and 1 deletions

View file

@ -64,6 +64,8 @@ $1',
'scribunto-luastandalone-gone' => 'Lua error: Internal error: The interpreter has already exited.', '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-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-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) /** Message documentation (Message documentation)
@ -172,6 +174,11 @@ Parameters:
'scribunto-luastandalone-exited' => 'Exception message. Parameters: 'scribunto-luastandalone-exited' => 'Exception message. Parameters:
* $1 - (Unused) * $1 - (Unused)
* $2 - an exit status', * $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) /** Afrikaans (Afrikaans)

View file

@ -64,6 +64,32 @@ class ScribuntoContent extends TextContent {
$output->addTemplate( $doc, $doc->getArticleID(), $doc->getLatestRevID() ); $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 ) { if ( !$generateHtml ) {
// We don't need the actual HTML // We don't need the actual HTML
$output->setText( '' ); $output->setText( '' );
@ -71,7 +97,6 @@ class ScribuntoContent extends TextContent {
} }
// Add HTML for the actual script // Add HTML for the actual script
$engine = Scribunto::newDefaultEngine();
$language = $engine->getGeSHiLanguage(); $language = $engine->getGeSHiLanguage();
if( $wgScribuntoUseGeSHi && $language ) { if( $wgScribuntoUseGeSHi && $language ) {
$geshi = SyntaxHighlight_GeSHi::prepare( $text, $language ); $geshi = SyntaxHighlight_GeSHi::prepare( $text, $language );