Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 17
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
PostHistoryQuery
0.00% covered (danger)
0.00%
0 / 17
0.00% covered (danger)
0.00%
0 / 1
30
0.00% covered (danger)
0.00%
0 / 1
 getResults
0.00% covered (danger)
0.00%
0 / 17
0.00% covered (danger)
0.00%
0 / 1
30
1<?php
2
3namespace Flow\Formatter;
4
5use Flow\Exception\FlowException;
6use Flow\Model\UUID;
7use MediaWiki\Exception\MWExceptionHandler;
8
9class PostHistoryQuery extends HistoryQuery {
10
11    /**
12     * @param UUID $postId
13     * @param int $limit
14     * @param UUID|null $offset
15     * @param string $direction 'rev' or 'fwd'
16     * @return FormatterRow[]
17     */
18    public function getResults( UUID $postId, $limit = 50, ?UUID $offset = null, $direction = 'fwd' ) {
19        $history = $this->storage->find(
20            'PostRevision',
21            [ 'rev_type_id' => $postId ],
22            $this->getOptions( $direction, $limit, $offset )
23        );
24        if ( !$history ) {
25            return [];
26        }
27
28        // See explanation in BoardHistoryQuery::getResults.
29        if ( $direction === 'rev' ) {
30            $history = array_reverse( $history );
31        }
32
33        $this->loadMetadataBatch( $history );
34        $results = [];
35        foreach ( $history as $revision ) {
36            try {
37                $results[] = $row = new FormatterRow;
38                $this->buildResult( $revision, null, $row );
39            } catch ( FlowException $e ) {
40                MWExceptionHandler::logException( $e );
41            }
42        }
43
44        return $results;
45    }
46
47}