MCR: Deprecate and gut Revision class
[lhc/web/wiklou.git] / includes / actions / HistoryAction.php
index d1be7d4..85e8db6 100644 (file)
@@ -154,7 +154,7 @@ class HistoryAction extends FormlessAction {
                        # show deletion/move log if there is an entry
                        LogEventsList::showLogExtract(
                                $out,
-                               [ 'delete', 'move' ],
+                               [ 'delete', 'move', 'protect' ],
                                $this->getTitle(),
                                '',
                                [ 'lim' => 10,
@@ -192,27 +192,26 @@ class HistoryAction extends FormlessAction {
 
                // Add the general form
                $action = htmlspecialchars( wfScript() );
+               $content = Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) . "\n";
+               $content .= Html::hidden( 'action', 'history' ) . "\n";
+               $content .= Xml::dateMenu(
+                       ( $year == null ? MWTimestamp::getLocalInstance()->format( 'Y' ) : $year ),
+                       $month
+               ) . ' ';
+               $content .= $tagSelector ? ( implode( ' ', $tagSelector ) . ' ' ) : '';
+               $content .= $checkDeleted . Html::submitButton(
+                       $this->msg( 'historyaction-submit' )->text(),
+                       [],
+                       [ 'mw-ui-progressive' ]
+               );
                $out->addHTML(
                        "<form action=\"$action\" method=\"get\" id=\"mw-history-searchform\">" .
                        Xml::fieldset(
                                $this->msg( 'history-fieldset-title' )->text(),
-                               false,
+                               $content,
                                [ 'id' => 'mw-history-search' ]
                        ) .
-                       Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) . "\n" .
-                       Html::hidden( 'action', 'history' ) . "\n" .
-                       Xml::dateMenu(
-                               ( $year == null ? MWTimestamp::getLocalInstance()->format( 'Y' ) : $year ),
-                               $month
-                       ) . '&#160;' .
-                       ( $tagSelector ? ( implode( '&#160;', $tagSelector ) . '&#160;' ) : '' ) .
-                       $checkDeleted .
-                       Html::submitButton(
-                               $this->msg( 'historyaction-submit' )->text(),
-                               [],
-                               [ 'mw-ui-progressive' ]
-                       ) . "\n" .
-                       '</fieldset></form>'
+                       '</form>'
                );
 
                Hooks::run( 'PageHistoryBeforeList', [ &$this->page, $this->getContext() ] );
@@ -259,12 +258,18 @@ class HistoryAction extends FormlessAction {
 
                $page_id = $this->page->getId();
 
-               return $dbr->select( 'revision',
-                       Revision::selectFields(),
+               $revQuery = Revision::getQueryInfo();
+               return $dbr->select(
+                       $revQuery['tables'],
+                       $revQuery['fields'],
                        array_merge( [ 'rev_page' => $page_id ], $offsets ),
                        __METHOD__,
-                       [ 'ORDER BY' => "rev_timestamp $dirs",
-                               'USE INDEX' => 'page_timestamp', 'LIMIT' => $limit ]
+                       [
+                               'ORDER BY' => "rev_timestamp $dirs",
+                               'USE INDEX' => [ 'revision' => 'page_timestamp' ],
+                               'LIMIT' => $limit
+                       ],
+                       $revQuery['joins']
                );
        }
 
@@ -330,8 +335,8 @@ class HistoryAction extends FormlessAction {
         * @return FeedItem
         */
        function feedItem( $row ) {
-               $rev = new Revision( $row );
-               $rev->setTitle( $this->getTitle() );
+               $rev = new Revision( $row, 0, $this->getTitle() );
+
                $text = FeedUtils::formatDiffRow(
                        $this->getTitle(),
                        $this->getTitle()->getPreviousRevisionID( $rev->getId() ),
@@ -386,6 +391,9 @@ class HistoryPager extends ReverseChronologicalPager {
        /** @var bool Whether to show the tag editing UI */
        protected $showTagEditUI;
 
+       /** @var string */
+       private $tagFilter;
+
        /**
         * @param HistoryAction $historyPage
         * @param string $year
@@ -416,14 +424,15 @@ class HistoryPager extends ReverseChronologicalPager {
        }
 
        function getQueryInfo() {
+               $revQuery = Revision::getQueryInfo( [ 'user' ] );
                $queryInfo = [
-                       'tables' => [ 'revision', 'user' ],
-                       'fields' => array_merge( Revision::selectFields(), Revision::selectUserFields() ),
+                       'tables' => $revQuery['tables'],
+                       'fields' => $revQuery['fields'],
                        'conds' => array_merge(
                                [ 'rev_page' => $this->getWikiPage()->getId() ],
                                $this->conds ),
                        'options' => [ 'USE INDEX' => [ 'revision' => 'page_timestamp' ] ],
-                       'join_conds' => [ 'user' => Revision::userJoinCond() ],
+                       'join_conds' => $revQuery['joins'],
                ];
                ChangeTags::modifyDisplayQuery(
                        $queryInfo['tables'],
@@ -630,12 +639,10 @@ class HistoryPager extends ReverseChronologicalPager {
         */
        function historyLine( $row, $next, $notificationtimestamp = false,
                $latest = false, $firstInList = false ) {
-               $rev = new Revision( $row );
-               $rev->setTitle( $this->getTitle() );
+               $rev = new Revision( $row, 0, $this->getTitle() );
 
                if ( is_object( $next ) ) {
-                       $prevRev = new Revision( $next );
-                       $prevRev->setTitle( $this->getTitle() );
+                       $prevRev = new Revision( $next, 0, $this->getTitle() );
                } else {
                        $prevRev = null;
                }
@@ -780,9 +787,11 @@ class HistoryPager extends ReverseChronologicalPager {
                        $s .= ' <span class="mw-changeslist-separator">. .</span> ' . $s2;
                }
 
-               Hooks::run( 'PageHistoryLineEnding', [ $this, &$row, &$s, &$classes ] );
+               $attribs = [ 'data-mw-revid' => $rev->getId() ];
+
+               Hooks::run( 'PageHistoryLineEnding', [ $this, &$row, &$s, &$classes, &$attribs ] );
+               $attribs = wfArrayFilterByKey( $attribs, [ Sanitizer::class, 'isReservedDataAttribute' ] );
 
-               $attribs = [];
                if ( $classes ) {
                        $attribs['class'] = implode( ' ', $classes );
                }