* (bug 10890) API: Timestamp support for categorymembers query
authorRoan Kattouw <catrope@users.mediawiki.org>
Mon, 3 Sep 2007 20:37:42 +0000 (20:37 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Mon, 3 Sep 2007 20:37:42 +0000 (20:37 +0000)
* Removed some stray whitespace

RELEASE-NOTES
includes/api/ApiQueryCategoryMembers.php

index 0b44ba7..f36366f 100644 (file)
@@ -497,6 +497,7 @@ Full API documentation is available at http://www.mediawiki.org/wiki/API
 * (bug 11072) Fix regression in API image history query
 * (bug 11115) Adding SHA1 hash to imageinfo query
 * (bug 10898) API does not return an edit token for non-existent pages
+* (bug 10890) Timestamp support for categorymembers query
 
 == Maintenance script changes since 1.10 ==
 
index cbb1ddf..d46e845 100644 (file)
@@ -58,10 +58,11 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase {
                if ( is_null( $categoryTitle ) )
                        $this->dieUsage("Category name $category is not valid", 'param_category');
                
-               $prop = array_flip($params['prop']);            
+               $prop = array_flip($params['prop']);
                $fld_ids = isset($prop['ids']);
                $fld_title = isset($prop['title']);
                $fld_sortkey = isset($prop['sortkey']);
+               $fld_timestamp = isset($prop['timestamp']);
 
                if (is_null($resultPageSet)) {
                        $this->addFields(array('cl_from', 'cl_sortkey', 'page_namespace', 'page_title'));
@@ -70,7 +71,8 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase {
                        $this->addFields($resultPageSet->getPageTableFields()); // will include page_ id, ns, title
                        $this->addFields(array('cl_from', 'cl_sortkey'));
                }
-               
+
+               $this->addFieldsIf('cl_timestamp', $fld_timestamp);
                $this->addTables(array('page','categorylinks'));        // must be in this order for 'USE INDEX' 
                $this->addOption('USE INDEX', 'cl_sortkey');            // Not needed after bug 10280 is applied to servers
 
@@ -79,7 +81,7 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase {
                $this->addWhereFld('cl_to', $categoryTitle->getDBkey());
                $this->addWhereFld('page_namespace', $params['namespace']);
                $this->addOption('ORDER BY', "cl_to, cl_sortkey, cl_from");
-
+               
                $limit = $params['limit'];
                $this->addOption('LIMIT', $limit +1);
 
@@ -110,6 +112,8 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase {
                                }
                                if ($fld_sortkey)
                                        $vals['sortkey'] = $row->cl_sortkey;
+                               if ($fld_timestamp)
+                                       $vals['timestamp'] = wfTimestamp(TS_ISO_8601, $row->cl_timestamp);
                                $data[] = $vals;
                        } else {
                                $resultPageSet->processDbRow($row);
@@ -152,9 +156,9 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase {
 
                if ($from != 0) {
                        // Duplicate sort key continue
-                       $this->addWhere( "cl_sortkey>$sortKey OR (cl_sortkey=$sortKey AND cl_from>=$from)" );                                           
+                       $this->addWhere( "cl_sortkey>$sortKey OR (cl_sortkey=$sortKey AND cl_from>=$from)" );
                } else {
-                       $this->addWhere( "cl_sortkey>=$sortKey" );                                              
+                       $this->addWhere( "cl_sortkey>=$sortKey" );
                }
        }
 
@@ -163,15 +167,16 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase {
                        'category' => null,
                        'prop' => array (
                                ApiBase :: PARAM_DFLT => 'ids|title',
-                               ApiBase :: PARAM_ISMULTI => true,                               
+                               ApiBase :: PARAM_ISMULTI => true,
                                ApiBase :: PARAM_TYPE => array (
                                        'ids',
                                        'title',
                                        'sortkey',
+                                       'timestamp',
                                )
                        ),
                        'namespace' => array (
-                               ApiBase :: PARAM_ISMULTI => true,                       
+                               ApiBase :: PARAM_ISMULTI => true,
                                ApiBase :: PARAM_TYPE => 'namespace',
                        ),
                        'continue' => null,