Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — master (#715)
by Alexander
03:39
created

AbstractController   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
eloc 35
c 1
b 0
f 0
dl 0
loc 72
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B loadDocument() 0 46 7
1
<?php
2
/**
3
 * (c) Kitodo. Key to digital objects e.V. <[email protected]>
4
 *
5
 * This file is part of the Kitodo and TYPO3 projects.
6
 *
7
 * @license GNU General Public License version 3 or later.
8
 * For the full copyright and license information, please read the
9
 * LICENSE.txt file that was distributed with this source code.
10
 */
11
12
namespace Kitodo\Dlf\Controller;
13
14
use Kitodo\Dlf\Common\Document;
15
use Kitodo\Dlf\Common\Helper;
16
use Psr\Log\LoggerAwareInterface;
17
use Psr\Log\LoggerAwareTrait;
18
use TYPO3\CMS\Core\Database\ConnectionPool;
19
use TYPO3\CMS\Core\Utility\GeneralUtility;
20
21
22
/**
23
 *
24
 */
25
abstract class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController implements LoggerAwareInterface
26
{
27
    use LoggerAwareTrait;
28
29
    public $prefixId = 'tx_dlf';
30
31
    /**
32
     * @var
33
     */
34
    protected $extConf;
35
36
    /**
37
     * This holds the current document
38
     *
39
     * @var \Kitodo\Dlf\Common\Document
40
     * @access protected
41
     */
42
    protected $doc;
43
44
    /**
45
     * Loads the current document into $this->doc
46
     *
47
     * @access protected
48
     *
49
     * @return void
50
     */
51
    protected function loadDocument($requestData)
52
    {
53
        // Check for required variable.
54
        if (
55
            !empty($requestData['id'])
56
            && !empty($this->settings['pages'])
57
        ) {
58
            // Should we exclude documents from other pages than $this->settings['pages']?
59
            $pid = (!empty($this->settings['excludeOther']) ? intval($this->settings['pages']) : 0);
60
            // Get instance of \Kitodo\Dlf\Common\Document.
61
            $this->doc = Document::getInstance($requestData['id'], $pid);
62
            if (!$this->doc->ready) {
63
                // Destroy the incomplete object.
64
                $this->doc = null;
65
                $this->logger->error('Failed to load document with UID ' . $requestData['id']);
1 ignored issue
show
Bug introduced by
The method error() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

65
                $this->logger->/** @scrutinizer ignore-call */ 
66
                               error('Failed to load document with UID ' . $requestData['id']);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
66
            } else {
67
                // Set configuration PID.
68
                $this->doc->cPid = $this->settings['pages'];
69
            }
70
        } elseif (!empty($requestData['recordId'])) {
71
            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
72
                ->getQueryBuilderForTable('tx_dlf_documents');
73
74
            // Get UID of document with given record identifier.
75
            $result = $queryBuilder
76
                ->select('tx_dlf_documents.uid AS uid')
77
                ->from('tx_dlf_documents')
78
                ->where(
79
                    $queryBuilder->expr()->eq('tx_dlf_documents.record_id', $queryBuilder->expr()->literal($requestData['recordId'])),
80
                    Helper::whereExpression('tx_dlf_documents')
81
                )
82
                ->setMaxResults(1)
83
                ->execute();
84
85
            if ($resArray = $result->fetch()) {
86
                $requestData['id'] = $resArray['uid'];
87
                // Set superglobal $_GET array and unset variables to avoid infinite looping.
88
                $_GET[$this->prefixId]['id'] = $requestData['id'];
89
                unset($requestData['recordId'], $_GET[$this->prefixId]['recordId']);
90
                // Try to load document.
91
                $this->loadDocument($requestData);
92
            } else {
93
                $this->logger->error('Failed to load document with record ID "' . $requestData['recordId'] . '"');
94
            }
95
        } else {
96
            $this->logger->error('Invalid UID ' . $requestData['id'] . ' or PID ' . $this->settings['pages'] . ' for document loading');
97
        }
98
    }
99
100
}
101