Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
SuggestIndex
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 2
12
0.00% covered (danger)
0.00%
0 / 1
 execute
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
6
 isInternal
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace CirrusSearch\Api;
4
5use MediaWiki\Api\ApiBase;
6use MediaWiki\Shell\Shell;
7use MediaWiki\WikiMap\WikiMap;
8
9/**
10 * Update ElasticSearch suggestion index
11 *
12 * @license GPL-2.0-or-later
13 */
14class SuggestIndex extends ApiBase {
15    use ApiTrait;
16
17    public function execute() {
18        // FIXME: This is horrible, no good, very bad hack. Only for testing,
19        // and probably should be eventually replaced with something more sane.
20        $updaterScript = "extensions/CirrusSearch/maintenance/UpdateSuggesterIndex.php";
21        // detects between mediawiki-vagrant and mediawiki-docker-dev (mwcli/mwdd)
22        $php = '/usr/local/bin/mwscript';
23        if ( !file_exists( $php ) ) {
24            $php = '/usr/bin/php';
25        }
26        $this->getResult()->addValue( null, 'result',
27            Shell::command()->unsafeCommand( "unset REQUEST_METHOD; $php $updaterScript --wiki " .
28                WikiMap::getCurrentWikiId() )->execute()
29        );
30    }
31
32    /**
33     * Mark as internal. This isn't meant to be used by normal api users
34     * @return bool
35     */
36    public function isInternal() {
37        return true;
38    }
39}