X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialBrokenRedirects.php;h=9ea18daa87a40ca91d6f28fa9752d778edb78eb2;hb=323a2909ba1f43407ccba8bc1fadf2d25f2de488;hp=b2ddc2209cf42f058ccd531e63e2b71a999427d7;hpb=b65669ff7adbbde55872a8ddd93214a9e1df75c6;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialBrokenRedirects.php b/includes/specials/SpecialBrokenRedirects.php index b2ddc2209c..9ea18daa87 100644 --- a/includes/specials/SpecialBrokenRedirects.php +++ b/includes/specials/SpecialBrokenRedirects.php @@ -28,12 +28,11 @@ * @ingroup SpecialPage */ class BrokenRedirectsPage extends QueryPage { - function __construct( $name = 'BrokenRedirects' ) { parent::__construct( $name ); } - function isExpensive() { + public function isExpensive() { return true; } @@ -49,7 +48,7 @@ class BrokenRedirectsPage extends QueryPage { return $this->msg( 'brokenredirectstext' )->parseAsBlock(); } - function getQueryInfo() { + public function getQueryInfo() { $dbr = wfGetDB( DB_SLAVE ); return array( @@ -122,12 +121,20 @@ class BrokenRedirectsPage extends QueryPage { array( 'redirect' => 'no' ) ); $links = array(); - $links[] = Linker::linkKnown( - $fromObj, - $this->msg( 'brokenredirects-edit' )->escaped(), - array(), - array( 'action' => 'edit' ) - ); + // if the page is editable, add an edit link + if ( + // check user permissions + $this->getUser()->isAllowed( 'edit' ) && + // check, if the content model is editable through action=edit + ContentHandler::getForTitle( $fromObj )->supportsDirectEditing() + ) { + $links[] = Linker::linkKnown( + $fromObj, + $this->msg( 'brokenredirects-edit' )->escaped(), + array(), + array( 'action' => 'edit' ) + ); + } $to = Linker::link( $toObj, null, @@ -148,12 +155,37 @@ class BrokenRedirectsPage extends QueryPage { ); } - $out .= $this->msg( 'parentheses' )->rawParams( $this->getLanguage()->pipeList( $links ) )->escaped(); + if ( $links ) { + $out .= $this->msg( 'parentheses' )->rawParams( $this->getLanguage() + ->pipeList( $links ) )->escaped(); + } $out .= " {$arr} {$to}"; return $out; } + + /** + * Cache page content model for performance + * + * @param IDatabase $db + * @param ResultWrapper $res + */ + function preprocessResults( $db, $res ) { + if ( !$res->numRows() ) { + return; + } + + $batch = new LinkBatch; + foreach ( $res as $row ) { + $batch->add( $row->namespace, $row->title ); + } + $batch->execute(); + + // Back to start for display + $res->seek( 0 ); + } + protected function getGroupName() { return 'maintenance'; }