Passed
Push — master ( 2d0a21...d7cfa8 )
by Timo
20:23 queued 19:26
created

AllowUrlFOpenStatus::getStatus()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 20
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 20
ccs 0
cts 17
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 11
nc 2
nop 0
crap 6
1
<?php
2
namespace ApacheSolrForTypo3\Solr\Report;
3
4
/***************************************************************
5
 *  Copyright notice
6
 *
7
 *  (c) 2012-2015 Ingo Renner <[email protected]>
8
 *  All rights reserved
9
 *
10
 *  This script is part of the TYPO3 project. The TYPO3 project is
11
 *  free software; you can redistribute it and/or modify
12
 *  it under the terms of the GNU General Public License as published by
13
 *  the Free Software Foundation; either version 2 of the License, or
14
 *  (at your option) any later version.
15
 *
16
 *  The GNU General Public License can be found at
17
 *  http://www.gnu.org/copyleft/gpl.html.
18
 *
19
 *  This script is distributed in the hope that it will be useful,
20
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 *  GNU General Public License for more details.
23
 *
24
 *  This copyright notice MUST APPEAR in all copies of the script!
25
 ***************************************************************/
26
27
use TYPO3\CMS\Core\Utility\GeneralUtility;
28
use TYPO3\CMS\Reports\Status;
29
30
/**
31
 * Provides a status report about whether the php.ini setting allow_url_fopen
32
 * is activated or not.
33
 *
34
 * @author Ingo Renner <[email protected]>
35
 */
36
class AllowUrlFOpenStatus extends AbstractSolrStatus
37
{
38
39
    /**
40
     * Checks whether allow_url_fopen is enabled.
41
     *
42
     */
43
    public function getStatus()
44
    {
45
        $reports = [];
46
        $severity = Status::OK;
47
        $value = 'On';
48
        $message = '';
49
50
        if (!ini_get('allow_url_fopen')) {
51
            $severity = Status::ERROR;
52
            $value = 'Off';
53
            $message = 'allow_url_fopen must be enabled in php.ini to allow
54
				communication between TYPO3 and the Apache Solr server.
55
				Indexing pages using the Index Queue will also not work with
56
				this setting disabled.';
57
        }
58
59
        $reports[] = GeneralUtility::makeInstance(Status::class, 'allow_url_fopen', $value, $message, $severity);
60
61
        return $reports;
62
    }
63
}
64