Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 24 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
MWServeRenderingAPI | |
0.00% |
0 / 24 |
|
0.00% |
0 / 1 |
56 | |
0.00% |
0 / 1 |
makeRequest | |
0.00% |
0 / 24 |
|
0.00% |
0 / 1 |
56 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\Collection\Rendering; |
4 | |
5 | use MediaWiki\MediaWikiServices; |
6 | |
7 | /** |
8 | * API for PediaPress' mw-serve |
9 | */ |
10 | class MWServeRenderingAPI extends CollectionRenderingAPI { |
11 | /** @inheritDoc */ |
12 | protected function makeRequest( $command, array $params ) { |
13 | global $wgCollectionMWServeURL, $wgCollectionMWServeCredentials, |
14 | $wgCollectionFormatToServeURL, $wgCollectionCommandToServeURL; |
15 | |
16 | $serveURL = $wgCollectionMWServeURL; |
17 | if ( $this->writer ) { |
18 | if ( isset( $wgCollectionFormatToServeURL[ $this->writer ] ) ) { |
19 | $serveURL = $wgCollectionFormatToServeURL[ $this->writer ]; |
20 | } |
21 | $params['writer'] = $this->writer; |
22 | } |
23 | |
24 | $params['command'] = $command; |
25 | if ( isset( $wgCollectionCommandToServeURL[ $command ] ) ) { |
26 | $serveURL = $wgCollectionCommandToServeURL[ $command ]; |
27 | } |
28 | if ( $wgCollectionMWServeCredentials ) { |
29 | $params['login_credentials'] = $wgCollectionMWServeCredentials; |
30 | } |
31 | // If $serveURL has a | in it, we need to use a proxy. |
32 | [ $proxy, $serveURL ] = array_pad( explode( '|', $serveURL, 2 ), -2, '' ); |
33 | |
34 | if ( !$serveURL ) { |
35 | wfDebugLog( 'collection', 'The mwlib/OCG render server URL isn\'t configured.' ); |
36 | |
37 | return new CollectionAPIResult( null ); |
38 | } |
39 | |
40 | $response = MediaWikiServices::getInstance()->getHttpRequestFactory()->post( |
41 | $serveURL, |
42 | [ 'postData' => $params, 'proxy' => $proxy ], |
43 | __METHOD__ |
44 | ); |
45 | |
46 | if ( $response === null ) { |
47 | wfDebugLog( 'collection', "Request to $serveURL resulted in error" ); |
48 | } |
49 | |
50 | return new CollectionAPIResult( $response ); |
51 | } |
52 | } |