(bug 25137) Don't open a DB connection just to (wrongly) use $dbr->timestamp()
[lhc/web/wiklou.git] / includes / api / ApiQueryIWBacklinks.php
index ab5cbae..3b30252 100644 (file)
@@ -1,12 +1,11 @@
 <?php
-
-/*
- * Created on May 14, 2010
- *
+/**
  * API for MediaWiki 1.17+
  *
- * Copyright (C) 2010 Sam Reed
- * Copyright (C) 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
+ * Created on May 14, 2010
+ *
+ * Copyright © 2010 Sam Reed
+ * Copyright © 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -22,6 +21,8 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
  */
 
 if ( !defined( 'MEDIAWIKI' ) ) {
@@ -38,7 +39,7 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase {
        public function __construct( $query, $moduleName ) {
                parent::__construct( $query, $moduleName, 'iwbl' );
        }
-       
+
        public function execute() {
                $this->run();
        }
@@ -49,7 +50,7 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase {
 
        public function run( $resultPageSet = null ) {
                $params = $this->extractRequestParams();
-               
+
                if ( isset( $params['title'] ) && !isset( $params['prefix'] ) ) {
                        $this->dieUsageMsg( array( 'missingparam', 'prefix' ) );
                }
@@ -72,7 +73,7 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase {
                                "iwl_from >= $from)))"
                        );
                }
-               
+
                $prop = array_flip( $params['prop'] );
                $iwprefix = isset( $prop['iwprefix'] );
                $iwtitle = isset( $prop['iwtitle'] );
@@ -98,7 +99,7 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase {
                $this->addOption( 'LIMIT', $params['limit'] + 1 );
 
                $res = $this->select( __METHOD__ );
-               
+
                $pages = array();
 
                $count = 0;
@@ -110,24 +111,24 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase {
                                $this->setContinueEnumParameter( 'continue', "{$row->iwl_prefix}|{$row->iwl_title}|{$row->iwl_from}" );
                                break;
                        }
-                       
+
                        if ( !is_null( $resultPageSet ) ) {
-                               $pages[] = Title::makeTitle( $row->page_namespace, $row->page_title )->getPrefixedText();
+                               $pages[] = Title::newFromRow( $row );
                        } else {
                                $entry = array();
-                               
+
                                $entry['pageid'] = intval( $row->page_id );
-                               $entry['ns'] = $row->page_namespace;
+                               $entry['ns'] = intval( $row->page_namespace );
                                $entry['title'] = $row->page_title;
-                               
+
                                if ( $row->page_is_redirect ) {
                                        $entry['redirect'] = '';
                                }
-                               
+
                                if ( $iwprefix ) {
                                        $entry['iwprefix'] = $row->iwl_prefix;
                                }
-                               
+
                                if ( $iwtitle ) {
                                        $entry['iwtitle'] = $row->iwl_title;
                                }
@@ -139,7 +140,7 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase {
                                }
                        }
                }
-               
+
                if ( is_null( $resultPageSet ) ) {
                        $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'iw' );
                } else {