private function prepareFirstQuery($resultPageSet = null) {
/* SELECT page_id, page_title, page_namespace, page_is_redirect
- * FROM pagelinks JOIN page ON pl_from=page_id
- * WHERE pl_title='Foo' AND pl_namespace=0
+ * FROM pagelinks, page WHERE pl_from=page_id
+ * AND pl_title='Foo' AND pl_namespace=0
* LIMIT 11 ORDER BY pl_from
*/
$db = $this->getDb();
- list($tblpage, $tbllinks) = $db->tableNamesN('page', $this->bl_table);
- $this->addTables("$tbllinks JOIN $tblpage ON {$this->bl_from}=page_id");
+ $this->addTables(array('page', $this->bl_table));
+ $this->addWhere("{$this->bl_from}=page_id");
if(is_null($resultPageSet))
$this->addFields(array('page_id', 'page_title', 'page_namespace'));
else
private function prepareSecondQuery($resultPageSet = null) {
/* SELECT page_id, page_title, page_namespace, page_is_redirect, pl_title, pl_namespace
- * FROM pagelinks JOIN page ON pl_from=page_id
- * WHERE (pl_title='Foo' AND pl_namespace=0) OR (pl_title='Bar' AND pl_namespace=1)
+ * FROM pagelinks, page WHERE pl_from=page_id
+ * AND (pl_title='Foo' AND pl_namespace=0) OR (pl_title='Bar' AND pl_namespace=1)
* LIMIT 11 ORDER BY pl_namespace, pl_title, pl_from
*/
$db = $this->getDb();
- list($tblpage, $tbllinks) = $db->tableNamesN('page', $this->bl_table);
- $this->addTables("$tbllinks JOIN $tblpage ON {$this->bl_from}=page_id");
+ $this->addTables(array('page', $this->bl_table));
+ $this->addWhere("{$this->bl_from}=page_id");
if(is_null($resultPageSet))
$this->addFields(array('page_id', 'page_title', 'page_namespace', 'page_is_redirect'));
else
private function run($resultPageSet = null) {
$this->params = $this->extractRequestParams(false);
- $userMax = ( $this->params['redirect'] ? ApiBase::LIMIT_BIG1/2 : ApiBase::LIMIT_BIG1 );
- $botMax = ( $this->params['redirect'] ? ApiBase::LIMIT_BIG2/2 : ApiBase::LIMIT_BIG2 );
+ $this->redirect = isset($this->params['redirect']) && $this->params['redirect'];
+ $userMax = ( $this->redirect ? ApiBase::LIMIT_BIG1/2 : ApiBase::LIMIT_BIG1 );
+ $botMax = ( $this->redirect ? ApiBase::LIMIT_BIG2/2 : ApiBase::LIMIT_BIG2 );
if( $this->params['limit'] == 'max' ) {
$this->params['limit'] = $this->getMain()->canApiHighLimits() ? $botMax : $userMax;
$this->getResult()->addValue( 'limits', $this->getModuleName(), $this->params['limit'] );
}
$db->freeResult($res);
- if($this->params['redirect'] && !empty($this->redirTitles))
+ if($this->redirect && !empty($this->redirTitles))
{
$this->resetQueryParams();
$this->prepareSecondQuery($resultPageSet);
}
protected function processContinue() {
- $pageSet = $this->getPageSet();
- $count = $pageSet->getTitleCount();
-
if (!is_null($this->params['continue']))
$this->parseContinueParam();
else {
$title = $this->params['title'];
if (!is_null($title)) {
$this->rootTitle = Title :: newFromText($title);
- } else { // This case is obsolete. Will support this for a while
- if ($count !== 1)
- $this->dieUsage("The {$this->getModuleName()} query requires one title to start", 'bad_title_count');
- $this->rootTitle = current($pageSet->getTitles()); // only one title there
- $this->setWarning('Using titles parameter is obsolete for this list. Use ' . $this->encodeParamName('title') . ' instead.');
+ } else {
+ $this->dieUsageMsg(array('missingparam', 'title'));
}
}