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 Wikimedia\Rdbms\IResultWrapper
;
28 use Wikimedia\Rdbms\FakeResultWrapper
;
29 use Wikimedia\Rdbms\IDatabase
;
31 class ContribsPager
extends RangeChronologicalPager
{
34 * @var string[] Local cache for escaped messages
39 * @var string User name, or a string describing an IP address range
44 * @var string Set to "newbie" to list contributions from the most recent 1% registered users.
45 * $this->target is ignored then. Defaults to "users".
50 * @var string|int A single namespace number, or an empty string for all namespaces
52 private $namespace = '';
55 * @var string|false Name of tag to filter, or false to ignore tags
60 * @var bool Set to true to invert the namespace selection
65 * @var bool Set to true to show both the subject and talk namespace, no matter which got
71 * @var bool Set to true to show only deleted revisions
76 * @var bool Set to true to show only latest (a.k.a. current) revisions
81 * @var bool Set to true to show only new pages
86 * @var bool Set to true to hide edits marked as minor by the user
90 private $preventClickjacking = false;
93 private $mDbSecondary;
101 * @var TemplateParser
103 private $templateParser;
105 public function __construct( IContextSource
$context, array $options ) {
106 // Set ->target and ->contribs before calling parent::__construct() so
107 // parent can call $this->getIndexField() and get the right result. Set
108 // the rest too just to keep things simple.
109 $this->target
= $options['target'] ??
'';
110 $this->contribs
= $options['contribs'] ??
'users';
111 $this->namespace = $options['namespace'] ??
'';
112 $this->tagFilter
= $options['tagfilter'] ??
false;
113 $this->nsInvert
= $options['nsInvert'] ??
false;
114 $this->associated
= $options['associated'] ??
false;
116 $this->deletedOnly
= !empty( $options['deletedOnly'] );
117 $this->topOnly
= !empty( $options['topOnly'] );
118 $this->newOnly
= !empty( $options['newOnly'] );
119 $this->hideMinor
= !empty( $options['hideMinor'] );
121 parent
::__construct( $context );
130 foreach ( $msgs as $msg ) {
131 $this->messages
[$msg] = $this->msg( $msg )->escaped();
134 // Date filtering: use timestamp if available
135 $startTimestamp = '';
137 if ( $options['start'] ) {
138 $startTimestamp = $options['start'] . ' 00:00:00';
140 if ( $options['end'] ) {
141 $endTimestamp = $options['end'] . ' 23:59:59';
143 $this->getDateRangeCond( $startTimestamp, $endTimestamp );
145 // Most of this code will use the 'contributions' group DB, which can map to replica DBs
146 // with extra user based indexes or partioning by user. The additional metadata
147 // queries should use a regular replica DB since the lookup pattern is not all by user.
148 $this->mDbSecondary
= wfGetDB( DB_REPLICA
); // any random replica DB
149 $this->mDb
= wfGetDB( DB_REPLICA
, 'contributions' );
150 $this->templateParser
= new TemplateParser();
153 function getDefaultQuery() {
154 $query = parent
::getDefaultQuery();
155 $query['target'] = $this->target
;
161 * Wrap the navigation bar in a p element with identifying class.
162 * In future we may want to change the `p` tag to a `div` and upstream
163 * this to the parent class.
165 * @return string HTML
167 function getNavigationBar() {
168 return Html
::rawElement( 'p', [ 'class' => 'mw-pager-navigation-bar' ],
169 parent
::getNavigationBar()
174 * This method basically executes the exact same code as the parent class, though with
175 * a hook added, to allow extensions to add additional queries.
177 * @param string $offset Index offset, inclusive
178 * @param int $limit Exact query limit
179 * @param bool $order IndexPager::QUERY_ASCENDING or IndexPager::QUERY_DESCENDING
180 * @return IResultWrapper
182 function reallyDoQuery( $offset, $limit, $order ) {
183 list( $tables, $fields, $conds, $fname, $options, $join_conds ) = $this->buildQueryInfo(
190 * This hook will allow extensions to add in additional queries, so they can get their data
191 * in My Contributions as well. Extensions should append their results to the $data array.
193 * Extension queries have to implement the navbar requirement as well. They should
194 * - have a column aliased as $pager->getIndexField()
196 * - have a WHERE-clause that compares the $pager->getIndexField()-equivalent column to the offset
197 * - have the ORDER BY specified based upon the details provided by the navbar
199 * See includes/Pager.php buildQueryInfo() method on how to build LIMIT, WHERE & ORDER BY
201 * &$data: an array of results of all contribs queries
202 * $pager: the ContribsPager object hooked into
203 * $offset: see phpdoc above
204 * $limit: see phpdoc above
205 * $descending: see phpdoc above
207 $data = [ $this->mDb
->select(
208 $tables, $fields, $conds, $fname, $options, $join_conds
211 'ContribsPager::reallyDoQuery',
212 [ &$data, $this, $offset, $limit, $order ]
217 // loop all results and collect them in an array
218 foreach ( $data as $query ) {
219 foreach ( $query as $i => $row ) {
220 // use index column as key, allowing us to easily sort in PHP
221 $result[$row->{$this->getIndexField()} . "-$i"] = $row;
226 if ( $order === self
::QUERY_ASCENDING
) {
233 $result = array_slice( $result, 0, $limit );
235 // get rid of array keys
236 $result = array_values( $result );
238 return new FakeResultWrapper( $result );
242 * Return the table targeted for ordering and continuation
244 * See T200259 and T221380.
246 * @warning Keep this in sync with self::getQueryInfo()!
250 private function getTargetTable() {
251 if ( $this->contribs
== 'newbie' ) {
255 $user = User
::newFromName( $this->target
, false );
256 $ipRangeConds = $user->isAnon() ?
$this->getIpRangeConds( $this->mDb
, $this->target
) : null;
257 if ( $ipRangeConds ) {
260 $conds = ActorMigration
::newMigration()->getWhere( $this->mDb
, 'rev_user', $user );
261 if ( isset( $conds['orconds']['actor'] ) ) {
262 // @todo: This will need changing when revision_actor_temp goes away
263 return 'revision_actor_temp';
270 function getQueryInfo() {
271 $revQuery = Revision
::getQueryInfo( [ 'page', 'user' ] );
273 'tables' => $revQuery['tables'],
274 'fields' => array_merge( $revQuery['fields'], [ 'page_is_new' ] ),
277 'join_conds' => $revQuery['joins'],
280 // WARNING: Keep this in sync with getTargetTable()!
282 if ( $this->contribs
== 'newbie' ) {
283 $max = $this->mDb
->selectField( 'user', 'max(user_id)', '', __METHOD__
);
284 $queryInfo['conds'][] = $revQuery['fields']['rev_user'] . ' >' . (int)( $max - $max / 100 );
285 # ignore local groups with the bot right
286 # @todo FIXME: Global groups may have 'bot' rights
287 $groupsWithBotPermission = User
::getGroupsWithPermission( 'bot' );
288 if ( count( $groupsWithBotPermission ) ) {
289 $queryInfo['tables'][] = 'user_groups';
290 $queryInfo['conds'][] = 'ug_group IS NULL';
291 $queryInfo['join_conds']['user_groups'] = [
293 'ug_user = ' . $revQuery['fields']['rev_user'],
294 'ug_group' => $groupsWithBotPermission,
295 'ug_expiry IS NULL OR ug_expiry >= ' .
296 $this->mDb
->addQuotes( $this->mDb
->timestamp() )
300 // (T140537) Disallow looking too far in the past for 'newbies' queries. If the user requested
301 // a timestamp offset far in the past such that there are no edits by users with user_ids in
302 // the range, we would end up scanning all revisions from that offset until start of time.
303 $queryInfo['conds'][] = 'rev_timestamp > ' .
304 $this->mDb
->addQuotes( $this->mDb
->timestamp( wfTimestamp() - 30 * 24 * 60 * 60 ) );
306 $user = User
::newFromName( $this->target
, false );
307 $ipRangeConds = $user->isAnon() ?
$this->getIpRangeConds( $this->mDb
, $this->target
) : null;
308 if ( $ipRangeConds ) {
309 $queryInfo['tables'][] = 'ip_changes';
310 $queryInfo['join_conds']['ip_changes'] = [
311 'LEFT JOIN', [ 'ipc_rev_id = rev_id' ]
313 $queryInfo['conds'][] = $ipRangeConds;
315 // tables and joins are already handled by Revision::getQueryInfo()
316 $conds = ActorMigration
::newMigration()->getWhere( $this->mDb
, 'rev_user', $user );
317 $queryInfo['conds'][] = $conds['conds'];
318 // Force the appropriate index to avoid bad query plans (T189026)
319 if ( isset( $conds['orconds']['actor'] ) ) {
320 // @todo: This will need changing when revision_actor_temp goes away
321 $queryInfo['options']['USE INDEX']['temp_rev_user'] = 'actor_timestamp';
323 $queryInfo['options']['USE INDEX']['revision'] =
324 isset( $conds['orconds']['userid'] ) ?
'user_timestamp' : 'usertext_timestamp';
329 if ( $this->deletedOnly
) {
330 $queryInfo['conds'][] = 'rev_deleted != 0';
333 if ( $this->topOnly
) {
334 $queryInfo['conds'][] = 'rev_id = page_latest';
337 if ( $this->newOnly
) {
338 $queryInfo['conds'][] = 'rev_parent_id = 0';
341 if ( $this->hideMinor
) {
342 $queryInfo['conds'][] = 'rev_minor_edit = 0';
345 $user = $this->getUser();
346 $queryInfo['conds'] = array_merge( $queryInfo['conds'], $this->getNamespaceCond() );
348 // Paranoia: avoid brute force searches (T19342)
349 if ( !$user->isAllowed( 'deletedhistory' ) ) {
350 $queryInfo['conds'][] = $this->mDb
->bitAnd( 'rev_deleted', Revision
::DELETED_USER
) . ' = 0';
351 } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
352 $queryInfo['conds'][] = $this->mDb
->bitAnd( 'rev_deleted', Revision
::SUPPRESSED_USER
) .
353 ' != ' . Revision
::SUPPRESSED_USER
;
356 // $this->getIndexField() must be in the result rows, as reallyDoQuery() tries to access it.
357 $indexField = $this->getIndexField();
358 if ( $indexField !== 'rev_timestamp' ) {
359 $queryInfo['fields'][] = $indexField;
362 ChangeTags
::modifyDisplayQuery(
363 $queryInfo['tables'],
364 $queryInfo['fields'],
366 $queryInfo['join_conds'],
367 $queryInfo['options'],
371 // Avoid PHP 7.1 warning from passing $this by reference
373 Hooks
::run( 'ContribsPager::getQueryInfo', [ &$pager, &$queryInfo ] );
378 function getNamespaceCond() {
379 if ( $this->namespace !== '' ) {
380 $selectedNS = $this->mDb
->addQuotes( $this->namespace );
381 $eq_op = $this->nsInvert ?
'!=' : '=';
382 $bool_op = $this->nsInvert ?
'AND' : 'OR';
384 if ( !$this->associated
) {
385 return [ "page_namespace $eq_op $selectedNS" ];
388 $associatedNS = $this->mDb
->addQuotes(
389 MediaWikiServices
::getInstance()->getAssociated( $this->namespace )
393 "page_namespace $eq_op $selectedNS " .
395 " page_namespace $eq_op $associatedNS"
403 * Get SQL conditions for an IP range, if applicable
404 * @param IDatabase $db
405 * @param string $ip The IP address or CIDR
406 * @return string|false SQL for valid IP ranges, false if invalid
408 private function getIpRangeConds( $db, $ip ) {
409 // First make sure it is a valid range and they are not outside the CIDR limit
410 if ( !$this->isQueryableRange( $ip ) ) {
414 list( $start, $end ) = IP
::parseRange( $ip );
416 return 'ipc_hex BETWEEN ' . $db->addQuotes( $start ) . ' AND ' . $db->addQuotes( $end );
420 * Is the given IP a range and within the CIDR limit?
422 * @param string $ipRange
423 * @return bool True if it is valid
426 public function isQueryableRange( $ipRange ) {
427 $limits = $this->getConfig()->get( 'RangeContributionsCIDRLimit' );
429 $bits = IP
::parseCIDR( $ipRange )[1];
431 ( $bits === false ) ||
432 ( IP
::isIPv4( $ipRange ) && $bits < $limits['IPv4'] ) ||
433 ( IP
::isIPv6( $ipRange ) && $bits < $limits['IPv6'] )
444 public function getIndexField() {
445 // The returned column is used for sorting and continuation, so we need to
446 // make sure to use the right denormalized column depending on which table is
447 // being targeted by the query to avoid bad query plans.
448 // See T200259, T204669, T220991, and T221380.
449 $target = $this->getTargetTable();
452 return 'rev_timestamp';
454 return 'ipc_rev_timestamp';
455 case 'revision_actor_temp':
456 return 'revactor_timestamp';
459 __METHOD__
. ": Unknown value '$target' from " . static::class . '::getTargetTable()', 0
461 return 'rev_timestamp';
466 * @return false|string
468 public function getTagFilter() {
469 return $this->tagFilter
;
475 public function getContribs() {
476 return $this->contribs
;
482 public function getTarget() {
483 return $this->target
;
489 public function isNewOnly() {
490 return $this->newOnly
;
496 public function getNamespace() {
497 return $this->namespace;
503 protected function getExtraSortFields() {
504 // The returned columns are used for sorting, so we need to make sure
505 // to use the right denormalized column depending on which table is
506 // being targeted by the query to avoid bad query plans.
507 // See T200259, T204669, T220991, and T221380.
508 $target = $this->getTargetTable();
513 return [ 'ipc_rev_id' ];
514 case 'revision_actor_temp':
515 return [ 'revactor_rev' ];
518 __METHOD__
. ": Unknown value '$target' from " . static::class . '::getTargetTable()', 0
524 protected function doBatchLookups() {
525 # Do a link batch query
526 $this->mResult
->seek( 0 );
528 $this->mParentLens
= [];
529 $batch = new LinkBatch();
530 $isIpRange = $this->isQueryableRange( $this->target
);
531 # Give some pointers to make (last) links
532 foreach ( $this->mResult
as $row ) {
533 if ( isset( $row->rev_parent_id
) && $row->rev_parent_id
) {
534 $parentRevIds[] = $row->rev_parent_id
;
536 if ( isset( $row->rev_id
) ) {
537 $this->mParentLens
[$row->rev_id
] = $row->rev_len
;
538 if ( $this->contribs
=== 'newbie' ) { // multiple users
539 $batch->add( NS_USER
, $row->user_name
);
540 $batch->add( NS_USER_TALK
, $row->user_name
);
541 } elseif ( $isIpRange ) {
542 // If this is an IP range, batch the IP's talk page
543 $batch->add( NS_USER_TALK
, $row->rev_user_text
);
545 $batch->add( $row->page_namespace
, $row->page_title
);
548 # Fetch rev_len for revisions not already scanned above
549 $this->mParentLens +
= Revision
::getParentLengths(
551 array_diff( $parentRevIds, array_keys( $this->mParentLens
) )
554 $this->mResult
->seek( 0 );
560 protected function getStartBody() {
561 return "<ul class=\"mw-contributions-list\">\n";
567 protected function getEndBody() {
572 * Check whether the revision associated is valid for formatting. If has no associated revision
573 * id then null is returned.
576 * @param Title|null $title
577 * @return Revision|null
579 public function tryToCreateValidRevision( $row, $title = null ) {
581 * There may be more than just revision rows. To make sure that we'll only be processing
582 * revisions here, let's _try_ to build a revision out of our row (without displaying
583 * notices though) and then trying to grab data from the built object. If we succeed,
584 * we're definitely dealing with revision data and we may proceed, if not, we'll leave it
585 * to extensions to subscribe to the hook to parse the row.
587 Wikimedia\
suppressWarnings();
589 $rev = new Revision( $row, 0, $title );
590 $validRevision = (bool)$rev->getId();
591 } catch ( Exception
$e ) {
592 $validRevision = false;
594 Wikimedia\restoreWarnings
();
595 return $validRevision ?
$rev : null;
599 * Generates each row in the contributions list.
601 * Contributions which are marked "top" are currently on top of the history.
602 * For these contributions, a [rollback] link is shown for users with roll-
603 * back privileges. The rollback link restores the most recent version that
604 * was not written by the target user.
606 * @todo This would probably look a lot nicer in a table.
610 function formatRow( $row ) {
615 $linkRenderer = MediaWikiServices
::getInstance()->getLinkRenderer();
618 // Create a title for the revision if possible
619 // Rows from the hook may not include title information
620 if ( isset( $row->page_namespace
) && isset( $row->page_title
) ) {
621 $page = Title
::newFromRow( $row );
623 $rev = $this->tryToCreateValidRevision( $row, $page );
625 $attribs['data-mw-revid'] = $rev->getId();
627 $link = $linkRenderer->makeLink(
629 $page->getPrefixedText(),
630 [ 'class' => 'mw-contributions-title' ],
631 $page->isRedirect() ?
[ 'redirect' => 'no' ] : []
633 # Mark current revisions
635 $user = $this->getUser();
637 if ( $row->rev_id
=== $row->page_latest
) {
638 $topmarktext .= '<span class="mw-uctop">' . $this->messages
['uctop'] . '</span>';
639 $classes[] = 'mw-contributions-current';
641 if ( !$row->page_is_new
&& $page->quickUserCan( 'rollback', $user )
642 && $page->quickUserCan( 'edit', $user )
644 $this->preventClickjacking();
645 $topmarktext .= ' ' . Linker
::generateRollback( $rev, $this->getContext() );
648 # Is there a visible previous revision?
649 if ( $rev->userCan( Revision
::DELETED_TEXT
, $user ) && $rev->getParentId() !== 0 ) {
650 $difftext = $linkRenderer->makeKnownLink(
652 new HtmlArmor( $this->messages
['diff'] ),
653 [ 'class' => 'mw-changeslist-diff' ],
656 'oldid' => $row->rev_id
660 $difftext = $this->messages
['diff'];
662 $histlink = $linkRenderer->makeKnownLink(
664 new HtmlArmor( $this->messages
['hist'] ),
665 [ 'class' => 'mw-changeslist-history' ],
666 [ 'action' => 'history' ]
669 if ( $row->rev_parent_id
=== null ) {
670 // For some reason rev_parent_id isn't populated for this row.
671 // Its rumoured this is true on wikipedia for some revisions (T36922).
672 // Next best thing is to have the total number of bytes.
673 $chardiff = ' <span class="mw-changeslist-separator"></span> ';
674 $chardiff .= Linker
::formatRevisionSize( $row->rev_len
);
675 $chardiff .= ' <span class="mw-changeslist-separator"></span> ';
678 if ( isset( $this->mParentLens
[$row->rev_parent_id
] ) ) {
679 $parentLen = $this->mParentLens
[$row->rev_parent_id
];
682 $chardiff = ' <span class="mw-changeslist-separator"></span> ';
683 $chardiff .= ChangesList
::showCharacterDifference(
688 $chardiff .= ' <span class="mw-changeslist-separator"></span> ';
691 $lang = $this->getLanguage();
692 $comment = $lang->getDirMark() . Linker
::revComment( $rev, false, true, false );
693 $d = ChangesList
::revDateLink( $rev, $user, $lang, $page );
695 # Show user names for /newbies as there may be different users.
696 # Note that only unprivileged users have rows with hidden user names excluded.
697 # When querying for an IP range, we want to always show user and user talk links.
699 if ( ( $this->contribs
== 'newbie' && !$rev->isDeleted( Revision
::DELETED_USER
) )
700 ||
$this->isQueryableRange( $this->target
) ) {
701 $userlink = ' <span class="mw-changeslist-separator"></span> '
702 . $lang->getDirMark()
703 . Linker
::userLink( $rev->getUser(), $rev->getUserText() );
704 $userlink .= ' ' . $this->msg( 'parentheses' )->rawParams(
705 Linker
::userTalkLink( $rev->getUser(), $rev->getUserText() ) )->escaped() . ' ';
709 if ( $rev->getParentId() === 0 ) {
710 $flags[] = ChangesList
::flag( 'newpage' );
713 if ( $rev->isMinor() ) {
714 $flags[] = ChangesList
::flag( 'minor' );
717 $del = Linker
::getRevDeleteLink( $user, $rev, $page );
722 // While it might be tempting to use a list here
723 // this would result in clutter and slows down navigating the content
724 // in assistive technology.
725 // See https://phabricator.wikimedia.org/T205581#4734812
726 $diffHistLinks = Html
::rawElement( 'span',
727 [ 'class' => 'mw-changeslist-links' ],
728 // The spans are needed to ensure the dividing '|' elements are not
729 // themselves styled as links.
730 Html
::rawElement( 'span', [], $difftext ) .
731 ' ' . // Space needed for separating two words.
732 Html
::rawElement( 'span', [], $histlink )
736 list( $tagSummary, $newClasses ) = ChangeTags
::formatSummaryRow(
741 $classes = array_merge( $classes, $newClasses );
743 Hooks
::run( 'SpecialContributions::formatRow::flags', [ $this->getContext(), $row, &$flags ] );
748 'diffHistLinks' => $diffHistLinks,
749 'charDifference' => $chardiff,
751 'articleLink' => $link,
752 'userlink' => $userlink,
753 'logText' => $comment,
754 'topmarktext' => $topmarktext,
755 'tagSummary' => $tagSummary,
758 # Denote if username is redacted for this edit
759 if ( $rev->isDeleted( Revision
::DELETED_USER
) ) {
760 $templateParams['rev-deleted-user-contribs'] =
761 $this->msg( 'rev-deleted-user-contribs' )->escaped();
764 $ret = $this->templateParser
->processTemplate(
765 'SpecialContributionsLine',
770 // Let extensions add data
771 Hooks
::run( 'ContributionsLineEnding', [ $this, &$ret, $row, &$classes, &$attribs ] );
772 $attribs = array_filter( $attribs,
773 [ Sanitizer
::class, 'isReservedDataAttribute' ],
777 // TODO: Handle exceptions in the catch block above. Do any extensions rely on
778 // receiving empty rows?
780 if ( $classes === [] && $attribs === [] && $ret === '' ) {
781 wfDebug( "Dropping Special:Contribution row that could not be formatted\n" );
782 return "<!-- Could not format Special:Contribution row. -->\n";
784 $attribs['class'] = $classes;
786 // FIXME: The signature of the ContributionsLineEnding hook makes it
787 // very awkward to move this LI wrapper into the template.
788 return Html
::rawElement( 'li', $attribs, $ret ) . "\n";
792 * Overwrite Pager function and return a helpful comment
795 function getSqlComment() {
796 if ( $this->namespace ||
$this->deletedOnly
) {
797 // potentially slow, see CR r58153
798 return 'contributions page filtered for namespace or RevisionDeleted edits';
800 return 'contributions page unfiltered';
804 protected function preventClickjacking() {
805 $this->preventClickjacking
= true;
811 public function getPreventClickjacking() {
812 return $this->preventClickjacking
;
816 * Set up date filter options, given request data.
818 * @param array $opts Options array
819 * @return array Options array with processed start and end date filter options
821 public static function processDateFilter( array $opts ) {
822 $start = $opts['start'] ??
'';
823 $end = $opts['end'] ??
'';
824 $year = $opts['year'] ??
'';
825 $month = $opts['month'] ??
'';
827 if ( $start !== '' && $end !== '' && $start > $end ) {
833 // If year/month legacy filtering options are set, convert them to display the new stamp
834 if ( $year !== '' ||
$month !== '' ) {
835 // Reuse getDateCond logic, but subtract a day because
836 // the endpoints of our date range appear inclusive
837 // but the internal end offsets are always exclusive
838 $legacyTimestamp = ReverseChronologicalPager
::getOffsetDate( $year, $month );
839 $legacyDateTime = new DateTime( $legacyTimestamp->getTimestamp( TS_ISO_8601
) );
840 $legacyDateTime = $legacyDateTime->modify( '-1 day' );
842 // Clear the new timestamp range options if used and
843 // replace with the converted legacy timestamp
845 $end = $legacyDateTime->format( 'Y-m-d' );
848 $opts['start'] = $start;