API: Fix parameter interpretation in ApiFeedRecentChanges
authorBrad Jorsch <bjorsch@wikimedia.org>
Sat, 25 Apr 2015 11:20:43 +0000 (07:20 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Sat, 25 Apr 2015 11:23:51 +0000 (07:23 -0400)
ApiFeedRecentChanges uses special page logic (eew) to do its thing.
Lacking the time at the moment to refactor the business logic, let's at
least pass the parsed parameters in via a FauxRequest instead of
allowing the special page logic to do its own interpretation of the raw
parameters.

This makes it so all recognized timestamp formats are supported (instead
of only TS_MW) and fixes the interpretation of booleans to match API
standards.

Bug: T97213
Change-Id: Ia254e36b5df2e552e283fb57ce859d6478908bd9

includes/api/ApiFeedRecentChanges.php

index d452bbd..d24112c 100644 (file)
@@ -66,9 +66,17 @@ class ApiFeedRecentChanges extends ApiBase {
 
                $formatter = $this->getFeedObject( $feedFormat, $specialClass );
 
-               // Everything is passed implicitly via $wgRequest… :(
-               // The row-getting functionality should maybe be factored out of ChangesListSpecialPage too…
+               // Parameters are passed via the request in the context… :(
+               $context = new DerivativeContext( $this );
+               $context->setRequest( new DerivativeRequest(
+                       $this->getRequest(),
+                       $this->params,
+                       $this->getRequest()->wasPosted()
+               ) );
+
+               // The row-getting functionality should be factored out of ChangesListSpecialPage too…
                $rc = new $specialClass();
+               $rc->setContext( $context );
                $rows = $rc->getRows();
 
                $feedItems = $rows ? ChangesFeed::buildItems( $rows ) : array();