Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
SuggestIndex
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 execute
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3namespace CirrusSearch\Api;
4
5use MediaWiki\WikiMap\WikiMap;
6
7/**
8 * Update ElasticSearch suggestion index
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 */
25class SuggestIndex extends \ApiBase {
26    use ApiTrait;
27
28    public function execute() {
29        // FIXME: This is horrible, no good, very bad hack. Only for testing,
30        // and probably should be eventually replaced with something more sane.
31        $updaterScript = "extensions/CirrusSearch/maintenance/UpdateSuggesterIndex.php";
32        // detects between mediawiki-vagrant and mediawiki-docker-dev (mwcli/mwdd)
33        $php = '/usr/local/bin/mwscript';
34        if ( !file_exists( $php ) ) {
35            $php = '/usr/bin/php';
36        }
37        $this->getResult()->addValue( null, 'result',
38            wfShellExecWithStderr( "unset REQUEST_METHOD; $php $updaterScript --wiki " . WikiMap::getCurrentWikiId() )
39        );
40    }
41}