r21821 - Code Review

From MediaWiki.org

Jump to: navigation, search
Repository:MediaWiki
Revision:r21820 | r21821 (on ViewVC) | r21822 >
Date:12:44, 3 May 2007
Author:daniel
Status:new
Tags:
Comment:don't show excerpts from non-readable articles
Modified paths:

Diff [purge]

Index: trunk/phase3/includes/SpecialSearch.php
===================================================================
--- trunk/phase3/includes/SpecialSearch.php	(revision 21820)
+++ trunk/phase3/includes/SpecialSearch.php	(revision 21821)
@@ -320,6 +320,14 @@
 		$contextchars = $wgUser->getOption( 'contextchars', 50 );
 
 		$link = $sk->makeKnownLinkObj( $t );
+
+		//If page content is not readable, just return the title.
+		//This is not quite safe, but better than showing excerpts from non-readable pages
+		//Note that hiding the entry entirely would screw up paging.
+		if (!$t->userCanRead()) {
+			return "<li>{$link}</li>\n";
+		}
+
 		$revision = Revision::newFromTitle( $t );
 		$text = $revision->getText();
 		$size = wfMsgExt( 'nbytes', array( 'parsemag', 'escape'),
Views
Toolbox