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 | protected function makeRequest( $command, array $params ) { |
12 | global $wgCollectionMWServeURL, $wgCollectionMWServeCredentials, |
13 | $wgCollectionFormatToServeURL, $wgCollectionCommandToServeURL; |
14 | |
15 | $serveURL = $wgCollectionMWServeURL; |
16 | if ( $this->writer ) { |
17 | if ( isset( $wgCollectionFormatToServeURL[ $this->writer ] ) ) { |
18 | $serveURL = $wgCollectionFormatToServeURL[ $this->writer ]; |
19 | } |
20 | $params['writer'] = $this->writer; |
21 | } |
22 | |
23 | $params['command'] = $command; |
24 | if ( isset( $wgCollectionCommandToServeURL[ $command ] ) ) { |
25 | $serveURL = $wgCollectionCommandToServeURL[ $command ]; |
26 | } |
27 | if ( $wgCollectionMWServeCredentials ) { |
28 | $params['login_credentials'] = $wgCollectionMWServeCredentials; |
29 | } |
30 | // If $serveURL has a | in it, we need to use a proxy. |
31 | [ $proxy, $serveURL ] = array_pad( explode( '|', $serveURL, 2 ), -2, '' ); |
32 | |
33 | if ( !$serveURL ) { |
34 | wfDebugLog( 'collection', 'The mwlib/OCG render server URL isn\'t configured.' ); |
35 | |
36 | return new CollectionAPIResult( null ); |
37 | } |
38 | |
39 | $response = MediaWikiServices::getInstance()->getHttpRequestFactory()->post( |
40 | $serveURL, |
41 | [ 'postData' => $params, 'proxy' => $proxy ], |
42 | __METHOD__ |
43 | ); |
44 | |
45 | if ( $response === null ) { |
46 | wfDebugLog( 'collection', "Request to $serveURL resulted in error" ); |
47 | } |
48 | |
49 | return new CollectionAPIResult( $response ); |
50 | } |
51 | } |