From 957f098222d4b72146d5dbade3a9185927ade012 Mon Sep 17 00:00:00 2001 From: Rob Church Date: Sat, 8 Apr 2006 21:13:11 +0000 Subject: [PATCH] (bug 861) Show page protection/unprotection events in histories --- RELEASE-NOTES | 1 + includes/Article.php | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index a8623858d4..ddba13dabe 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -37,6 +37,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Improve Special:Log performance on big log sets * (bug 5507) Changed mediawiki:logouttext from plain to wikitext * (bug 4760) Prevent creation of entries in protection log when protection levels haven't changed +* (bug 861) Show page protection/unprotection events in histories == Compatibility == diff --git a/includes/Article.php b/includes/Article.php index cbce67a1e4..41b59deed2 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -1690,7 +1690,7 @@ class Article { * @return bool true on success */ function updateRestrictions( $limit = array(), $reason = '' ) { - global $wgUser, $wgRestrictionTypes; + global $wgUser, $wgRestrictionTypes, $wgContLang; $id = $this->mTitle->getArticleID(); if( !$wgUser->isAllowed( 'protect' ) || wfReadOnly() || $id == 0 ) { @@ -1712,12 +1712,24 @@ class Article { # If nothing's changed, do nothing if( $changed ) { if( wfRunHooks( 'ArticleProtect', array( &$this, &$wgUser, $limit, $reason ) ) ) { - # Update page record + $dbw =& wfGetDB( DB_MASTER ); + + # Prepare a null revision to be added to the history + $comment = $wgContLang->ucfirst( wfMsgForContent( $protect ? 'protectedarticle' : 'unprotectedarticle', $this->mTitle->getPrefixedText() ) ); + if( $reason ) + $comment .= ": $reason"; + if( $protect ) + $comment .= " [$updated]"; + $nullRevision = Revision::newNullRevision( $dbw, $id, $comment, true ); + $nullRevId = $nullRevision->insertOn( $dbw ); + + # Update page record $dbw->update( 'page', array( /* SET */ 'page_touched' => $dbw->timestamp(), - 'page_restrictions' => $updated + 'page_restrictions' => $updated, + 'page_latest' => $nullRevId ), array( /* WHERE */ 'page_id' => $id ), 'Article::protect' -- 2.20.1