Failed Conditions
Push — globalErrorHandling ( f22e31 )
by Andreas
05:27 queued 02:54
created

inc/load.php (3 issues)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * Load all internal libraries and setup class autoloader
4
 *
5
 * @author Andreas Gohr <[email protected]>
6
 */
7
8
use dokuwiki\Extension\PluginController;
9
10
// setup class autoloader
11
spl_autoload_register('load_autoload');
12
13
// require all the common libraries
14
// for a few of these order does matter
15
require_once(DOKU_INC.'inc/defines.php');
16
require_once(DOKU_INC.'inc/actions.php');
17
require_once(DOKU_INC.'inc/changelog.php');
18
require_once(DOKU_INC.'inc/common.php');
19
require_once(DOKU_INC.'inc/confutils.php');
20
require_once(DOKU_INC.'inc/pluginutils.php');
21
require_once(DOKU_INC.'inc/form.php');
22
require_once(DOKU_INC.'inc/fulltext.php');
23
require_once(DOKU_INC.'inc/html.php');
24
require_once(DOKU_INC.'inc/httputils.php');
25
require_once(DOKU_INC.'inc/indexer.php');
26
require_once(DOKU_INC.'inc/infoutils.php');
27
require_once(DOKU_INC.'inc/io.php');
28
require_once(DOKU_INC.'inc/mail.php');
29
require_once(DOKU_INC.'inc/media.php');
30
require_once(DOKU_INC.'inc/pageutils.php');
31
require_once(DOKU_INC.'inc/parserutils.php');
32
require_once(DOKU_INC.'inc/search.php');
33
require_once(DOKU_INC.'inc/template.php');
34
require_once(DOKU_INC.'inc/toolbar.php');
35
require_once(DOKU_INC.'inc/utf8.php');
36
require_once(DOKU_INC.'inc/auth.php');
37
require_once(DOKU_INC.'inc/compatibility.php');
38
require_once(DOKU_INC.'inc/deprecated.php');
39
require_once(DOKU_INC.'inc/legacy.php');
40
41
/**
42
 * spl_autoload_register callback
43
 *
44
 * Contains a static list of DokuWiki's core classes and automatically
45
 * require()s their associated php files when an object is instantiated.
46
 *
47
 * @author Andreas Gohr <[email protected]>
48
 * @todo   add generic loading of renderers and auth backends
49
 *
50
 * @param string $name
51
 *
52
 * @return bool
53
 */
