Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 20
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
PostSummaryRevisionBoardHistoryStorage
0.00% covered (danger)
0.00%
0 / 20
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 1
 find
0.00% covered (danger)
0.00%
0 / 20
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2
3namespace Flow\Data\Storage;
4
5use Flow\Exception\DataModelException;
6use Flow\Model\UUID;
7
8class PostSummaryRevisionBoardHistoryStorage extends BoardHistoryStorage {
9    /**
10     * @param array $attributes
11     * @param array $options
12     * @return array
13     * @throws DataModelException
14     */
15    public function find( array $attributes, array $options = [] ) {
16        $attributes = $this->preprocessSqlArray( $attributes );
17
18        $dbr = $this->dbFactory->getDB( DB_REPLICA );
19        $res = $dbr->select(
20            [ 'flow_revision', 'flow_topic_list', 'flow_tree_node' ],
21            [ '*' ],
22            array_merge( [
23                'rev_type' => 'post-summary',
24                'topic_id = tree_ancestor_id',
25                'rev_type_id = tree_descendant_id',
26            ], $attributes ),
27            __METHOD__,
28            $options
29        );
30
31        if ( $res === false ) {
32            throw new DataModelException( __METHOD__ . ': Query failed: ' . $dbr->lastError(), 'process-data' );
33        }
34
35        $retval = [];
36        foreach ( $res as $row ) {
37            $row = UUID::convertUUIDs( (array)$row, 'alphadecimal' );
38            $retval[$row['rev_id']] = $row;
39        }
40
41        return $retval;
42    }
43}