+ private $mAllPages; // [ns][dbkey] => page_id or negative when missing
+ private $mTitles, $mGoodTitles, $mMissingTitles, $mInvalidTitles;
+ private $mMissingPageIDs, $mRedirectTitles, $mSpecialTitles;
+ private $mNormalizedTitles, $mInterwikiTitles;
+ private $mResolveRedirects, $mPendingRedirectIDs;
+ private $mConvertTitles, $mConvertedTitles;
+ private $mGoodRevIDs, $mMissingRevIDs;
+ private $mFakePageId;
+
+ private $mRequestedPageFields;
+
+ /**
+ * Constructor
+ * @param $query ApiQuery
+ * @param $resolveRedirects bool Whether redirects should be resolved
+ */
+ public function __construct( $query, $resolveRedirects = false, $convertTitles = false ) {
+ parent::__construct( $query, 'query' );
+
+ $this->mAllPages = array();
+ $this->mTitles = array();
+ $this->mGoodTitles = array();
+ $this->mMissingTitles = array();
+ $this->mInvalidTitles = array();
+ $this->mMissingPageIDs = array();
+ $this->mRedirectTitles = array();
+ $this->mNormalizedTitles = array();
+ $this->mInterwikiTitles = array();
+ $this->mGoodRevIDs = array();
+ $this->mMissingRevIDs = array();
+ $this->mSpecialTitles = array();
+
+ $this->mRequestedPageFields = array();
+ $this->mResolveRedirects = $resolveRedirects;
+ if ( $resolveRedirects ) {
+ $this->mPendingRedirectIDs = array();
+ }
+
+ $this->mConvertTitles = $convertTitles;
+ $this->mConvertedTitles = array();
+
+ $this->mFakePageId = - 1;
+ }
+
+ /**
+ * Check whether this PageSet is resolving redirects
+ * @return bool
+ */
+ public function isResolvingRedirects() {
+ return $this->mResolveRedirects;
+ }
+
+ /**
+ * Request an additional field from the page table. Must be called
+ * before execute()
+ * @param $fieldName string Field name
+ */
+ public function requestField( $fieldName ) {
+ $this->mRequestedPageFields[$fieldName] = null;
+ }
+
+ /**
+ * Get the value of a custom field previously requested through
+ * requestField()
+ * @param $fieldName string Field name
+ * @return mixed Field value
+ */
+ public function getCustomField( $fieldName ) {
+ return $this->mRequestedPageFields[$fieldName];
+ }
+
+ /**
+ * Get the fields that have to be queried from the page table:
+ * the ones requested through requestField() and a few basic ones
+ * we always need
+ * @return array of field names
+ */
+ public function getPageTableFields() {
+ // Ensure we get minimum required fields
+ // DON'T change this order
+ $pageFlds = array(
+ 'page_namespace' => null,
+ 'page_title' => null,
+ 'page_id' => null,
+ );
+
+ if ( $this->mResolveRedirects ) {
+ $pageFlds['page_is_redirect'] = null;
+ }
+
+ // only store non-default fields
+ $this->mRequestedPageFields = array_diff_key( $this->mRequestedPageFields, $pageFlds );
+
+ $pageFlds = array_merge( $pageFlds, $this->mRequestedPageFields );
+ return array_keys( $pageFlds );
+ }