r72387 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72386‎ | r72387 | r72388 >
Date:18:31, 4 September 2010
Author:platonides
Status:resolved (Comments)
Tags:
Comment:
Make happy check-vars. This shows it that getQuery() returns an ApiQuery (more specifically, that getQuery() doesn't return an article)
Modified paths:
  • /trunk/phase3/includes/api/ApiQueryBase.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryBase.php
@@ -40,7 +40,7 @@
4141
4242 private $mQueryModule, $mDb, $tables, $where, $fields, $options, $join_conds;
4343
44 - public function __construct( $query, $moduleName, $paramPrefix = '' ) {
 44+ public function __construct( ApiQuery $query, $moduleName, $paramPrefix = '' ) {
4545 parent::__construct( $query->getMain(), $moduleName, $paramPrefix );
4646 $this->mQueryModule = $query;
4747 $this->mDb = null;
@@ -361,7 +361,8 @@
362362 */
363363 protected function getDB() {
364364 if ( is_null( $this->mDb ) ) {
365 - $this->mDb = $this->getQuery()->getDB();
 365+ $apiQuery = $this->getQuery();
 366+ $this->mDb = $apiQuery->getDB();
366367 }
367368 return $this->mDb;
368369 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r73596follow up r72387: using ApiQuery here breaks ApiParamInfo (bug 25248)gurch10:46, 23 September 2010

Comments

#Comment by Gurch (talk | contribs)   08:51, 23 September 2010

This broke action=paraminfo for query modules (bug 25248).

#Comment by Catrope (talk | contribs)   13:56, 27 September 2010
-			$this->mDb = $this->getQuery()->getDB();
+			$apiQuery = $this->getQuery();
+			$this->mDb = $apiQuery->getDB();

We're not coding for PHP 4 anymore. If check-vars can't handle chained calls like that, that's not an excuse to make the code uglier.

#Comment by Platonides (talk | contribs)   15:41, 27 September 2010

The problem is not that it can't handle chained calls, but that Article has a deprecated getDB() function.

Calling it as $apiQuery->getDB(); is an easy way to makes it realise that the returned object is from class ApiQuery and not Article (and to be fair, as a human I had to dive a bit to check what it was, and still didn't got it completely right).

Status & tagging log