3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
23 * Pager for Special:Contributions
26 use MediaWiki\MediaWikiServices
;
27 use MediaWiki\Storage\RevisionRecord
;
28 use Wikimedia\Rdbms\IResultWrapper
;
29 use Wikimedia\Rdbms\FakeResultWrapper
;
30 use Wikimedia\Rdbms\IDatabase
;
32 class ContribsPager
extends RangeChronologicalPager
{
35 * @var string[] Local cache for escaped messages
40 * @var string User name, or a string describing an IP address range
45 * @var string Set to "newbie" to list contributions from the most recent 1% registered users.
46 * $this->target is ignored then. Defaults to "users".
51 * @var string|int A single namespace number, or an empty string for all namespaces
53 private $namespace = '';
56 * @var string|false Name of tag to filter, or false to ignore tags
61 * @var bool Set to true to invert the namespace selection
66 * @var bool Set to true to show both the subject and talk namespace, no matter which got
72 * @var bool Set to true to show only deleted revisions
77 * @var bool Set to true to show only latest (a.k.a. current) revisions
82 * @var bool Set to true to show only new pages
87 * @var bool Set to true to hide edits marked as minor by the user
91 private $preventClickjacking = false;
94 private $mDbSecondary;
102 * @var TemplateParser
104 private $templateParser;
106 public function __construct( IContextSource
$context, array $options ) {
107 // Set ->target and ->contribs before calling parent::__construct() so
108 // parent can call $this->getIndexField() and get the right result. Set
109 // the rest too just to keep things simple.
110 $this->target
= $options['target'] ??
'';
111 $this->contribs
= $options['contribs'] ??
'users';
112 $this->namespace = $options['namespace'] ??
'';
113 $this->tagFilter
= $options['tagfilter'] ??
false;
114 $this->nsInvert
= $options['nsInvert'] ??
false;
115 $this->associated
= $options['associated'] ??
false;
117 $this->deletedOnly
= !empty( $options['deletedOnly'] );
118 $this->topOnly
= !empty( $options['topOnly'] );
119 $this->newOnly
= !empty( $options['newOnly'] );
120 $this->hideMinor
= !empty( $options['hideMinor'] );
122 parent
::__construct( $context );
131 foreach ( $msgs as $msg ) {
132 $this->messages
[$msg] = $this->msg( $msg )->escaped();
135 // Date filtering: use timestamp if available
136 $startTimestamp = '';
138 if ( $options['start'] ) {
139 $startTimestamp = $options['start'] . ' 00:00:00';
141 if ( $options['end'] ) {
142 $endTimestamp = $options['end'] . ' 23:59:59';
144 $this->getDateRangeCond( $startTimestamp, $endTimestamp );
146 // Most of this code will use the 'contributions' group DB, which can map to replica DBs
147 // with extra user based indexes or partioning by user. The additional metadata
148 // queries should use a regular replica DB since the lookup pattern is not all by user.
149 $this->mDbSecondary
= wfGetDB( DB_REPLICA
); // any random replica DB
150 $this->mDb
= wfGetDB( DB_REPLICA
, 'contributions' );
151 $this->templateParser
= new TemplateParser();
154 function getDefaultQuery() {
155 $query = parent
::getDefaultQuery();
156 $query['target'] = $this->target
;
162 * Wrap the navigation bar in a p element with identifying class.
163 * In future we may want to change the `p` tag to a `div` and upstream
164 * this to the parent class.
166 * @return string HTML
168 function getNavigationBar() {
169 return Html
::rawElement( 'p', [ 'class' => 'mw-pager-navigation-bar' ],
170 parent
::getNavigationBar()
175 * This method basically executes the exact same code as the parent class, though with
176 * a hook added, to allow extensions to add additional queries.
178 * @param string $offset Index offset, inclusive
179 * @param int $limit Exact query limit
180 * @param bool $order IndexPager::QUERY_ASCENDING or IndexPager::QUERY_DESCENDING
181 * @return IResultWrapper
183 function reallyDoQuery( $offset, $limit, $order ) {
184 list( $tables, $fields, $conds, $fname, $options, $join_conds ) = $this->buildQueryInfo(
191 * This hook will allow extensions to add in additional queries, so they can get their data
192 * in My Contributions as well. Extensions should append their results to the $data array.
194 * Extension queries have to implement the navbar requirement as well. They should
195 * - have a column aliased as $pager->getIndexField()
197 * - have a WHERE-clause that compares the $pager->getIndexField()-equivalent column to the offset
198 * - have the ORDER BY specified based upon the details provided by the navbar
200 * See includes/Pager.php buildQueryInfo() method on how to build LIMIT, WHERE & ORDER BY
202 * &$data: an array of results of all contribs queries
203 * $pager: the ContribsPager object hooked into
204 * $offset: see phpdoc above
205 * $limit: see phpdoc above
206 * $descending: see phpdoc above
208 $data = [ $this->mDb
->select(
209 $tables, $fields, $conds, $fname, $options, $join_conds
212 'ContribsPager::reallyDoQuery',
213 [ &$data, $this, $offset, $limit, $order ]
218 // loop all results and collect them in an array
219 foreach ( $data as $query ) {
220 foreach ( $query as $i => $row ) {
221 // use index column as key, allowing us to easily sort in PHP
222 $result[$row->{$this->getIndexField()} . "-$i"] = $row;
227 if ( $order === self
::QUERY_ASCENDING
) {
234 $result = array_slice( $result, 0, $limit );
236 // get rid of array keys
237 $result = array_values( $result );
239 return new FakeResultWrapper( $result );
243 * Return the table targeted for ordering and continuation
245 * See T200259 and T221380.
247 * @warning Keep this in sync with self::getQueryInfo()!
251 private function getTargetTable() {
252 if ( $this->contribs
== 'newbie' ) {
256 $user = User
::newFromName( $this->target
, false );
257 $ipRangeConds = $user->isAnon() ?
$this->getIpRangeConds( $this->mDb
, $this->target
) : null;
258 if ( $ipRangeConds ) {
261 $conds = ActorMigration
::newMigration()->getWhere( $this->mDb
, 'rev_user', $user );
262 if ( isset( $conds['orconds']['actor'] ) ) {
263 // @todo: This will need changing when revision_actor_temp goes away
264 return 'revision_actor_temp';
271 function getQueryInfo() {
272 $revQuery = Revision
::getQueryInfo( [ 'page', 'user' ] );
274 'tables' => $revQuery['tables'],
275 'fields' => array_merge( $revQuery['fields'], [ 'page_is_new' ] ),
278 'join_conds' => $revQuery['joins'],
281 // WARNING: Keep this in sync with getTargetTable()!
283 if ( $this->contribs
== 'newbie' ) {
284 $max = $this->mDb
->selectField( 'user', 'max(user_id)', '', __METHOD__
);
285 $queryInfo['conds'][] = $revQuery['fields']['rev_user'] . ' >' . (int)( $max - $max / 100 );
286 # ignore local groups with the bot right
287 # @todo FIXME: Global groups may have 'bot' rights
288 $groupsWithBotPermission = MediaWikiServices
::getInstance()
289 ->getPermissionManager()
290 ->getGroupsWithPermission( 'bot' );
291 if ( count( $groupsWithBotPermission ) ) {
292 $queryInfo['tables'][] = 'user_groups';
293 $queryInfo['conds'][] = 'ug_group IS NULL';
294 $queryInfo['join_conds']['user_groups'] = [
296 'ug_user = ' . $revQuery['fields']['rev_user'],
297 'ug_group' => $groupsWithBotPermission,
298 'ug_expiry IS NULL OR ug_expiry >= ' .
299 $this->mDb
->addQuotes( $this->mDb
->timestamp() )
303 // (T140537) Disallow looking too far in the past for 'newbies' queries. If the user requested
304 // a timestamp offset far in the past such that there are no edits by users with user_ids in
305 // the range, we would end up scanning all revisions from that offset until start of time.
306 $queryInfo['conds'][] = 'rev_timestamp > ' .
307 $this->mDb
->addQuotes( $this->mDb
->timestamp( wfTimestamp() - 30 * 24 * 60 * 60 ) );
309 $user = User
::newFromName( $this->target
, false );
310 $ipRangeConds = $user->isAnon() ?
$this->getIpRangeConds( $this->mDb
, $this->target
) : null;
311 if ( $ipRangeConds ) {
312 $queryInfo['tables'][] = 'ip_changes';
313 $queryInfo['join_conds']['ip_changes'] = [
314 'LEFT JOIN', [ 'ipc_rev_id = rev_id' ]
316 $queryInfo['conds'][] = $ipRangeConds;
318 // tables and joins are already handled by Revision::getQueryInfo()
319 $conds = ActorMigration
::newMigration()->getWhere( $this->mDb
, 'rev_user', $user );
320 $queryInfo['conds'][] = $conds['conds'];
321 // Force the appropriate index to avoid bad query plans (T189026)
322 if ( isset( $conds['orconds']['actor'] ) ) {
323 // @todo: This will need changing when revision_actor_temp goes away
324 $queryInfo['options']['USE INDEX']['temp_rev_user'] = 'actor_timestamp';
326 $queryInfo['options']['USE INDEX']['revision'] =
327 isset( $conds['orconds']['userid'] ) ?
'user_timestamp' : 'usertext_timestamp';
332 if ( $this->deletedOnly
) {
333 $queryInfo['conds'][] = 'rev_deleted != 0';
336 if ( $this->topOnly
) {
337 $queryInfo['conds'][] = 'rev_id = page_latest';
340 if ( $this->newOnly
) {
341 $queryInfo['conds'][] = 'rev_parent_id = 0';
344 if ( $this->hideMinor
) {
345 $queryInfo['conds'][] = 'rev_minor_edit = 0';
348 $user = $this->getUser();
349 $queryInfo['conds'] = array_merge( $queryInfo['conds'], $this->getNamespaceCond() );
351 // Paranoia: avoid brute force searches (T19342)
352 if ( !$user->isAllowed( 'deletedhistory' ) ) {
353 $queryInfo['conds'][] = $this->mDb
->bitAnd(
354 'rev_deleted', RevisionRecord
::DELETED_USER
356 } elseif ( !MediaWikiServices
::getInstance()
357 ->getPermissionManager()
358 ->userHasAnyRight( $user, 'suppressrevision', 'viewsuppressed' )
360 $queryInfo['conds'][] = $this->mDb
->bitAnd(
361 'rev_deleted', RevisionRecord
::SUPPRESSED_USER
362 ) . ' != ' . RevisionRecord
::SUPPRESSED_USER
;
365 // $this->getIndexField() must be in the result rows, as reallyDoQuery() tries to access it.
366 $indexField = $this->getIndexField();
367 if ( $indexField !== 'rev_timestamp' ) {
368 $queryInfo['fields'][] = $indexField;
371 ChangeTags
::modifyDisplayQuery(
372 $queryInfo['tables'],
373 $queryInfo['fields'],
375 $queryInfo['join_conds'],
376 $queryInfo['options'],
380 // Avoid PHP 7.1 warning from passing $this by reference
382 Hooks
::run( 'ContribsPager::getQueryInfo', [ &$pager, &$queryInfo ] );
387 function getNamespaceCond() {
388 if ( $this->namespace !== '' ) {
389 $selectedNS = $this->mDb
->addQuotes( $this->namespace );
390 $eq_op = $this->nsInvert ?
'!=' : '=';
391 $bool_op = $this->nsInvert ?
'AND' : 'OR';
393 if ( !$this->associated
) {
394 return [ "page_namespace $eq_op $selectedNS" ];
397 $associatedNS = $this->mDb
->addQuotes(
398 MediaWikiServices
::getInstance()->getNamespaceInfo()->getAssociated( $this->namespace )
402 "page_namespace $eq_op $selectedNS " .
404 " page_namespace $eq_op $associatedNS"
412 * Get SQL conditions for an IP range, if applicable
413 * @param IDatabase $db
414 * @param string $ip The IP address or CIDR
415 * @return string|false SQL for valid IP ranges, false if invalid
417 private function getIpRangeConds( $db, $ip ) {
418 // First make sure it is a valid range and they are not outside the CIDR limit
419 if ( !$this->isQueryableRange( $ip ) ) {
423 list( $start, $end ) = IP
::parseRange( $ip );
425 return 'ipc_hex BETWEEN ' . $db->addQuotes( $start ) . ' AND ' . $db->addQuotes( $end );
429 * Is the given IP a range and within the CIDR limit?
431 * @param string $ipRange
432 * @return bool True if it is valid
435 public function isQueryableRange( $ipRange ) {
436 $limits = $this->getConfig()->get( 'RangeContributionsCIDRLimit' );
438 $bits = IP
::parseCIDR( $ipRange )[1];
440 ( $bits === false ) ||
441 ( IP
::isIPv4( $ipRange ) && $bits < $limits['IPv4'] ) ||
442 ( IP
::isIPv6( $ipRange ) && $bits < $limits['IPv6'] )
453 public function getIndexField() {
454 // The returned column is used for sorting and continuation, so we need to
455 // make sure to use the right denormalized column depending on which table is
456 // being targeted by the query to avoid bad query plans.
457 // See T200259, T204669, T220991, and T221380.
458 $target = $this->getTargetTable();
461 return 'rev_timestamp';
463 return 'ipc_rev_timestamp';
464 case 'revision_actor_temp':
465 return 'revactor_timestamp';
468 __METHOD__
. ": Unknown value '$target' from " . static::class . '::getTargetTable()', 0
470 return 'rev_timestamp';
475 * @return false|string
477 public function getTagFilter() {
478 return $this->tagFilter
;
484 public function getContribs() {
485 return $this->contribs
;
491 public function getTarget() {
492 return $this->target
;
498 public function isNewOnly() {
499 return $this->newOnly
;
505 public function getNamespace() {
506 return $this->namespace;
512 protected function getExtraSortFields() {
513 // The returned columns are used for sorting, so we need to make sure
514 // to use the right denormalized column depending on which table is
515 // being targeted by the query to avoid bad query plans.
516 // See T200259, T204669, T220991, and T221380.
517 $target = $this->getTargetTable();
522 return [ 'ipc_rev_id' ];
523 case 'revision_actor_temp':
524 return [ 'revactor_rev' ];
527 __METHOD__
. ": Unknown value '$target' from " . static::class . '::getTargetTable()', 0
533 protected function doBatchLookups() {
534 # Do a link batch query
535 $this->mResult
->seek( 0 );
537 $this->mParentLens
= [];
538 $batch = new LinkBatch();
539 $isIpRange = $this->isQueryableRange( $this->target
);
540 # Give some pointers to make (last) links
541 foreach ( $this->mResult
as $row ) {
542 if ( isset( $row->rev_parent_id
) && $row->rev_parent_id
) {
543 $parentRevIds[] = $row->rev_parent_id
;
545 if ( isset( $row->rev_id
) ) {
546 $this->mParentLens
[$row->rev_id
] = $row->rev_len
;
547 if ( $this->contribs
=== 'newbie' ) { // multiple users
548 $batch->add( NS_USER
, $row->user_name
);
549 $batch->add( NS_USER_TALK
, $row->user_name
);
550 } elseif ( $isIpRange ) {
551 // If this is an IP range, batch the IP's talk page
552 $batch->add( NS_USER_TALK
, $row->rev_user_text
);
554 $batch->add( $row->page_namespace
, $row->page_title
);
557 # Fetch rev_len for revisions not already scanned above
558 $this->mParentLens +
= Revision
::getParentLengths(
560 array_diff( $parentRevIds, array_keys( $this->mParentLens
) )
563 $this->mResult
->seek( 0 );
569 protected function getStartBody() {
570 return "<ul class=\"mw-contributions-list\">\n";
576 protected function getEndBody() {
581 * Check whether the revision associated is valid for formatting. If has no associated revision
582 * id then null is returned.
585 * @param Title|null $title
586 * @return Revision|null
588 public function tryToCreateValidRevision( $row, $title = null ) {
590 * There may be more than just revision rows. To make sure that we'll only be processing
591 * revisions here, let's _try_ to build a revision out of our row (without displaying
592 * notices though) and then trying to grab data from the built object. If we succeed,
593 * we're definitely dealing with revision data and we may proceed, if not, we'll leave it
594 * to extensions to subscribe to the hook to parse the row.
596 Wikimedia\
suppressWarnings();
598 $rev = new Revision( $row, 0, $title );
599 $validRevision = (bool)$rev->getId();
600 } catch ( Exception
$e ) {
601 $validRevision = false;
603 Wikimedia\restoreWarnings
();
604 return $validRevision ?
$rev : null;
608 * Generates each row in the contributions list.
610 * Contributions which are marked "top" are currently on top of the history.
611 * For these contributions, a [rollback] link is shown for users with roll-
612 * back privileges. The rollback link restores the most recent version that
613 * was not written by the target user.
615 * @todo This would probably look a lot nicer in a table.
619 function formatRow( $row ) {
624 $linkRenderer = MediaWikiServices
::getInstance()->getLinkRenderer();
627 // Create a title for the revision if possible
628 // Rows from the hook may not include title information
629 if ( isset( $row->page_namespace
) && isset( $row->page_title
) ) {
630 $page = Title
::newFromRow( $row );
632 $rev = $this->tryToCreateValidRevision( $row, $page );
634 $attribs['data-mw-revid'] = $rev->getId();
636 $link = $linkRenderer->makeLink(
638 $page->getPrefixedText(),
639 [ 'class' => 'mw-contributions-title' ],
640 $page->isRedirect() ?
[ 'redirect' => 'no' ] : []
642 # Mark current revisions
644 $user = $this->getUser();
646 if ( $row->rev_id
=== $row->page_latest
) {
647 $topmarktext .= '<span class="mw-uctop">' . $this->messages
['uctop'] . '</span>';
648 $classes[] = 'mw-contributions-current';
650 if ( !$row->page_is_new
&& $page->quickUserCan( 'rollback', $user )
651 && $page->quickUserCan( 'edit', $user )
653 $this->preventClickjacking();
654 $topmarktext .= ' ' . Linker
::generateRollback( $rev, $this->getContext(),
658 # Is there a visible previous revision?
659 if ( $rev->userCan( RevisionRecord
::DELETED_TEXT
, $user ) && $rev->getParentId() !== 0 ) {
660 $difftext = $linkRenderer->makeKnownLink(
662 new HtmlArmor( $this->messages
['diff'] ),
663 [ 'class' => 'mw-changeslist-diff' ],
666 'oldid' => $row->rev_id
670 $difftext = $this->messages
['diff'];
672 $histlink = $linkRenderer->makeKnownLink(
674 new HtmlArmor( $this->messages
['hist'] ),
675 [ 'class' => 'mw-changeslist-history' ],
676 [ 'action' => 'history' ]
679 if ( $row->rev_parent_id
=== null ) {
680 // For some reason rev_parent_id isn't populated for this row.
681 // Its rumoured this is true on wikipedia for some revisions (T36922).
682 // Next best thing is to have the total number of bytes.
683 $chardiff = ' <span class="mw-changeslist-separator"></span> ';
684 $chardiff .= Linker
::formatRevisionSize( $row->rev_len
);
685 $chardiff .= ' <span class="mw-changeslist-separator"></span> ';
688 if ( isset( $this->mParentLens
[$row->rev_parent_id
] ) ) {
689 $parentLen = $this->mParentLens
[$row->rev_parent_id
];
692 $chardiff = ' <span class="mw-changeslist-separator"></span> ';
693 $chardiff .= ChangesList
::showCharacterDifference(
698 $chardiff .= ' <span class="mw-changeslist-separator"></span> ';
701 $lang = $this->getLanguage();
702 $comment = $lang->getDirMark() . Linker
::revComment( $rev, false, true, false );
703 $d = ChangesList
::revDateLink( $rev, $user, $lang, $page );
705 # Show user names for /newbies as there may be different users.
706 # Note that only unprivileged users have rows with hidden user names excluded.
707 # When querying for an IP range, we want to always show user and user talk links.
709 if ( ( $this->contribs
== 'newbie' && !$rev->isDeleted( RevisionRecord
::DELETED_USER
) )
710 ||
$this->isQueryableRange( $this->target
) ) {
711 $userlink = ' <span class="mw-changeslist-separator"></span> '
712 . $lang->getDirMark()
713 . Linker
::userLink( $rev->getUser(), $rev->getUserText() );
714 $userlink .= ' ' . $this->msg( 'parentheses' )->rawParams(
715 Linker
::userTalkLink( $rev->getUser(), $rev->getUserText() ) )->escaped() . ' ';
719 if ( $rev->getParentId() === 0 ) {
720 $flags[] = ChangesList
::flag( 'newpage' );
723 if ( $rev->isMinor() ) {
724 $flags[] = ChangesList
::flag( 'minor' );
727 $del = Linker
::getRevDeleteLink( $user, $rev, $page );
732 // While it might be tempting to use a list here
733 // this would result in clutter and slows down navigating the content
734 // in assistive technology.
735 // See https://phabricator.wikimedia.org/T205581#4734812
736 $diffHistLinks = Html
::rawElement( 'span',
737 [ 'class' => 'mw-changeslist-links' ],
738 // The spans are needed to ensure the dividing '|' elements are not
739 // themselves styled as links.
740 Html
::rawElement( 'span', [], $difftext ) .
741 ' ' . // Space needed for separating two words.
742 Html
::rawElement( 'span', [], $histlink )
746 list( $tagSummary, $newClasses ) = ChangeTags
::formatSummaryRow(
751 $classes = array_merge( $classes, $newClasses );
753 Hooks
::run( 'SpecialContributions::formatRow::flags', [ $this->getContext(), $row, &$flags ] );
758 'diffHistLinks' => $diffHistLinks,
759 'charDifference' => $chardiff,
761 'articleLink' => $link,
762 'userlink' => $userlink,
763 'logText' => $comment,
764 'topmarktext' => $topmarktext,
765 'tagSummary' => $tagSummary,
768 # Denote if username is redacted for this edit
769 if ( $rev->isDeleted( RevisionRecord
::DELETED_USER
) ) {
770 $templateParams['rev-deleted-user-contribs'] =
771 $this->msg( 'rev-deleted-user-contribs' )->escaped();
774 $ret = $this->templateParser
->processTemplate(
775 'SpecialContributionsLine',
780 // Let extensions add data
781 Hooks
::run( 'ContributionsLineEnding', [ $this, &$ret, $row, &$classes, &$attribs ] );
782 $attribs = array_filter( $attribs,
783 [ Sanitizer
::class, 'isReservedDataAttribute' ],
787 // TODO: Handle exceptions in the catch block above. Do any extensions rely on
788 // receiving empty rows?
790 if ( $classes === [] && $attribs === [] && $ret === '' ) {
791 wfDebug( "Dropping Special:Contribution row that could not be formatted\n" );
792 return "<!-- Could not format Special:Contribution row. -->\n";
794 $attribs['class'] = $classes;
796 // FIXME: The signature of the ContributionsLineEnding hook makes it
797 // very awkward to move this LI wrapper into the template.
798 return Html
::rawElement( 'li', $attribs, $ret ) . "\n";
802 * Overwrite Pager function and return a helpful comment
805 function getSqlComment() {
806 if ( $this->namespace ||
$this->deletedOnly
) {
807 // potentially slow, see CR r58153
808 return 'contributions page filtered for namespace or RevisionDeleted edits';
810 return 'contributions page unfiltered';
814 protected function preventClickjacking() {
815 $this->preventClickjacking
= true;
821 public function getPreventClickjacking() {
822 return $this->preventClickjacking
;
826 * Set up date filter options, given request data.
828 * @param array $opts Options array
829 * @return array Options array with processed start and end date filter options
831 public static function processDateFilter( array $opts ) {
832 $start = $opts['start'] ??
'';
833 $end = $opts['end'] ??
'';
834 $year = $opts['year'] ??
'';
835 $month = $opts['month'] ??
'';
837 if ( $start !== '' && $end !== '' && $start > $end ) {
843 // If year/month legacy filtering options are set, convert them to display the new stamp
844 if ( $year !== '' ||
$month !== '' ) {
845 // Reuse getDateCond logic, but subtract a day because
846 // the endpoints of our date range appear inclusive
847 // but the internal end offsets are always exclusive
848 $legacyTimestamp = ReverseChronologicalPager
::getOffsetDate( $year, $month );
849 $legacyDateTime = new DateTime( $legacyTimestamp->getTimestamp( TS_ISO_8601
) );
850 $legacyDateTime = $legacyDateTime->modify( '-1 day' );
852 // Clear the new timestamp range options if used and
853 // replace with the converted legacy timestamp
855 $end = $legacyDateTime->format( 'Y-m-d' );
858 $opts['start'] = $start;