}
/**
- * This is three-in-one module to query:
+ * This is a three-in-one module to query:
* * backlinks - links pointing to the given page,
* * embeddedin - what pages transclude the given page within themselves,
* * imageusage - what pages use the given image
*
- * @addtogroup API
+ * @ingroup API
*/
class ApiQueryBacklinks extends ApiQueryGeneratorBase {
$titleWhere = '';
foreach($this->redirTitles as $t)
$titleWhere .= ($titleWhere != '' ? " OR " : '') .
- "({$this->bl_title} = '{$t->getDBKey()}'" .
+ "({$this->bl_title} = ".$db->addQuotes($t->getDBKey()).
($this->hasNS ? " AND {$this->bl_ns} = '{$t->getNamespace()}'" : "") .
")";
$this->addWhere($titleWhere);
$resultData = array();
foreach($this->data as $ns => $a)
foreach($a as $title => $arr)
- $resultData[$arr['pageid']] = $arr;
+ $resultData[] = $arr;
$result = $this->getResult();
$result->setIndexedTagName($resultData, $this->bl_code);
$result->addValue('query', $this->getModuleName(), $resultData);
if (!is_null($this->params['continue']))
$this->parseContinueParam();
else {
- $title = $this->params['title'];
- if (!is_null($title)) {
- $this->rootTitle = Title :: newFromText($title);
+ if ( $this->params['title'] !== "" ) {
+ $title = Title::newFromText( $this->params['title'] );
+ if ( !$title ) {
+ $this->dieUsageMsg(array('invalidtitle', $this->params['title']));
+ } else {
+ $this->rootTitle = $title;
+ }
} else {
$this->dieUsageMsg(array('missingparam', 'title'));
}