$feedUrl
);
+ // Convert year/month parameters to end parameter
+ $params['start'] = '';
+ $params['end'] = '';
+ $params = ContribsPager::processDateFilter( $params );
+
$pager = new ContribsPager( $this->getContext(), [
'target' => $target,
'namespace' => $params['namespace'],
- 'year' => $params['year'],
- 'month' => $params['month'],
+ 'start' => $params['start'],
+ 'end' => $params['end'],
'tagFilter' => $params['tagfilter'],
'deletedOnly' => $params['deletedonly'],
'topOnly' => $params['toponly'],
$this->opts['start'] = $request->getVal( 'start' );
$this->opts['end'] = $request->getVal( 'end' );
- $this->opts = SpecialContributions::processDateFilter( $this->opts );
+ $this->opts = ContribsPager::processDateFilter( $this->opts );
}
$feedType = $request->getVal( 'feed' );
return UserNamePrefixSearch::search( 'public', $search, $limit, $offset );
}
- /**
- * Set up date filter options, given request data.
- *
- * @param array $opts Options array
- * @return array Options array with processed start and end date filter options
- */
- public static function processDateFilter( $opts ) {
- $start = $opts['start'] ?: '';
- $end = $opts['end'] ?: '';
- $year = $opts['year'] ?: '';
- $month = $opts['month'] ?: '';
-
- if ( $start !== '' && $end !== '' &&
- $start > $end
- ) {
- $temp = $start;
- $start = $end;
- $end = $temp;
- }
-
- // If year/month legacy filtering options are set, convert them to display the new stamp
- if ( $year !== '' || $month !== '' ) {
- // Reuse getDateCond logic, but subtract a day because
- // the endpoints of our date range appear inclusive
- // but the internal end offsets are always exclusive
- $legacyTimestamp = ReverseChronologicalPager::getOffsetDate( $year, $month );
- $legacyDateTime = new DateTime( $legacyTimestamp->getTimestamp( TS_ISO_8601 ) );
- $legacyDateTime = $legacyDateTime->modify( '-1 day' );
-
- // Clear the new timestamp range options if used and
- // replace with the converted legacy timestamp
- $start = '';
- $end = $legacyDateTime->format( 'Y-m-d' );
- }
-
- $opts['start'] = $start;
- $opts['end'] = $end;
- return $opts;
- }
-
protected function getGroupName() {
return 'users';
}
public function getPreventClickjacking() {
return $this->preventClickjacking;
}
+
+ /**
+ * Set up date filter options, given request data.
+ *
+ * @param array $opts Options array
+ * @return array Options array with processed start and end date filter options
+ */
+ public static function processDateFilter( $opts ) {
+ $start = $opts['start'] ?: '';
+ $end = $opts['end'] ?: '';
+ $year = $opts['year'] ?: '';
+ $month = $opts['month'] ?: '';
+
+ if ( $start !== '' && $end !== '' && $start > $end ) {
+ $temp = $start;
+ $start = $end;
+ $end = $temp;
+ }
+
+ // If year/month legacy filtering options are set, convert them to display the new stamp
+ if ( $year !== '' || $month !== '' ) {
+ // Reuse getDateCond logic, but subtract a day because
+ // the endpoints of our date range appear inclusive
+ // but the internal end offsets are always exclusive
+ $legacyTimestamp = ReverseChronologicalPager::getOffsetDate( $year, $month );
+ $legacyDateTime = new DateTime( $legacyTimestamp->getTimestamp( TS_ISO_8601 ) );
+ $legacyDateTime = $legacyDateTime->modify( '-1 day' );
+
+ // Clear the new timestamp range options if used and
+ // replace with the converted legacy timestamp
+ $start = '';
+ $end = $legacyDateTime->format( 'Y-m-d' );
+ }
+
+ $opts['start'] = $start;
+ $opts['end'] = $end;
+
+ return $opts;
+ }
}
--- /dev/null
+<?php
+
+/**
+ * @group Database
+ */
+class ContribsPagerTest extends \PHPUnit_Framework_TestCase {
+ /**
+ * @dataProvider dateFilterOptionProcessingProvider
+ * @param array $inputOpts Input options
+ * @param array $expectedOpts Expected options
+ */
+ public function testDateFilterOptionProcessing( $inputOpts, $expectedOpts ) {
+ $this->assertArraySubset( $expectedOpts, ContribsPager::processDateFilter( $inputOpts ) );
+ }
+
+ public static function dateFilterOptionProcessingProvider() {
+ return [
+ [ [ 'start' => '2016-05-01',
+ 'end' => '2016-06-01',
+ 'year' => null,
+ 'month' => null ],
+ [ 'start' => '2016-05-01',
+ 'end' => '2016-06-01' ] ],
+ [ [ 'start' => '2016-05-01',
+ 'end' => '2016-06-01',
+ 'year' => '',
+ 'month' => '' ],
+ [ 'start' => '2016-05-01',
+ 'end' => '2016-06-01' ] ],
+ [ [ 'start' => '2016-05-01',
+ 'end' => '2016-06-01',
+ 'year' => '2012',
+ 'month' => '5' ],
+ [ 'start' => '',
+ 'end' => '2012-05-31' ] ],
+ [ [ 'start' => '',
+ 'end' => '',
+ 'year' => '2012',
+ 'month' => '5' ],
+ [ 'start' => '',
+ 'end' => '2012-05-31' ] ],
+ [ [ 'start' => '',
+ 'end' => '',
+ 'year' => '2012',
+ 'month' => '' ],
+ [ 'start' => '',
+ 'end' => '2012-12-31' ] ],
+ ];
+ }
+}
+++ /dev/null
-<?php
-
-/**
- * @group Database
- */
-class SpecialContributionsTest extends \PHPUnit_Framework_TestCase {
- /**
- * @dataProvider dateFilterOptionProcessingProvider
- * @param array $inputOpts Input options
- * @param array $expectedOpts Expected options
- */
- public function testDateFilterOptionProcessing( $inputOpts, $expectedOpts ) {
- $this->assertArraySubset( $expectedOpts, SpecialContributions::processDateFilter( $inputOpts ) );
- }
-
- public static function dateFilterOptionProcessingProvider() {
- return [
- [ [ 'start' => '2016-05-01',
- 'end' => '2016-06-01',
- 'year' => null,
- 'month' => null ],
- [ 'start' => '2016-05-01',
- 'end' => '2016-06-01' ] ],
- [ [ 'start' => '2016-05-01',
- 'end' => '2016-06-01',
- 'year' => '',
- 'month' => '' ],
- [ 'start' => '2016-05-01',
- 'end' => '2016-06-01' ] ],
- [ [ 'start' => '2016-05-01',
- 'end' => '2016-06-01',
- 'year' => '2012',
- 'month' => '5' ],
- [ 'start' => '',
- 'end' => '2012-05-31' ] ],
- [ [ 'start' => '',
- 'end' => '',
- 'year' => '2012',
- 'month' => '5' ],
- [ 'start' => '',
- 'end' => '2012-05-31' ] ],
- [ [ 'start' => '',
- 'end' => '',
- 'year' => '2012',
- 'month' => '' ],
- [ 'start' => '',
- 'end' => '2012-12-31' ] ],
- ];
- }
-}