r44232 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44231‎ | r44232 | r44233 >
Date:15:51, 4 December 2008
Author:catrope
Status:resolved
Tags:
Comment:
API: (bug 16515) Added pst and onlypst parameters to action=parse, which do a pre-save transform on the input
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiParse.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryLogEvents.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryWatchlist.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiParse.php
@@ -111,6 +111,16 @@
112112 $titleObj = Title::newFromText($title);
113113 if(!$titleObj)
114114 $titleObj = Title::newFromText("API");
 115+ if($params['pst'] || $params['onlypst'])
 116+ $text = $wgParser->preSaveTransform($text, $titleObj, $wgUser, $popts);
 117+ if($params['onlypst'])
 118+ {
 119+ // Build a result and bail out
 120+ $result_array['text'] = array();
 121+ $this->getResult()->setContent($result_array['text'], $text);
 122+ $this->getResult()->addValue(null, $this->getModuleName(), $result_array);
 123+ return;
 124+ }
115125 $p_result = $wgParser->parse($text, $titleObj, $popts);
116126 }
117127
@@ -222,7 +232,9 @@
223233 'sections',
224234 'revid'
225235 )
226 - )
 236+ ),
 237+ 'pst' => false,
 238+ 'onlypst' => false,
227239 );
228240 }
229241
@@ -236,6 +248,12 @@
237249 'prop' => array('Which pieces of information to get.',
238250 'NOTE: Section tree is only generated if there are more than 4 sections, or if the __TOC__ keyword is present'
239251 ),
 252+ 'pst' => array( 'Do a pre-save transform on the input before parsing it.',
 253+ 'Ignored if page or oldid is used.'
 254+ ),
 255+ 'onlypst' => array('Do a PST on the input, but don\'t parse it.',
 256+ 'Returns PSTed wikitext. Ignored if page or oldid is used.'
 257+ ),
240258 );
241259 }
242260
Index: trunk/phase3/includes/api/ApiQueryLogEvents.php
@@ -140,7 +140,7 @@
141141 $this->getResult()->addValue('query', $this->getModuleName(), $data);
142142 }
143143
144 - public static function addLogParams($result, &$vals, $params, $type) {
 144+ public static function addLogParams($result, &$vals, $params, $type, $ts) {
145145 $params = explode("\n", $params);
146146 switch ($type) {
147147 case 'move':
@@ -169,6 +169,8 @@
170170 case 'block':
171171 $vals2 = array();
172172 list( $vals2['duration'], $vals2['flags'] ) = $params;
 173+ $vals2['expiry'] = wfTimestamp(TS_ISO_8601,
 174+ strtotime($params[0], wfTimestamp(TS_UNIX, $ts)));
173175 $vals[$type] = $vals2;
174176 $params = null;
175177 break;
@@ -200,7 +202,8 @@
201203
202204 if ($this->fld_details && $row->log_params !== '') {
203205 self::addLogParams($this->getResult(), $vals,
204 - $row->log_params, $row->log_type);
 206+ $row->log_params, $row->log_type,
 207+ $row->log_timestamp);
205208 }
206209
207210 if ($this->fld_user) {
Index: trunk/phase3/includes/api/ApiQueryWatchlist.php
@@ -118,7 +118,6 @@
119119
120120 $this->addTables(array (
121121 'watchlist',
122 - 'page',
123122 'recentchanges'
124123 ));
125124
@@ -126,14 +125,18 @@
127126 $this->addWhere(array (
128127 'wl_namespace = rc_namespace',
129128 'wl_title = rc_title',
130 - 'rc_cur_id = page_id',
131129 'wl_user' => $userId,
132130 'rc_deleted' => 0,
133131 ));
134132
135133 $this->addWhereRange('rc_timestamp', $dir, $start, $end);
136134 $this->addWhereFld('wl_namespace', $namespace);
137 - $this->addWhereIf('rc_this_oldid=page_latest', !$allrev);
 135+ if(!$allrev)
 136+ {
 137+ $this->addTables('page');
 138+ $this->addWhere('page_id=rc_cur_id');
 139+ $this->addWhereIf('rc_this_oldid=page_latest');
 140+ }
138141
139142 if (!is_null($show)) {
140143 $show = array_flip($show);
Index: trunk/phase3/RELEASE-NOTES
@@ -482,6 +482,7 @@
483483 * (bug 16516) Made rvsection=T-2 work
484484 * (bug 16526) Added usprop=emailable to list=users
485485 * (bug 16548) list=search threw errors with an invalid error code
 486+* (bug 16515) Added pst and onlypst parameters to action=parse
486487
487488 === Languages updated in 1.14 ===
488489

Follow-up revisions

RevisionCommit summaryAuthorDate
r44233Revert part of r44232, accidentally committed too muchcatrope15:55, 4 December 2008

Status & tagging log