* second instance of this class, and all subsequent actions will go use the second instance
* for all their work.
*
- * @addtogroup API
+ * @ingroup API
*/
class ApiPageSet extends ApiQueryBase {
private $mRequestedPageFields;
public function __construct($query, $resolveRedirects = false) {
- parent :: __construct($query, __CLASS__);
+ parent :: __construct($query, 'query');
$this->mAllPages = array ();
$this->mTitles = array();
break;
case 'revids' :
if($this->mResolveRedirects)
- $this->dieUsage('revids may not be used with redirect resolution', 'params');
+ $this->setWarning('Redirect resolution cannot be used together with the revids= parameter. '.
+ 'Any redirects the revids= point to have not been resolved.');
+ $this->mResolveRedirects = false;
$this->initFromRevIDs($revids);
break;
default :
}
private function initFromPageIds($pageids) {
- if(empty($pageids))
+ if(!count($pageids))
return;
$pageids = array_map('intval', $pageids); // paranoia
$res = $db->select('page', $this->getPageTableFields(), $set, __METHOD__);
$this->profileDBOut();
- $this->initFromQueryResult($db, $res, array_flip($pageids), false); // process PageIDs
+ $remaining = array_flip($pageids);
+ $this->initFromQueryResult($db, $res, $remaining, false); // process PageIDs
// Resolve any found redirects
$this->resolvePendingRedirects();
else
{
// The remaining pageids do not exist
- if(empty($this->mMissingPageIDs))
+ if(!$this->mMissingPageIDs)
$this->mMissingPageIDs = array_keys($remaining);
else
$this->mMissingPageIDs = array_merge($this->mMissingPageIDs, array_keys($remaining));
private function initFromRevIDs($revids) {
- if(empty($revids))
+ if(!count($revids))
return;
$db = $this->getDB();
$this->mMissingRevIDs = array_keys($remaining);
// Populate all the page information
- if($this->mResolveRedirects)
- ApiBase :: dieDebug(__METHOD__, 'revids may not be used with redirect resolution');
$this->initFromPageIds(array_keys($pageids));
}
// Repeat until all redirects have been resolved
// The infinite loop is prevented by keeping all known pages in $this->mAllPages
- while (!empty ($this->mPendingRedirectIDs)) {
+ while ($this->mPendingRedirectIDs) {
// Resolve redirects by querying the pagelinks table, and repeat the process
// Create a new linkBatch object for the next pass
$this->mRedirectTitles[$from] = $to;
}
$db->freeResult($res);
- if(!empty($this->mPendingRedirectIDs))
+ if($this->mPendingRedirectIDs)
{
# We found pages that aren't in the redirect table
# Add them
$this->mRedirectTitles[$title->getPrefixedText()] = $rt->getPrefixedText();
unset($this->mPendingRedirectIDs[$id]);
}
- $this->getMain()->scheduleCommit();
}
return $lb;
}
continue; // There's nothing else we can do
}
$iw = $titleObj->getInterwiki();
- if (!empty($iw)) {
+ if (strval($iw) !== '') {
// This title is an interwiki link.
$this->mInterwikiTitles[$titleObj->getPrefixedText()] = $iw;
} else {