54
function load_autoload($name){
55
    static $classes = null;
56
    if($classes === null) $classes = array(
57
        'Diff'                  => DOKU_INC.'inc/DifferenceEngine.php',
58
        'UnifiedDiffFormatter'  => DOKU_INC.'inc/DifferenceEngine.php',
59
        'TableDiffFormatter'    => DOKU_INC.'inc/DifferenceEngine.php',
60
        'cache'                 => DOKU_INC.'inc/cache.php',
61
        'cache_parser'          => DOKU_INC.'inc/cache.php',
62
        'cache_instructions'    => DOKU_INC.'inc/cache.php',
63
        'cache_renderer'        => DOKU_INC.'inc/cache.php',
64
        'Input'                 => DOKU_INC.'inc/Input.class.php',
65
        'JpegMeta'              => DOKU_INC.'inc/JpegMeta.php',
66
        'SimplePie'             => DOKU_INC.'inc/SimplePie.php',
67
        'FeedParser'            => DOKU_INC.'inc/FeedParser.php',
68
        'IXR_Server'            => DOKU_INC.'inc/IXR_Library.php',
69
        'IXR_Client'            => DOKU_INC.'inc/IXR_Library.php',
70
        'IXR_Error'             => DOKU_INC.'inc/IXR_Library.php',
71
        'IXR_IntrospectionServer' => DOKU_INC.'inc/IXR_Library.php',
72
        'SafeFN'                => DOKU_INC.'inc/SafeFN.class.php',
73
        'Sitemapper'            => DOKU_INC.'inc/Sitemapper.php',
74
        'Mailer'                => DOKU_INC.'inc/Mailer.class.php',
75
76
        'Doku_Handler'          => DOKU_INC.'inc/parser/handler.php',
77
        'Doku_Renderer'          => DOKU_INC.'inc/parser/renderer.php',
78
        'Doku_Renderer_xhtml'    => DOKU_INC.'inc/parser/xhtml.php',
79
        'Doku_Renderer_code'     => DOKU_INC.'inc/parser/code.php',
80
        'Doku_Renderer_xhtmlsummary' => DOKU_INC.'inc/parser/xhtmlsummary.php',
81
        'Doku_Renderer_metadata' => DOKU_INC.'inc/parser/metadata.php',
82
83
        'DokuCLI'                => DOKU_INC.'inc/cli.php',
84
        'DokuCLI_Options'        => DOKU_INC.'inc/cli.php',
85
        'DokuCLI_Colors'         => DOKU_INC.'inc/cli.php',
86
87
    );
88
89
    if(isset($classes[$name])){
90
        require ($classes[$name]);
91
        return true;
92
    }
93
94
    // namespace to directory conversion
95
    $name = str_replace('\\', '/', $name);
96
97
    // test namespace
98
    if(substr($name, 0, 14) === 'dokuwiki/test/') {
99
        $file = DOKU_INC . '_test/' . substr($name, 14) . '.php';
100
        if(file_exists($file)) {
101
            require $file;
102
            return true;
103
        }
104
    }
105
106
    // plugin namespace
107
    if(substr($name, 0, 16) === 'dokuwiki/plugin/') {
108
        $name = str_replace('/test/', '/_test/', $name); // no underscore in test namespace
109
        $file = DOKU_PLUGIN . substr($name, 16) . '.php';
110
        if(file_exists($file)) {
111
            try {
112
                require $file;
113
            } catch (\Throwable $e) {
0 ignored issues
show
The class Throwable does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
114
                \dokuwiki\ErrorHandler::showExceptionMsg($e, "Error loading plugin $name");
115
            }
116
            return true;
117
        }
118
    }
119
120
    // template namespace
121
    if(substr($name, 0, 18) === 'dokuwiki/template/') {
122
        $name = str_replace('/test/', '/_test/', $name); // no underscore in test namespace
123
        $file = DOKU_INC.'lib/tpl/' . substr($name, 18) . '.php';
124
        if(file_exists($file)) {
125
            try {
126
                require $file;
127
            } catch (\Throwable $e) {
0 ignored issues
show
The class Throwable does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
128
                \dokuwiki\ErrorHandler::showExceptionMsg($e, "Error loading template $name");
129
            }
130
            return true;
131
        }
132
    }
133
134
    // our own namespace
135
    if(substr($name, 0, 9) === 'dokuwiki/') {
136
        $file = DOKU_INC . 'inc/' . substr($name, 9) . '.php';
137
        if(file_exists($file)) {
138
            require $file;
139
            return true;
140
        }
141
    }
142
143
    // Plugin loading
144
    if(preg_match(
145
        '/^(' . implode('|', PluginController::PLUGIN_TYPES) . ')_plugin_(' .
146
        DOKU_PLUGIN_NAME_REGEX .
147
        ')(?:_([^_]+))?$/',
148
        $name,
149
        $m
150
    )) {
151
        // try to load the wanted plugin file
152
        $c = ((count($m) === 4) ? "/{$m[3]}" : '');
153
        $plg = DOKU_PLUGIN . "{$m[2]}/{$m[1]}$c.php";
154
        if(file_exists($plg)){
155
            try {
156
                require $plg;
157
            } catch (\Throwable $e) {
0 ignored issues
show
The class Throwable does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
158
                \dokuwiki\ErrorHandler::showExceptionMsg($e, "Error loading plugin ${$m[2]}");
159
            }
160
        }
161
        return true;
162
    }
163
    return false;
164
}
165
166