(bug 5841) Allow the 'EditFilter' hook to return a non-fatal error message

This commit is contained in:
Rob Church 2006-05-06 21:41:53 +00:00
parent 197d2c89c6
commit f064b66c64
3 changed files with 24 additions and 3 deletions

View file

@ -220,7 +220,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
* (bug 5839) Prevent access to Special:Confirmemail for logged-out users
* (bug 5853) Update for Portuguese messages (pt)
* (bug 5851) Use Cyrillic for Kirghiz language name
* (bug 5841) Allow the 'EditFilter' hook to return a non-fatal error message
== Compatibility ==

View file

@ -297,6 +297,17 @@ $user: the user _doing_ the block (not the one being blocked)
$block: the Block object that was saved
$user: the user who did the block (not the one being blocked)
'EditFilter': Perform checks on an edit
$editor: Edit form (see includes/EditPage.php)
$text: Contents of the edit box
&section: Section being edited
$error: Error message to return
Return false to halt editing; you'll need to handle error messages, etc. yourself.
Alternatively, modifying $error and returning true will cause the contents of $error
to be echoed at the top of the edit form as wikitext. Return true without altering
$error to allow the edit to proceed.
'EmailConfirmed': When checking that the user's email address is "confirmed"
$user: User being checked
$confirmed: Whether or not the email address is confirmed

View file

@ -30,6 +30,7 @@ class EditPage {
var $missingSummary = false;
var $allowBlankSummary = false;
var $autoSumm = '';
var $hookError = '';
# Form values
var $save = false, $preview = false, $diff = false;
@ -492,11 +493,16 @@ class EditPage {
wfProfileOut( "$fname-checks" );
return false;
}
if ( !wfRunHooks( 'EditFilter', array( &$this, $this->textbox1, $this->section ) ) ) {
# Error messages or other handling should be performed by the filter function
if ( !wfRunHooks( 'EditFilter', array( &$this, $this->textbox1, $this->section, &$this->hookError ) ) ) {
# Error messages etc. could be handled within the hook...
wfProfileOut( $fname );
wfProfileOut( "$fname-checks" );
return false;
} elseif( $this->hookError != '' ) {
# ...or the hook could be expecting us to produce an error
wfProfileOut( "$fname-checks " );
wfProfileOut( $fname );
return false;
}
if ( $wgUser->isBlockedFrom( $this->mTitle, false ) ) {
# Check block state against master, thus 'false'.
@ -771,6 +777,10 @@ class EditPage {
if( $this->missingSummary ) {
$wgOut->addWikiText( wfMsg( 'missingsummary' ) );
}
if( !$this->hookError = '' ) {
$wgOut->addWikiText( $this->hookError );
}
if ( !$this->checkUnicodeCompliantBrowser() ) {
$wgOut->addWikiText( wfMsg( 'nonunicodebrowser') );