Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
26.67% |
4 / 15 |
|
23.08% |
3 / 13 |
CRAP | |
0.00% |
0 / 1 |
DerivativeRequest | |
28.57% |
4 / 14 |
|
23.08% |
3 / 13 |
85.43 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getCookie | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getHeader | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getAllHeaders | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getSession | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getSessionData | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setSessionData | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getAcceptLang | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getIP | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
setIP | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getProtocol | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getUpload | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getElapsedTime | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | /** |
3 | * Deal with importing all those nasty globals and things |
4 | * |
5 | * Copyright © 2003 Brooke Vibber <bvibber@wikimedia.org> |
6 | * https://www.mediawiki.org/ |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
10 | * the Free Software Foundation; either version 2 of the License, or |
11 | * (at your option) any later version. |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
17 | * |
18 | * You should have received a copy of the GNU General Public License along |
19 | * with this program; if not, write to the Free Software Foundation, Inc., |
20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
21 | * http://www.gnu.org/copyleft/gpl.html |
22 | * |
23 | * @file |
24 | */ |
25 | |
26 | namespace MediaWiki\Request; |
27 | |
28 | use MediaWiki\Session\Session; |
29 | |
30 | /** |
31 | * Similar to MediaWiki\Request\FauxRequest, but only fakes URL parameters and method |
32 | * (POST or GET) and use the base request for the remaining stuff |
33 | * (cookies, session and headers). |
34 | * |
35 | * @newable |
36 | * |
37 | * @ingroup HTTP |
38 | * @since 1.19 |
39 | */ |
40 | class DerivativeRequest extends FauxRequest { |
41 | private $base; |
42 | private $ip; |
43 | |
44 | /** |
45 | * @stable to call |
46 | * |
47 | * @param WebRequest $base |
48 | * @param array $data Array of *non*-urlencoded key => value pairs, the |
49 | * fake GET/POST values |
50 | * @param bool $wasPosted Whether to treat the data as POST |
51 | */ |
52 | public function __construct( WebRequest $base, $data, $wasPosted = false ) { |
53 | $this->base = $base; |
54 | parent::__construct( $data, $wasPosted ); |
55 | } |
56 | |
57 | public function getCookie( $key, $prefix = null, $default = null ) { |
58 | return $this->base->getCookie( $key, $prefix, $default ); |
59 | } |
60 | |
61 | public function getHeader( $name, $flags = 0 ) { |
62 | return $this->base->getHeader( $name, $flags ); |
63 | } |
64 | |
65 | public function getAllHeaders() { |
66 | return $this->base->getAllHeaders(); |
67 | } |
68 | |
69 | public function getSession(): Session { |
70 | return $this->base->getSession(); |
71 | } |
72 | |
73 | public function getSessionData( $key ) { |
74 | return $this->base->getSessionData( $key ); |
75 | } |
76 | |
77 | public function setSessionData( $key, $data ) { |
78 | $this->base->setSessionData( $key, $data ); |
79 | } |
80 | |
81 | public function getAcceptLang() { |
82 | return $this->base->getAcceptLang(); |
83 | } |
84 | |
85 | public function getIP(): string { |
86 | return $this->ip ?: $this->base->getIP(); |
87 | } |
88 | |
89 | public function setIP( $ip ) { |
90 | $this->ip = $ip; |
91 | } |
92 | |
93 | public function getProtocol() { |
94 | return $this->base->getProtocol(); |
95 | } |
96 | |
97 | public function getUpload( $key ) { |
98 | // @phan-suppress-next-line PhanTypeMismatchReturnSuperType |
99 | return $this->base->getUpload( $key ); |
100 | } |
101 | |
102 | public function getElapsedTime() { |
103 | return $this->base->getElapsedTime(); |
104 | } |
105 | } |
106 | |
107 | /** @deprecated class alias since 1.40 */ |
108 | class_alias( DerivativeRequest::class, 'DerivativeRequest' ); |