From: Leon Weber Date: Fri, 1 Dec 2006 21:18:40 +0000 (+0000) Subject: Added hook 'EditPage::attemptSave' before an article is saved. X-Git-Tag: 1.31.0-rc.0~55018 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=d830450a8abf39a3311276eec3363fcaf7fadcb9;p=lhc%2Fweb%2Fwiklou.git Added hook 'EditPage::attemptSave' before an article is saved. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 394e7ba708..cb53f7fddd 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -231,6 +231,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Fix regression in authentication hook auto-creation on login * (bug 8110) Allow spaces in ISBNs * (bug 8024) Introduce "send me copies of emails I send to others" preference +* Added 'EditPage::attemptSave' hook before an article is saved. == Languages updated == diff --git a/docs/hooks.txt b/docs/hooks.txt index 445b2a45ed..104a665869 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -313,6 +313,10 @@ $diff: DifferenceEngine object that's calling $oldRev: Revision object of the "old" revision (may be null/invalid) $newRev: Revision object of the "new" revision +'EditPage::attemptSave': called before an article is +saved, that is before insertNewArticle() is called +&$editpage_Obj: the current EditPage object + 'EditFormPreloadText': Allows population of the edit form when creating new pages &$text: Text to preload with &$title: Title object representing the page being created diff --git a/includes/EditPage.php b/includes/EditPage.php index d2eeb73078..d3ae6bf7bb 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -598,6 +598,12 @@ class EditPage { wfProfileIn( $fname ); wfProfileIn( "$fname-checks" ); + if( !wfRunHooks( 'EditPage::attemptSave', array( &$this ) ) ) + { + wfDebug( "Hook 'EditPage::attemptSave' aborted article saving" ); + return false; + } + # Reintegrate metadata if ( $this->mMetaData != '' ) $this->textbox1 .= "\n" . $this->mMetaData ; $this->mMetaData = '' ; @@ -684,6 +690,7 @@ class EditPage { # If article is new, insert it. $aid = $this->mTitle->getArticleID( GAID_FOR_UPDATE ); if ( 0 == $aid ) { + // Late check for create permission, just in case *PARANOIA* if ( !$this->mTitle->userCanCreate() ) { wfDebug( "$fname: no create permission\n" );