* @ingroup SpecialPage
*/
-use Wikimedia\Rdbms\ResultWrapper;
+use MediaWiki\MediaWikiServices;
+use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\IDatabase;
/**
*
* @ingroup SpecialPage
*/
-class DoubleRedirectsPage extends QueryPage {
+class SpecialDoubleRedirects extends QueryPage {
function __construct( $name = 'DoubleRedirects' ) {
parent::__construct( $name );
}
// That does save the bulk of the query cost, but now we need to
// get a little more detail about each individual entry quickly
// using the filter of reallyGetQueryInfo.
- if ( $result && !isset( $result->b_namespace ) ) {
- $dbr = wfGetDB( DB_REPLICA );
- $qi = $this->reallyGetQueryInfo(
- $result->namespace,
- $result->title
- );
- $res = $dbr->select(
- $qi['tables'],
- $qi['fields'],
- $qi['conds'],
- __METHOD__
- );
-
- if ( $res ) {
- $result = $dbr->fetchObject( $res );
+ $deep = false;
+ if ( $result ) {
+ if ( isset( $result->b_namespace ) ) {
+ $deep = $result;
+ } else {
+ $dbr = wfGetDB( DB_REPLICA );
+ $qi = $this->reallyGetQueryInfo(
+ $result->namespace,
+ $result->title
+ );
+ $res = $dbr->select(
+ $qi['tables'],
+ $qi['fields'],
+ $qi['conds'],
+ __METHOD__
+ );
+
+ if ( $res ) {
+ $deep = $dbr->fetchObject( $res ) ?: false;
+ }
}
}
$titleA = Title::makeTitle( $result->namespace, $result->title );
$linkRenderer = $this->getLinkRenderer();
- if ( !$result ) {
+ if ( !$deep ) {
return '<del>' . $linkRenderer->makeLink( $titleA, null, [], [ 'redirect' => 'no' ] ) . '</del>';
}
// if the page is editable, add an edit link
if (
// check user permissions
- $this->getUser()->isAllowed( 'edit' ) &&
+ MediaWikiServices::getInstance()
+ ->getPermissionManager()
+ ->userHasRight( $this->getUser(), 'edit' ) &&
// check, if the content model is editable through action=edit
ContentHandler::getForTitle( $titleA )->supportsDirectEditing()
) {
[ 'redirect' => 'no' ]
);
- $titleB = Title::makeTitle( $result->b_namespace, $result->b_title );
+ $titleB = Title::makeTitle( $deep->b_namespace, $deep->b_title );
$linkB = $linkRenderer->makeKnownLink(
$titleB,
null,
);
$titleC = Title::makeTitle(
- $result->c_namespace,
- $result->c_title,
- $result->c_fragment,
- $result->c_interwiki
+ $deep->c_namespace,
+ $deep->c_title,
+ $deep->c_fragment,
+ $deep->c_interwiki
);
$linkC = $linkRenderer->makeKnownLink( $titleC, $titleC->getFullText() );
return ( "{$linkA} {$edit} {$arr} {$linkB} {$arr} {$linkC}" );
}
+ public function execute( $par ) {
+ $this->addHelpLink( 'Help:Redirects' );
+ parent::execute( $par );
+ }
+
/**
* Cache page content model and gender distinction for performance
*
* @param IDatabase $db
- * @param ResultWrapper $res
+ * @param IResultWrapper $res
*/
function preprocessResults( $db, $res ) {
if ( !$res->numRows() ) {