Index: extensions/Cite/Cite_body.php
===================================================================
--- extensions/Cite/Cite_body.php (revision 45293)
+++ extensions/Cite/Cite_body.php (working copy)
@@ -667,6 +667,23 @@
}
/**
+ * Called at the end of page processing to append an error if refs were
+ * used without a references tag.
+ */
+ function checkRefsNoReferences(&$parser, &$text){
+ foreach ( $this->mRefs as $group => $refs ) {
+ if ( count( $refs ) == 0 ) continue;
+ $text .= "\n
";
+ if ( $group == CITE_DEFAULT_GROUP ) {
+ $text .= $this->error( 'cite_error_refs_without_references' );
+ } else {
+ $text .= $this->error( 'cite_error_group_refs_without_references', htmlspecialchars( $group ) );
+ }
+ }
+ return true;
+ }
+
+ /**
* Initialize the parser hooks
*/
function setHooks() {
@@ -676,6 +693,7 @@
$wgParser->setHook( 'references' , array( &$this, 'references' ) );
$wgHooks['ParserClearState'][] = array( &$this, 'clearState' );
+ $wgHooks['ParserBeforeTidy'][] = array( &$this, 'checkRefsNoReferences' );
}
/**
Index: extensions/Cite/Cite.i18n.php
===================================================================
--- extensions/Cite/Cite.i18n.php (revision 45293)
+++ extensions/Cite/Cite.i18n.php (working copy)
@@ -44,6 +44,8 @@
'cite_error_references_no_text' => 'Invalid <ref>
tag;
no text was provided for refs named $1
',
'cite_error_included_ref' => 'Closing </ref> missing for <ref> tag',
+ 'cite_error_refs_without_references' => '<ref>
tags exist, but no <references/>
tag was found',
+ 'cite_error_group_refs_without_references' => '<ref>
tags exist for a group named "$1", but no corresponding <references group="$1"/>
tag was found',
/*
Output formatting
Index: extensions/Cite/citeParserTests.txt
===================================================================
--- extensions/Cite/citeParserTests.txt (revision 45293)
+++ extensions/Cite/citeParserTests.txt (working copy)
@@ -11,6 +11,7 @@
!! result
Wikipedia rocks![1]
+<ref>
tags exist, but no <references/>
tag was found
!! end
!! test
@@ -129,6 +130,7 @@
!! result
1337[1]
+<ref>
tags exist, but no <references/>
tag was found
!! end
!! test
@@ -236,8 +238,8 @@
Cite error: Invalid <references>
tag;
no input is allowed. Use <references />
Cite error: Invalid <references>
tag;
-no parameters are allowed.
-Use <references />
+parameter "group" is allowed only.
+Use <references />
, or <references group="..." />