diff --git a/LinkTitles.body.php b/LinkTitles.body.php index 20b6f5c..b54417e 100755 --- a/LinkTitles.body.php +++ b/LinkTitles.body.php @@ -239,13 +239,12 @@ /// If in doubt, call MediaWiki's `RequestContext::getMain()` /// to obtain such an object. /// @returns undefined - public static function processPage($title, RequestContext $context) { - // TODO: make this namespace-aware - $titleObj = Title::makeTitle(0, $title); - $page = WikiPage::factory($titleObj); + public static function processPage(Title $title, RequestContext $context) { + // TODO: make this namespace-aware + $page = WikiPage::factory($title); $content = $page->getContent(); $text = $content->getContentHandler()->serializeContent($content); - $newText = LinkTitles::parseContent($titleObj, $text); + $newText = LinkTitles::parseContent($title, $text); if ( $text != $newText ) { $content = $content->getContentHandler()->unserializeContent( $newText ); $page->doQuickEditContent($content, diff --git a/LinkTitles.cli.php b/LinkTitles.cli.php index a7feded..bf734fc 100755 --- a/LinkTitles.cli.php +++ b/LinkTitles.cli.php @@ -71,20 +71,25 @@ class LinkTitlesCli extends Maintenance { /// if the `--start` option is given) and call LinkTitles::processPage() for /// each page. public function execute() { + global $wgLinkTitlesNamespaces; + $index = intval($this->getOption('start', 0)); if ( $index < 0 ) { $this->error('FATAL: Start index must be 0 or greater.', 1); }; + // get our Namespaces + $namespacesClause = str_replace( '_', ' ','(' . implode( ', ',$wgLinkTitlesNamespaces ) . ')' ); + // Connect to the database $dbr = $this->getDB( DB_SLAVE ); // Retrieve page names from the database. $res = $dbr->select( 'page', - 'page_title', + array('page_title', 'page_namespace'), array( - 'page_namespace = 0', + 'page_namespace IN ' . $namespacesClause, ), __METHOD__, array( @@ -99,7 +104,7 @@ class LinkTitlesCli extends Maintenance { // Iterate through the pages; break if a time limit is exceeded. foreach ( $res as $row ) { $index += 1; - $curTitle = $row->page_title; + $curTitle = Title::makeTitle( $row->page_namespace, $row->page_title); $this->output( sprintf("\rPage #%d (%02.0f%%)", $index, $index / $numPages * 100) ); diff --git a/SpecialLinkTitles.php b/SpecialLinkTitles.php index 4d7ce89..5d205f3 100644 --- a/SpecialLinkTitles.php +++ b/SpecialLinkTitles.php @@ -79,6 +79,10 @@ class SpecialLinkTitles extends SpecialPage { /// @param OutputPage $output Output page for the special page. private function process( WebRequest &$request, OutputPage &$output) { global $wgLinkTitlesTimeLimit; + global $wgLinkTitlesNamespaces; + + // get our Namespaces + $namespacesClause = str_replace( '_', ' ','(' . implode( ', ',$wgLinkTitlesNamespaces ) . ')' ); // Start the stopwatch $startTime = microtime(true); @@ -111,9 +115,9 @@ class SpecialLinkTitles extends SpecialPage { // Retrieve page names from the database. $res = $dbr->select( 'page', - 'page_title', + array('page_title', 'page_namespace'), array( - 'page_namespace = 0', + 'page_namespace IN ' . $namespacesClause, ), __METHOD__, array( @@ -124,7 +128,7 @@ class SpecialLinkTitles extends SpecialPage { // Iterate through the pages; break if a time limit is exceeded. foreach ( $res as $row ) { - $curTitle = $row->page_title; + $curTitle = Title::makeTitle( $row->page_namespace, $row->page_title); LinkTitles::processPage($curTitle, $this->getContext()); $start += 1;