* (bug 26480) add a pppageprops param to prop=pageprops
[lhc/web/wiklou.git] / includes / api / ApiQueryPageProps.php
index 46d04b1..1e9fa48 100644 (file)
@@ -43,8 +43,6 @@ class ApiQueryPageProps extends ApiQueryBase {
        }
 
        public function execute() {
-               $this->params = $this->extractRequestParams();
-
                # Only operate on existing pages
                $pages = $this->getPageSet()->getGoodTitles();
                if ( !count( $pages ) ) {
@@ -52,6 +50,8 @@ class ApiQueryPageProps extends ApiQueryBase {
                        return;
                }
 
+               $this->params = $this->extractRequestParams();
+
                $this->addTables( 'page_props' );
                $this->addFields( array( 'pp_page', 'pp_propname', 'pp_value' ) );
                $this->addWhereFld( 'pp_page',  array_keys( $pages ) );
@@ -60,6 +60,10 @@ class ApiQueryPageProps extends ApiQueryBase {
                        $this->addWhere( 'pp_page >=' . intval( $this->params['continue'] ) );
                }
 
+               if ( $this->params['prop'] ) {
+                       $this->addWhereFld( 'pp_propname', $this->params['prop'] );
+               }
+
                # Force a sort order to ensure that properties are grouped by page
                $this->addOption( 'ORDER BY', 'pp_page' );
 
@@ -121,23 +125,23 @@ class ApiQueryPageProps extends ApiQueryBase {
        }
 
        public function getAllowedParams() {
-               return array( 'continue' => null );
+               return array(
+                       'continue' => null,
+                       'prop' => null,
+               );
        }
 
        public function getParamDescription() {
-               return  array( 'continue' => 'When more results are available, use this to continue' );
+               return array(
+                       'continue' => 'When more results are available, use this to continue',
+                       'prop' => 'Page prop to look on the page for. Useful for checking whether a certain page uses a certain page prop.'
+               );
        }
 
        public function getDescription() {
                return 'Get various properties defined in the page content';
        }
 
-       public function getPossibleErrors() {
-               return array_merge( parent::getPossibleErrors(), array(
-                       array( 'code' => '_badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ),
-               ) );
-       }
-
        protected function getExamples() {
                return array(
                        'api.php?action=query&prop=pageprops&titles=Category:Foo',