From 7e35fc4b5a28b1c05e8dd83c9c7f96cb9a66cd0f Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Thu, 4 Dec 2008 15:51:39 +0000 Subject: [PATCH] API: (bug 16515) Added pst and onlypst parameters to action=parse, which do a pre-save transform on the input --- RELEASE-NOTES | 1 + includes/api/ApiParse.php | 20 +++++++++++++++++++- includes/api/ApiQueryLogEvents.php | 7 +++++-- includes/api/ApiQueryWatchlist.php | 9 ++++++--- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index daf3c9d2fa..2804408f4b 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index 92857edae4..2f74226707 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -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.' + ), ); } diff --git a/includes/api/ApiQueryLogEvents.php b/includes/api/ApiQueryLogEvents.php index 84bd15d6ec..beb2963e86 100644 --- a/includes/api/ApiQueryLogEvents.php +++ b/includes/api/ApiQueryLogEvents.php @@ -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) { diff --git a/includes/api/ApiQueryWatchlist.php b/includes/api/ApiQueryWatchlist.php index a70ea49730..3d38b81e8a 100644 --- a/includes/api/ApiQueryWatchlist.php +++ b/includes/api/ApiQueryWatchlist.php @@ -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); -- 2.20.1