API: (bug 16515) Added pst and onlypst parameters to action=parse, which do a pre...
authorRoan Kattouw <catrope@users.mediawiki.org>
Thu, 4 Dec 2008 15:51:39 +0000 (15:51 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Thu, 4 Dec 2008 15:51:39 +0000 (15:51 +0000)
RELEASE-NOTES
includes/api/ApiParse.php
includes/api/ApiQueryLogEvents.php
includes/api/ApiQueryWatchlist.php

index daf3c9d..2804408 100644 (file)
@@ -482,6 +482,7 @@ The following extensions are migrated into MediaWiki 1.14:
 * (bug 16516) Made rvsection=T-2 work
 * (bug 16526) Added usprop=emailable to list=users
 * (bug 16548) list=search threw errors with an invalid error code
+* (bug 16515) Added pst and onlypst parameters to action=parse
 
 === Languages updated in 1.14 ===
 
index 92857ed..2f74226 100644 (file)
@@ -111,6 +111,16 @@ class ApiParse extends ApiBase {
                        $titleObj = Title::newFromText($title);
                        if(!$titleObj)
                                $titleObj = Title::newFromText("API");
+                       if($params['pst'] || $params['onlypst'])
+                               $text = $wgParser->preSaveTransform($text, $titleObj, $wgUser, $popts);
+                       if($params['onlypst'])
+                       {
+                               // Build a result and bail out
+                               $result_array['text'] = array();
+                               $this->getResult()->setContent($result_array['text'], $text);
+                               $this->getResult()->addValue(null, $this->getModuleName(), $result_array);
+                               return;
+                       }
                        $p_result = $wgParser->parse($text, $titleObj, $popts);
                }
 
@@ -222,7 +232,9 @@ class ApiParse extends ApiBase {
                                        'sections',
                                        'revid'
                                )
-                       )
+                       ),
+                       'pst' => false,
+                       'onlypst' => false,
                );
        }
 
@@ -236,6 +248,12 @@ class ApiParse extends ApiBase {
                        'prop' => array('Which pieces of information to get.',
                                        'NOTE: Section tree is only generated if there are more than 4 sections, or if the __TOC__ keyword is present'
                        ),
+                       'pst' => array( 'Do a pre-save transform on the input before parsing it.',
+                                       'Ignored if page or oldid is used.'
+                       ),
+                       'onlypst' => array('Do a PST on the input, but don\'t parse it.',
+                                       'Returns PSTed wikitext. Ignored if page or oldid is used.'
+                       ),
                );
        }
 
index 84bd15d..beb2963 100644 (file)
@@ -140,7 +140,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
                $this->getResult()->addValue('query', $this->getModuleName(), $data);
        }
        
-       public static function addLogParams($result, &$vals, $params, $type) {
+       public static function addLogParams($result, &$vals, $params, $type, $ts) {
                $params = explode("\n", $params);
                switch ($type) {
                        case 'move':
@@ -169,6 +169,8 @@ class ApiQueryLogEvents extends ApiQueryBase {
                        case 'block':
                                $vals2 = array();
                                list( $vals2['duration'], $vals2['flags'] ) = $params;
+                               $vals2['expiry'] = wfTimestamp(TS_ISO_8601,
+                                               strtotime($params[0], wfTimestamp(TS_UNIX, $ts)));
                                $vals[$type] = $vals2;
                                $params = null;
                                break;
@@ -200,7 +202,8 @@ class ApiQueryLogEvents extends ApiQueryBase {
 
                if ($this->fld_details && $row->log_params !== '') {
                        self::addLogParams($this->getResult(), $vals,
-                               $row->log_params, $row->log_type);
+                               $row->log_params, $row->log_type,
+                               $row->log_timestamp);
                }
 
                if ($this->fld_user) {
index a70ea49..3d38b81 100644 (file)
@@ -118,7 +118,6 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
 
                $this->addTables(array (
                        'watchlist',
-                       'page',
                        'recentchanges'
                ));
 
@@ -126,14 +125,18 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                $this->addWhere(array (
                        'wl_namespace = rc_namespace',
                        'wl_title = rc_title',
-                       'rc_cur_id = page_id',
                        'wl_user' => $userId,
                        'rc_deleted' => 0,
                ));
 
                $this->addWhereRange('rc_timestamp', $dir, $start, $end);
                $this->addWhereFld('wl_namespace', $namespace);
-               $this->addWhereIf('rc_this_oldid=page_latest', !$allrev);
+               if(!$allrev)
+               {
+                       $this->addTables('page');
+                       $this->addWhere('page_id=rc_cur_id');
+                       $this->addWhereIf('rc_this_oldid=page_latest');
+               }
 
                if (!is_null($show)) {
                        $show = array_flip($show);