public function execute() {
$async = $this->getOption( 'async', false );
$dryrun = $this->getOption( 'dry-run', false );
- $title = $this->getOption( 'title' );
- if ( isset( $title ) ) {
- $title = Title::newFromText( $title );
+ if ( $this->hasOption( 'title' ) ) {
+ $title = Title::newFromText( $this->getOption( 'title' ) );
if ( !$title || !$title->isRedirect() ) {
$this->error( $title->getPrefixedText() . " is not a redirect!\n", true );
}
+ } else {
+ $title = null;
}
$dbr = wfGetDB( DB_SLAVE );
'pb.page_is_redirect' => 1,
);
- if ( isset( $title ) ) {
+ if ( $title != null ) {
$conds['pb.page_namespace'] = $title->getNamespace();
$conds['pb.page_title'] = $title->getDBkey();
}
if ( !$res->numRows() ) {
$this->output( "No double redirects found.\n" );
+
return;
}
foreach ( $res as $row ) {
$titleA = Title::makeTitle( $row->pa_namespace, $row->pa_title );
$titleB = Title::makeTitle( $row->pb_namespace, $row->pb_title );
- RequestContext::getMain()->setTitle( $titleA );
$processedTitles .= "* [[$titleA]]\n";
if ( !$async ) {
$success = ( $dryrun ? true : $job->run() );
if ( !$success ) {
- $this->error( "Error fixing " . $titleA->getPrefixedText() . ": " . $job->getLastError() . "\n" );
+ $this->error( "Error fixing " . $titleA->getPrefixedText()
+ . ": " . $job->getLastError() . "\n" );
}
} else {
$jobs[] = $job;