@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @param array $config |
32 | 32 | */ |
33 | - public function __construct( $config = [] ) { |
|
34 | - $this->registerHandlers( $config ); |
|
33 | + public function __construct($config = []) { |
|
34 | + $this->registerHandlers($config); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -39,16 +39,16 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @param Cache $cache |
41 | 41 | */ |
42 | - public function setCache( Cache $cache ) { |
|
42 | + public function setCache(Cache $cache) { |
|
43 | 43 | $this->cache = $cache; |
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
47 | 47 | * @since 1.0 |
48 | 48 | */ |
49 | - public static function hasPropertyCollisions( $var ) { |
|
49 | + public static function hasPropertyCollisions($var) { |
|
50 | 50 | |
51 | - if ( !isset( $var['sespgEnabledPropertyList'] ) ) { |
|
51 | + if (!isset($var['sespgEnabledPropertyList'])) { |
|
52 | 52 | return false; |
53 | 53 | } |
54 | 54 | |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | '_APPROVEDSTATUS' => true |
61 | 61 | ]; |
62 | 62 | |
63 | - foreach ( $var['sespgEnabledPropertyList'] as $key ) { |
|
64 | - if ( isset( $list[$key] ) ) { |
|
63 | + foreach ($var['sespgEnabledPropertyList'] as $key) { |
|
64 | + if (isset($list[$key])) { |
|
65 | 65 | return $key; |
66 | 66 | } |
67 | 67 | } |
@@ -74,15 +74,15 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @param array &$vars |
76 | 76 | */ |
77 | - public static function initExtension( &$vars ) { |
|
78 | - $version = 'UNKNOWN' ; |
|
77 | + public static function initExtension(&$vars) { |
|
78 | + $version = 'UNKNOWN'; |
|
79 | 79 | |
80 | 80 | // See https://phabricator.wikimedia.org/T151136 |
81 | - if ( isset( $credits['version'] ) ) { |
|
81 | + if (isset($credits['version'])) { |
|
82 | 82 | $version = $credits['version']; |
83 | 83 | } |
84 | 84 | |
85 | - define( 'SMW_APPROVED_REVS_VERSION', $version ); |
|
85 | + define('SMW_APPROVED_REVS_VERSION', $version); |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * @see https://www.semantic-mediawiki.org/wiki/Hooks#SMW::Config::BeforeCompletion |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @param array &$config |
93 | 93 | */ |
94 | - $GLOBALS['wgHooks']['SMW::Config::BeforeCompletion'][] = function( &$config ) { |
|
94 | + $GLOBALS['wgHooks']['SMW::Config::BeforeCompletion'][] = function(&$config) { |
|
95 | 95 | |
96 | - if ( isset( $config['smwgImportFileDirs'] ) ) { |
|
97 | - $config['smwgImportFileDirs'] += [ 'sar' => __DIR__ . '/../data/import' ]; |
|
96 | + if (isset($config['smwgImportFileDirs'])) { |
|
97 | + $config['smwgImportFileDirs'] += ['sar' => __DIR__ . '/../data/import']; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | return true; |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | * @since 1.0 |
106 | 106 | */ |
107 | 107 | public function register() { |
108 | - foreach ( $this->handlers as $name => $callback ) { |
|
109 | - \Hooks::register( $name, $callback ); |
|
108 | + foreach ($this->handlers as $name => $callback) { |
|
109 | + \Hooks::register($name, $callback); |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | |
@@ -114,13 +114,13 @@ discard block |
||
114 | 114 | * @since 1.0 |
115 | 115 | */ |
116 | 116 | public function deregister() { |
117 | - foreach ( array_keys( $this->handlers ) as $name ) { |
|
118 | - MediaWikiServices::getInstance()->getHookContainer()->clear( $name ); |
|
117 | + foreach (array_keys($this->handlers) as $name) { |
|
118 | + MediaWikiServices::getInstance()->getHookContainer()->clear($name); |
|
119 | 119 | |
120 | 120 | // Remove registered `wgHooks` hooks that are not cleared by the |
121 | 121 | // previous call |
122 | - if ( isset( $GLOBALS['wgHooks'][$name] ) ) { |
|
123 | - unset( $GLOBALS['wgHooks'][$name] ); |
|
122 | + if (isset($GLOBALS['wgHooks'][$name])) { |
|
123 | + unset($GLOBALS['wgHooks'][$name]); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | } |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @return boolean |
134 | 134 | */ |
135 | - public function isRegistered( $name ) { |
|
136 | - return \Hooks::isRegistered( $name ); |
|
135 | + public function isRegistered($name) { |
|
136 | + return \Hooks::isRegistered($name); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | * |
144 | 144 | * @return array |
145 | 145 | */ |
146 | - public function getHandlers( $name ) { |
|
147 | - return \Hooks::getHandlers( $name ); |
|
146 | + public function getHandlers($name) { |
|
147 | + return \Hooks::getHandlers($name); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -153,13 +153,13 @@ discard block |
||
153 | 153 | * @param Title $title |
154 | 154 | * @param integer $latestRevID |
155 | 155 | */ |
156 | - public function onIsApprovedRevision( $title, $latestRevID ) { |
|
156 | + public function onIsApprovedRevision($title, $latestRevID) { |
|
157 | 157 | |
158 | - $approvedRevsHandler = new ApprovedRevsHandler( |
|
158 | + $approvedRevsHandler = new ApprovedRevsHandler( |
|
159 | 159 | new ApprovedRevsFacade() |
160 | 160 | ); |
161 | 161 | |
162 | - return $approvedRevsHandler->isApprovedUpdate( $title, $latestRevID ); |
|
162 | + return $approvedRevsHandler->isApprovedUpdate($title, $latestRevID); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -168,17 +168,17 @@ discard block |
||
168 | 168 | * @param Title $title |
169 | 169 | * @param ?Revision $revision |
170 | 170 | */ |
171 | - public function onChangeRevision( $title, ?Revision $revision ) { |
|
171 | + public function onChangeRevision($title, ?Revision $revision) { |
|
172 | 172 | |
173 | - $approvedRevsHandler = new ApprovedRevsHandler( |
|
173 | + $approvedRevsHandler = new ApprovedRevsHandler( |
|
174 | 174 | new ApprovedRevsFacade() |
175 | 175 | ); |
176 | 176 | |
177 | 177 | $record = null; |
178 | - if ( $revision !== null ) { |
|
178 | + if ($revision !== null) { |
|
179 | 179 | $record = $revision->getRevisionRecord(); |
180 | 180 | } |
181 | - $approvedRevsHandler->doChangeRevision( $title, $record ); |
|
181 | + $approvedRevsHandler->doChangeRevision($title, $record); |
|
182 | 182 | |
183 | 183 | return true; |
184 | 184 | } |
@@ -189,13 +189,13 @@ discard block |
||
189 | 189 | * @param Title $title |
190 | 190 | * @param integer &$latestRevID |
191 | 191 | */ |
192 | - public function onOverrideRevisionID( $title, &$latestRevID ) { |
|
192 | + public function onOverrideRevisionID($title, &$latestRevID) { |
|
193 | 193 | |
194 | - $approvedRevsHandler = new ApprovedRevsHandler( |
|
194 | + $approvedRevsHandler = new ApprovedRevsHandler( |
|
195 | 195 | new ApprovedRevsFacade() |
196 | 196 | ); |
197 | 197 | |
198 | - $approvedRevsHandler->doChangeRevisionID( $title, $latestRevID ); |
|
198 | + $approvedRevsHandler->doChangeRevisionID($title, $latestRevID); |
|
199 | 199 | |
200 | 200 | return true; |
201 | 201 | } |
@@ -208,10 +208,10 @@ discard block |
||
208 | 208 | * @param ProertyRegistry $$registry |
209 | 209 | * @param integer &$latestRevID |
210 | 210 | */ |
211 | - public function onInitProperties( $registry ) { |
|
211 | + public function onInitProperties($registry) { |
|
212 | 212 | |
213 | 213 | $propertyRegistry = new PropertyRegistry(); |
214 | - $propertyRegistry->register( $registry ); |
|
214 | + $propertyRegistry->register($registry); |
|
215 | 215 | |
216 | 216 | return true; |
217 | 217 | } |
@@ -224,17 +224,17 @@ discard block |
||
224 | 224 | * @param ProertyRegistry $$registry |
225 | 225 | * @param integer &$latestRevID |
226 | 226 | */ |
227 | - public function onUpdateDataBefore( $store, $semanticData ) { |
|
227 | + public function onUpdateDataBefore($store, $semanticData) { |
|
228 | 228 | |
229 | 229 | $propertyAnnotator = new PropertyAnnotator( |
230 | 230 | new ServicesFactory() |
231 | 231 | ); |
232 | 232 | |
233 | 233 | $propertyAnnotator->setLogger( |
234 | - ApplicationFactory::getInstance()->getMediaWikiLogger( 'smw-approved-revs' ) |
|
234 | + ApplicationFactory::getInstance()->getMediaWikiLogger('smw-approved-revs') |
|
235 | 235 | ); |
236 | 236 | |
237 | - $propertyAnnotator->addAnnotation( $semanticData ); |
|
237 | + $propertyAnnotator->addAnnotation($semanticData); |
|
238 | 238 | |
239 | 239 | return true; |
240 | 240 | } |
@@ -249,11 +249,11 @@ discard block |
||
249 | 249 | * @param integer $rev_id |
250 | 250 | * @param string $content |
251 | 251 | */ |
252 | - public function onApprovedRevsRevisionApproved( $output, $title, $rev_id, $content ) { |
|
252 | + public function onApprovedRevsRevisionApproved($output, $title, $rev_id, $content) { |
|
253 | 253 | |
254 | 254 | $ttl = 60 * 60; // 1hr |
255 | 255 | |
256 | - if ( $this->cache === null ) { |
|
256 | + if ($this->cache === null) { |
|
257 | 257 | $this->cache = ApplicationFactory::getInstance()->getCache(); |
258 | 258 | } |
259 | 259 | |
@@ -262,8 +262,8 @@ discard block |
||
262 | 262 | // annotations. It is to ensure that when an agent switches to a blank |
263 | 263 | // version (no SMW related annotations or categories) the update is carried |
264 | 264 | // out and the store is able to remove any remaining annotations. |
265 | - $key = smwfCacheKey( 'smw:parseraftertidy', $title->getPrefixedDBKey() ); |
|
266 | - $this->cache->save( $key, $rev_id, $ttl ); |
|
265 | + $key = smwfCacheKey('smw:parseraftertidy', $title->getPrefixedDBKey()); |
|
266 | + $this->cache->save($key, $rev_id, $ttl); |
|
267 | 267 | |
268 | 268 | return true; |
269 | 269 | } |
@@ -278,17 +278,17 @@ discard block |
||
278 | 278 | * @param integer $timestamp |
279 | 279 | * @param string $sha1 |
280 | 280 | */ |
281 | - public function onApprovedRevsFileRevisionApproved( $parser, $title, $timestamp, $sha1 ) { |
|
281 | + public function onApprovedRevsFileRevisionApproved($parser, $title, $timestamp, $sha1) { |
|
282 | 282 | |
283 | 283 | $ttl = 60 * 60; // 1hr |
284 | 284 | |
285 | - if ( $this->cache === null ) { |
|
285 | + if ($this->cache === null) { |
|
286 | 286 | $this->cache = ApplicationFactory::getInstance()->getCache(); |
287 | 287 | } |
288 | 288 | |
289 | 289 | // @see onApprovedRevsRevisionApproved for the same reason |
290 | - $key = smwfCacheKey( 'smw:parseraftertidy', $title->getPrefixedDBKey() ); |
|
291 | - $this->cache->save( $key, $sha1, $ttl ); |
|
290 | + $key = smwfCacheKey('smw:parseraftertidy', $title->getPrefixedDBKey()); |
|
291 | + $this->cache->save($key, $sha1, $ttl); |
|
292 | 292 | |
293 | 293 | return true; |
294 | 294 | } |
@@ -301,27 +301,27 @@ discard block |
||
301 | 301 | * @param Title $title |
302 | 302 | * @param File &$file |
303 | 303 | */ |
304 | - public function onChangeFile( $title, &$file ) { |
|
304 | + public function onChangeFile($title, &$file) { |
|
305 | 305 | |
306 | 306 | $approvedRevsHandler = new ApprovedRevsHandler( |
307 | 307 | new ApprovedRevsFacade() |
308 | 308 | ); |
309 | 309 | |
310 | - $approvedRevsHandler->doChangeFile( $title, $file ); |
|
310 | + $approvedRevsHandler->doChangeFile($title, $file); |
|
311 | 311 | |
312 | 312 | return true; |
313 | 313 | } |
314 | 314 | |
315 | - private function registerHandlers( $config ) { |
|
315 | + private function registerHandlers($config) { |
|
316 | 316 | $this->handlers = [ |
317 | - 'ApprovedRevsRevisionApproved' => [ $this, 'onApprovedRevsRevisionApproved' ], |
|
318 | - 'ApprovedRevsFileRevisionApproved' => [ $this, 'onApprovedRevsFileRevisionApproved' ], |
|
319 | - 'SMW::RevisionGuard::IsApprovedRevision' => [ $this, 'onIsApprovedRevision' ], |
|
320 | - 'SMW::RevisionGuard::ChangeRevision' => [ $this, 'onChangeRevision' ], |
|
321 | - 'SMW::RevisionGuard::ChangeRevisionID' => [ $this, 'onOverrideRevisionID' ], |
|
322 | - 'SMW::RevisionGuard::ChangeFile' => [ $this, 'onChangeFile' ], |
|
323 | - 'SMW::Property::initProperties' => [ $this, 'onInitProperties' ], |
|
324 | - 'SMWStore::updateDataBefore' => [ $this, 'onUpdateDataBefore' ], |
|
317 | + 'ApprovedRevsRevisionApproved' => [$this, 'onApprovedRevsRevisionApproved'], |
|
318 | + 'ApprovedRevsFileRevisionApproved' => [$this, 'onApprovedRevsFileRevisionApproved'], |
|
319 | + 'SMW::RevisionGuard::IsApprovedRevision' => [$this, 'onIsApprovedRevision'], |
|
320 | + 'SMW::RevisionGuard::ChangeRevision' => [$this, 'onChangeRevision'], |
|
321 | + 'SMW::RevisionGuard::ChangeRevisionID' => [$this, 'onOverrideRevisionID'], |
|
322 | + 'SMW::RevisionGuard::ChangeFile' => [$this, 'onChangeFile'], |
|
323 | + 'SMW::Property::initProperties' => [$this, 'onInitProperties'], |
|
324 | + 'SMWStore::updateDataBefore' => [$this, 'onUpdateDataBefore'], |
|
325 | 325 | ]; |
326 | 326 | } |
327 | 327 | |
@@ -330,9 +330,9 @@ discard block |
||
330 | 330 | */ |
331 | 331 | public static function onExtensionFunction() { |
332 | 332 | |
333 | - if ( !defined( 'SMW_VERSION' ) ) { |
|
334 | - if ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' ) { |
|
335 | - die( "\nThe 'Semantic Approved Revs' extension requires the 'Semantic MediaWiki' extension to be installed and enabled.\n" ); |
|
333 | + if (!defined('SMW_VERSION')) { |
|
334 | + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { |
|
335 | + die("\nThe 'Semantic Approved Revs' extension requires the 'Semantic MediaWiki' extension to be installed and enabled.\n"); |
|
336 | 336 | } else { |
337 | 337 | die( |
338 | 338 | '<b>Error:</b> The <a href="https://github.com/SemanticMediaWiki/SemanticApprovedRevs/">Semantic Approved Revs</a> extension' . |
@@ -345,9 +345,9 @@ discard block |
||
345 | 345 | // its `extension.json` doesn't set the constant so we have to rely on |
346 | 346 | // active class loading (which is an anti-pattern) to check whether the |
347 | 347 | // extension is enabled or not! |
348 | - if ( !class_exists( 'ApprovedRevs' ) ) { |
|
349 | - if ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' ) { |
|
350 | - die( "\nThe 'Semantic Approved Revs' extension requires the 'Approved Revs' extension to be installed and enabled.\n" ); |
|
348 | + if (!class_exists('ApprovedRevs')) { |
|
349 | + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { |
|
350 | + die("\nThe 'Semantic Approved Revs' extension requires the 'Approved Revs' extension to be installed and enabled.\n"); |
|
351 | 351 | } else { |
352 | 352 | die( |
353 | 353 | '<b>Error:</b> The <a href="https://github.com/SemanticMediaWiki/SemanticApprovedRevs/">Semantic Approved Revs</a> extension' . |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | } |
357 | 357 | } |
358 | 358 | |
359 | - if ( defined( 'SESP_VERSION' ) && version_compare( SESP_VERSION, '2.1.0', '<' ) && ( $prop = Hooks::hasPropertyCollisions( $GLOBALS ) ) !== false ) { |
|
359 | + if (defined('SESP_VERSION') && version_compare(SESP_VERSION, '2.1.0', '<') && ($prop = Hooks::hasPropertyCollisions($GLOBALS)) !== false) { |
|
360 | 360 | die( |
361 | 361 | "\nPlease remove the `$prop` property (defined by the SemanticExtraSpecialProperties extension) and switch to the new SESP version 2.1" . |
362 | 362 | " to avoid collision with the 'Semantic Approved Revs' list of properties.\n" |