Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 11
CRAP
0.00% covered (danger)
0.00%
0 / 1
DumpFilter
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 11
210
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 writeOpenStream
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 writeCloseStream
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 writeOpenPage
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 writeClosePage
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 writeRevision
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
6
 writeLogItem
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 closeRenameAndReopen
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 closeAndRename
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getFilenames
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 pass
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3 * Dump output filter class.
4 * This just does output filtering and streaming; XML formatting is done
5 * higher up, so be careful in what you do.
6 *
7 * Copyright © 2003, 2005, 2006 Brooke Vibber <bvibber@wikimedia.org>
8 * https://www.mediawiki.org/
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 * http://www.gnu.org/copyleft/gpl.html
24 *
25 * @file
26 */
27
28/**
29 * @ingroup Dump
30 */
31class DumpFilter {
32    /**
33     * @var DumpOutput
34     * FIXME will need to be made protected whenever legacy code
35     * is updated.
36     */
37    public $sink;
38
39    /**
40     * @var bool
41     */
42    protected $sendingThisPage;
43
44    /**
45     * @param DumpOutput &$sink
46     */
47    public function __construct( &$sink ) {
48        $this->sink =& $sink;
49    }
50
51    /**
52     * @param string $string
53     */
54    public function writeOpenStream( $string ) {
55        $this->sink->writeOpenStream( $string );
56    }
57
58    /**
59     * @param string $string
60     */
61    public function writeCloseStream( $string ) {
62        $this->sink->writeCloseStream( $string );
63    }
64
65    /**
66     * @param stdClass|null $page
67     * @param string $string
68     */
69    public function writeOpenPage( $page, $string ) {
70        $this->sendingThisPage = $this->pass( $page );
71        if ( $this->sendingThisPage ) {
72            $this->sink->writeOpenPage( $page, $string );
73        }
74    }
75
76    /**
77     * @param string $string
78     */
79    public function writeClosePage( $string ) {
80        if ( $this->sendingThisPage ) {
81            $this->sink->writeClosePage( $string );
82            $this->sendingThisPage = false;
83        }
84    }
85
86    /**
87     * @param stdClass|null $rev
88     * @param string $string
89     */
90    public function writeRevision( $rev, $string ) {
91        if ( $this->sendingThisPage ) {
92            $this->sink->writeRevision( $rev, $string );
93        }
94    }
95
96    /**
97     * @param stdClass $rev
98     * @param string $string
99     */
100    public function writeLogItem( $rev, $string ) {
101        $this->sink->writeRevision( $rev, $string );
102    }
103
104    /**
105     * @see DumpOutput::closeRenameAndReopen()
106     * @param string|string[] $newname
107     */
108    public function closeRenameAndReopen( $newname ) {
109        $this->sink->closeRenameAndReopen( $newname );
110    }
111
112    /**
113     * @see DumpOutput::closeAndRename()
114     * @param string|string[] $newname
115     * @param bool $open
116     */
117    public function closeAndRename( $newname, $open = false ) {
118        $this->sink->closeAndRename( $newname, $open );
119    }
120
121    /**
122     * @return array
123     */
124    public function getFilenames() {
125        return $this->sink->getFilenames() ?? [];
126    }
127
128    /**
129     * Override for page-based filter types.
130     * @param stdClass|null $page
131     * @return bool
132     */
133    protected function pass( $page ) {
134        return true;
135    }
136}