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.

Issues (3647)

symphony/template/usererror.xslt.php (8 issues)

1
<?php
2
3
$Page = new HTMLPage();
4
5
$Page->Html->setElementStyle('html');
6
7
$Page->Html->setDTD('<!DOCTYPE html>');
8
$Page->Html->setAttribute('lang', 'en');
9
$Page->addElementToHead(new XMLElement('meta', null, array('http-equiv' => 'Content-Type', 'content' => 'text/html; charset=UTF-8')), 0);
10
$Page->addStylesheetToHead(ASSETS_URL . '/css/symphony.min.css', 'screen', null, false);
0 ignored issues
show
The constant ASSETS_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
11
12
$Page->setHttpStatus($e->getHttpStatusCode());
13
$Page->addHeaderToPage('Content-Type', 'text/html; charset=UTF-8');
14
$Page->addHeaderToPage('Symphony-Error-Type', 'xslt');
15
16
$Page->setTitle(__('%1$s &ndash; %2$s', array(__('Symphony'), __('XSLT Processing Error'))));
17
$Page->Body->setAttribute('id', 'error');
18
19
$div = new XMLElement('div', null, array('class' => 'frame'));
20
$ul = new XMLElement('ul');
21
$li = new XMLElement('li');
22
$li->appendChild(new XMLElement('h1', __('XSLT Processing Error')));
23
$li->appendChild(new XMLElement('p', __('This page could not be rendered due to the following XSLT processing errors:')));
24
$ul->appendChild($li);
25
26
$errors_grouped = array();
27
28
list($key, $val) = $e->getAdditional()->proc->getError(false, true);
29
30
do {
31
    if (preg_match('/^loadXML\(\)/i', $val['message']) && preg_match_all('/line:\s+(\d+)/i', $val['message'], $matches)) {
32
        $errors_grouped['xml'][] = array('line'=>$matches[1][0], 'raw'=>$val);
33
    } elseif (preg_match_all('/pages\/([^.\/]+\.xsl)\s+line\s+(\d+)/i', $val['message'], $matches) || preg_match_all('/pages\/([^.\/]+\.xsl):(\d+):/i', $val['message'], $matches)) {
34
        $errors_grouped['page'][$matches[1][0]][] = array('line'=>$matches[2][0], 'raw'=>$val);
35
    } elseif (preg_match_all('/utilities\/([^.\/]+\.xsl)\s+line\s+(\d+)/i', $val['message'], $matches)) {
36
        $errors_grouped['utility'][$matches[1][0]][] = array('line'=>$matches[2][0], 'raw'=>$val);
37
    } else {
38
        $val['parts'] = explode(' ', $val['message'], 3);
39
        $errors_grouped['general'][] = $val;
40
    }
41
} while (list($key, $val) = $e->getAdditional()->proc->getError());
42
43
$query_string = General::sanitize($Page->__buildQueryString());
44
45
if (strlen(trim($query_string)) > 0) {
46
    $query_string = "&amp;{$query_string}";
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $query_string instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
47
}
48
49
foreach ($errors_grouped as $group => $data) {
50
    switch ($group) {
51
        case 'general':
52
            $error = new XMLElement('li', '<header class="frame-header">' . __('General') . '<a class="debug" href="?debug' . $query_string .'" title="' . __('Show debug view') . '">' . __('Debug') . '</a></header>');
53
            $content = new XMLElement('div', null, array('class' => 'content'));
54
            $list = new XMLElement('ul');
55
            $file = null;
56
            $line = null;
57
58
            foreach ($data as $index => $e) {
0 ignored issues
show
Blank line found at start of control structure
Loading history...
59
60
                // Highlight error
61
                $class = array();
62
                if (strpos($data[$index + 1]['message'], '^') !== false) {
63
                    $class = array('class' => 'error');
64
                }
65
66
                // Don't show markers
67
                if (strpos($e['message'], '^') === false) {
68
                    $parts = explode('(): ', $e['message']);
69
70
                    // Function
71
                    preg_match('/(.*)\:(\d+)\:/', $e['parts'][1], $current);
72
                    if ($data[$index - 1]['parts'][0] != $e['parts'][0] || (strpos($data[$index - 1]['message'], '^') !== false && $data[$index - 2]['message'] != $data[$index + 1]['message'])) {
73
                        $list->appendChild(
74
                            new XMLElement(
75
                                'li',
76
                                '<code><em>' . $e['parts'][0] . ' ' . $current[1] . '</em></code>'
77
                            )
78
                        );
79
                    }
80
81
                    // Store current file and line
82
                    if (count($current) > 2) {
83
                        $file = $current[1];
84
                        $line = $current[2];
85
                    }
86
87
                    // Error
88
                    if (!empty($class)) {
89
                        if (isset($data[$index + 3]) && !empty($parts[1]) && strpos($data[$index + 3]['message'], $parts[1]) === false) {
90
                            $position = explode('(): ', $data[$index + 1]['message']);
91
                            $length = max(0, strlen($position[1]) - 1);
92
                            $list->appendChild(
93
                                new XMLElement(
94
                                    'li',
95
                                    '<code>&#160;&#160;&#160;&#160;' . str_replace(' ', '&#160;', trim(htmlspecialchars(substr($parts[1], 0, $length))) . '<b>' . htmlspecialchars(substr($parts[1], $length, 1)) . '</b>' . htmlspecialchars(substr($parts[1], $length + 1))) . '</code>',
96
                                    $class
97
                                )
98
                            );
99
100
                            if (isset($file, $line)) {
101
                                // Show in debug
102
                                $filename = explode(WORKSPACE . '/', $file);
0 ignored issues
show
The constant WORKSPACE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
103
                                $list->appendChild(
104
                                    new XMLElement(
105
                                        'li',
106
                                        '<code>&#160;&#160;&#160;&#160;<a href="?debug=/workspace/' . $filename[1] . '#line-' . $line .'" title="' . __('Show debug view for %s', array($filename[1])) . '">' . __('Show line %d in debug view', array($line)) . '</a></code>'
107
                                    )
108
                                );
109
                            }
110
                        }
111
112
                        // Message
113
                    } else {
114
                        $list->appendChild(
115
                            new XMLElement(
116
                                'li',
117
                                '<code>&#160;&#160;&#160;&#160;' . (strpos($e['parts'][1], '/') !== 0 ? $e['parts'][1] . ' ' : '') . str_replace(' ', '&#160;', $e['parts'][2]) . '</code>'
0 ignored issues
show
Inline shorthand IF statement requires brackets around comparison
Loading history...
118
                            )
119
                        );
120
                    }
121
                }
122
            }
123
124
            $content->appendChild($list);
125
            $error->appendChild($content);
126
            $ul->appendChild($error);
127
128
            break;
129
        case 'page':
130
            foreach ($data as $filename => $errors) {
131
                $error = new XMLElement('li', '<header class="frame-header">' . $filename . '<a class="debug" href="?debug=/workspace/pages/' .  $filename . $query_string .'" title="' . __('Show debug view') . '">' . __('Debug') . '</a></header>');
132
                $content = new XMLElement('div', null, array('class' => 'content'));
133
                $list = new XMLElement('ul');
134
135
                foreach ($errors as $e) {
136
                    if (!is_array($e)) {
137
                        continue;
138
                    }
139
140
                    $parts = explode('(): ', $e['raw']['message']);
141
142
                    $list->appendChild(
143
                        new XMLElement(
144
                            'li',
145
                            '<code><em>' . $parts[0] . '():</em></code>'
146
                        )
147
                    );
148
                    $list->appendChild(
149
                        new XMLElement(
150
                            'li',
151
                            '<code>&#160;&#160;&#160;&#160;' . $parts[1] . '</code>'
152
                        )
153
                    );
154
                    $list->appendChild(
155
                        new XMLElement(
156
                            'li',
157
                            '<code>&#160;&#160;&#160;&#160;<a href="?debug=/workspace/pages/' . $filename . $query_string . '#line-' . $e['line'] .'" title="' . __('Show debug view for %s', array($filename)) . '">' . __('Show line %d in debug view', array($e['line'])) . '</a></code>'
158
                        )
159
                    );
160
                }
161
162
                $content->appendChild($list);
163
                $error->appendChild($content);
164
                $ul->appendChild($error);
165
            }
0 ignored issues
show
Blank line found after control structure
Loading history...
166
167
            break;
168
        case 'utility':
169
            foreach ($data as $filename => $errors) {
170
                $error = new XMLElement('li', '<header class="frame-header">' . $filename . '<a class="debug" href="?debug=/workspace/utilities/' .  $filename . $query_string .'" title="' . __('Show debug view') . '">' . __('Debug') . '</a></header>');
171
                $content = new XMLElement('div', null, array('class' => 'content'));
172
                $list = new XMLElement('ul');
173
174
                foreach ($errors as $e) {
175
                    if (!is_array($e)) {
176
                        continue;
177
                    }
178
179
                    $parts = explode('(): ', $e['raw']['message']);
180
181
                    $list->appendChild(
182
                        new XMLElement(
183
                            'li',
184
                            '<code><em>' . $parts[0] . '():</em></code>'
185
                        )
186
                    );
187
                    $list->appendChild(
188
                        new XMLElement(
189
                            'li',
190
                            '<code>&#160;&#160;&#160;&#160;' . $parts[1] . '</code>'
191
                        )
192
                    );
193
                    $list->appendChild(
194
                        new XMLElement(
195
                            'li',
196
                            '<code>&#160;&#160;&#160;&#160;<a href="?debug=/workspace/utilities/' .  $filename . $query_string . '#line-' . $e['line'] .'" title="' . __('Show debug view for %s', array($filename)) . '">' . __('Show line %d in debug view', array($e['line'])) . '</a></code>'
197
                        )
198
                    );
199
                }
200
201
                $content->appendChild($list);
202
                $error->appendChild($content);
203
                $ul->appendChild($error);
204
            }
0 ignored issues
show
Blank line found after control structure
Loading history...
205
206
            break;
207
        case 'xml':
208
            foreach ($data as $filename => $errors) {
209
                $error = new XMLElement('li', '<header class="frame-header">XML <a class="button" href="?debug=xml' . $query_string .'" title="' . __('Show debug view') . '">' . __('Debug') . '</a></header>');
210
                $content = new XMLElement('div', null, array('class' => 'content'));
211
                $list = new XMLElement('ul');
212
213
                foreach ($errors as $e) {
214
                    if (!is_array($e)) {
215
                        continue;
216
                    }
217
218
                    $parts = explode('(): ', $e['message']);
219
220
                    $list->appendChild(
221
                        new XMLElement(
222
                            'li',
223
                            '<code><em>' . $parts[0] . '():</em></code>'
224
                        )
225
                    );
226
                    $list->appendChild(
227
                        new XMLElement(
228
                            'li',
229
                            '<code>&#160;&#160;&#160;&#160;' . $parts[1] . '</code>'
230
                        )
231
                    );
232
233
                    if (strpos($e['file'], WORKSPACE) !== false) {
234
                        // The line in the exception is where it was thrown, it's
235
                        // useless for the ?debug view. This gets the line from
236
                        // the ?debug page.
237
                        preg_match('/:\s(\d+)$/', $parts[1], $line);
238
239
                        $list->appendChild(
240
                            new XMLElement(
241
                                'li',
242
                                '<code>&#160;&#160;&#160;&#160;<a href="?debug=xml' . $query_string . '#line-' . $line[1] .'" title="' . __('Show debug view for %s', array($filename)) . '">' . __('Show line %d in debug view', array($line[1])) . '</a></code>'
243
                            )
244
                        );
245
                    } else {
246
                        $list->appendChild(
247
                            new XMLElement(
248
                                'li',
249
                                '<code>&#160;&#160;&#160;&#160;' . $e['file'] . ':' . $e['line']. '</code>'
250
                            )
251
                        );
252
                    }
253
                }
254
255
                $content->appendChild($list);
256
                $error->appendChild($content);
257
                $ul->appendChild($error);
258
            }
0 ignored issues
show
Blank line found after control structure
Loading history...
259
260
            break;
261
    }
262
}
263
264
$div->appendChild($ul);
265
$Page->Body->appendChild($div);
266
267
print $Page->generate();
268
269
exit;
270