These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
0 ignored issues
–
show
|
|||
2 | |||
3 | use SEQL\HookRegistry; |
||
4 | |||
5 | /** |
||
6 | * @see https://github.com/SemanticMediaWiki/SemanticExternalQueryLookup/ |
||
7 | * |
||
8 | * @defgroup SEQL Semantic External Query Lookup |
||
9 | */ |
||
10 | if ( !defined( 'MEDIAWIKI' ) ) { |
||
11 | die( 'This file is part of the SemanticExternalQueryLookup extension, it is not a valid entry point.' ); |
||
12 | } |
||
13 | |||
14 | if ( version_compare( $GLOBALS[ 'wgVersion' ], '1.23', 'lt' ) ) { |
||
15 | die( '<b>Error:</b> This version of <a href="https://github.com/SemanticMediaWiki/SemanticExternalQueryLookup/">SemanticExternalQueryLookup</a> is only compatible with MediaWiki 1.23 or above. You need to upgrade MediaWiki first.' ); |
||
16 | } |
||
17 | |||
18 | if ( defined( 'SEQL_VERSION' ) ) { |
||
19 | // Do not initialize more than once. |
||
20 | return 1; |
||
21 | } |
||
22 | |||
23 | define( 'SEQL_VERSION', '1.0.0-alpha' ); |
||
24 | |||
25 | /** |
||
26 | * @codeCoverageIgnore |
||
27 | */ |
||
28 | call_user_func( function () { |
||
29 | |||
30 | // Register extension info |
||
31 | $GLOBALS['wgExtensionCredits']['semantic'][] = array( |
||
32 | 'path' => __FILE__, |
||
33 | 'name' => 'Semantic External Query Lookup', |
||
34 | 'author' => array( 'James Hong Kong' ), |
||
35 | 'url' => 'https://github.com/SemanticMediaWiki/SemanticExternalQueryLookup/', |
||
36 | 'descriptionmsg' => 'seql-desc', |
||
37 | 'version' => SEQL_VERSION, |
||
38 | 'license-name' => 'GPL-2.0+', |
||
39 | ); |
||
40 | |||
41 | // Alias to keep LocalSettings independent from the internal NS usage |
||
42 | class_alias( 'SEQL\ByAskApiHttpRequestQueryLookup', 'SMWExternalQueryLookup' ); // deprecated |
||
43 | class_alias( 'SEQL\ByAskApiHttpRequestQueryLookup', 'SMWExternalAskQueryLookup' ); |
||
44 | |||
45 | // Register message files |
||
46 | $GLOBALS['wgMessagesDirs']['semantic-external-query-lookup'] = __DIR__ . '/i18n'; |
||
47 | |||
48 | /** |
||
49 | * Specifies how long a response is cached before a new request is routed |
||
50 | * to the endpoint. This avoids that repeated requests with the same signature |
||
51 | * are made to an endpoint. |
||
52 | * |
||
53 | * This is important if the endpoint has an API access request limitation. |
||
54 | */ |
||
55 | $GLOBALS['seqlgHttpResponseCacheLifetime'] = 60 * 5; // in seconds |
||
56 | |||
57 | /** |
||
58 | * Type of the cache to be used, using CACHE_NONE will disable the caching |
||
59 | * and reroutes every request to the endpoint. |
||
60 | * |
||
61 | * @see https://www.mediawiki.org/wiki/Manual:$wgMainCacheType |
||
62 | */ |
||
63 | $GLOBALS['seqlgHttpResponseCacheType'] = CACHE_ANYTHING; |
||
64 | |||
65 | $GLOBALS['seqlgExternalRepositoryEndpoints'] = array(); |
||
66 | |||
67 | // Finalize extension setup |
||
68 | $GLOBALS['wgExtensionFunctions'][] = function() { |
||
69 | |||
70 | $options = array( |
||
71 | 'externalRepositoryEndpoints' => $GLOBALS['seqlgExternalRepositoryEndpoints'] |
||
72 | ); |
||
73 | |||
74 | $hookRegistry = new HookRegistry( |
||
75 | $options |
||
76 | ); |
||
77 | |||
78 | $hookRegistry->register(); |
||
79 | }; |
||
80 | |||
81 | } ); |
||
82 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.