@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @param PropertyRegistry $propertyRegistry |
22 | 22 | */ |
23 | - public function register( $propertyRegistry ) { |
|
23 | + public function register($propertyRegistry) { |
|
24 | 24 | |
25 | 25 | $defs = [ |
26 | 26 | self::SAR_PROP_APPROVED_REV => [ |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | ] |
54 | 54 | ]; |
55 | 55 | |
56 | - foreach ( $defs as $key => $definition ) { |
|
56 | + foreach ($defs as $key => $definition) { |
|
57 | 57 | |
58 | 58 | $propertyRegistry->registerProperty( |
59 | 59 | $key, |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | |
65 | 65 | $propertyRegistry->registerPropertyAlias( |
66 | 66 | $key, |
67 | - wfMessage( $definition['alias'] )->text() |
|
67 | + wfMessage($definition['alias'])->text() |
|
68 | 68 | ); |
69 | 69 | |
70 | 70 | $propertyRegistry->registerPropertyAliasByMsgKey( |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param ApprovedRevsFacade $approvedRevsFacade |
34 | 34 | * @param RepoGroup|null $repoGroup |
35 | 35 | */ |
36 | - public function __construct( ApprovedRevsFacade $approvedRevsFacade, RepoGroup $repoGroup = null ) { |
|
36 | + public function __construct(ApprovedRevsFacade $approvedRevsFacade, RepoGroup $repoGroup = null) { |
|
37 | 37 | $this->approvedRevsFacade = $approvedRevsFacade; |
38 | 38 | $this->repoGroup = $repoGroup; |
39 | 39 | } |
@@ -46,13 +46,13 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @return boolean |
48 | 48 | */ |
49 | - public function isApprovedUpdate( Title $title, $latestRevID ) { |
|
49 | + public function isApprovedUpdate(Title $title, $latestRevID) { |
|
50 | 50 | |
51 | - if ( !$this->approvedRevsFacade->hasApprovedRevision( $title ) ) { |
|
51 | + if (!$this->approvedRevsFacade->hasApprovedRevision($title)) { |
|
52 | 52 | return true; |
53 | 53 | } |
54 | 54 | |
55 | - if ( ( $approvedRevID = $this->approvedRevsFacade->getApprovedRevID( $title ) ) !== null ) { |
|
55 | + if (($approvedRevID = $this->approvedRevsFacade->getApprovedRevID($title)) !== null) { |
|
56 | 56 | return $approvedRevID == $latestRevID; |
57 | 57 | } |
58 | 58 | |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | * @param Title $title |
66 | 66 | * @param ?RevisionStoreRecord &$revision |
67 | 67 | */ |
68 | - public function doChangeRevision( Title $title, ?RevisionStoreRecord &$revision ) { |
|
68 | + public function doChangeRevision(Title $title, ?RevisionStoreRecord &$revision) { |
|
69 | 69 | |
70 | 70 | // Forcibly change the revision to match what ApprovedRevs sees as |
71 | 71 | // approved |
72 | - if ( ( $approvedRevID = $this->approvedRevsFacade->getApprovedRevID( $title ) ) !== null ) { |
|
72 | + if (($approvedRevID = $this->approvedRevsFacade->getApprovedRevID($title)) !== null) { |
|
73 | 73 | $approvedRev = MediaWikiServices::getInstance() |
74 | - ->getRevisionLookup()->getRevisionById( $approvedRevID ); |
|
75 | - if ( $approvedRev instanceof RevisionStoreRecord ) { |
|
74 | + ->getRevisionLookup()->getRevisionById($approvedRevID); |
|
75 | + if ($approvedRev instanceof RevisionStoreRecord) { |
|
76 | 76 | $revision = $approvedRev; |
77 | 77 | } |
78 | 78 | } |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | * @param Title $title |
85 | 85 | * @param integer &$revisionID |
86 | 86 | */ |
87 | - public function doChangeRevisionID( Title $title, &$revisionID ) { |
|
87 | + public function doChangeRevisionID(Title $title, &$revisionID) { |
|
88 | 88 | |
89 | - if ( ( $approvedRevID = $this->approvedRevsFacade->getApprovedRevID( $title ) ) !== null ) { |
|
89 | + if (($approvedRevID = $this->approvedRevsFacade->getApprovedRevID($title)) !== null) { |
|
90 | 90 | $revisionID = $approvedRevID; |
91 | 91 | } |
92 | 92 | } |
@@ -97,37 +97,37 @@ discard block |
||
97 | 97 | * @param Title $title |
98 | 98 | * @param File &$file |
99 | 99 | */ |
100 | - public function doChangeFile( Title $title, &$file ) { |
|
100 | + public function doChangeFile(Title $title, &$file) { |
|
101 | 101 | |
102 | 102 | // It has been observed that when running `runJobs.php` with `--wait` |
103 | 103 | // the `ApprovedRevs` instance holds an outdated cache entry therefore |
104 | 104 | // clear the static before trying to get the info |
105 | - $this->approvedRevsFacade->clearApprovedFileInfo( $title ); |
|
105 | + $this->approvedRevsFacade->clearApprovedFileInfo($title); |
|
106 | 106 | |
107 | - list( $timestamp, $file_sha1 ) = $this->approvedRevsFacade->getApprovedFileInfo( |
|
107 | + list($timestamp, $file_sha1) = $this->approvedRevsFacade->getApprovedFileInfo( |
|
108 | 108 | $title |
109 | 109 | ); |
110 | 110 | |
111 | - if ( $file_sha1 === false ) { |
|
111 | + if ($file_sha1 === false) { |
|
112 | 112 | return true; |
113 | 113 | } |
114 | 114 | |
115 | - if ( $this->repoGroup === null ) { |
|
115 | + if ($this->repoGroup === null) { |
|
116 | 116 | $this->repoGroup = RepoGroup::singleton(); |
117 | 117 | } |
118 | 118 | |
119 | 119 | $localRepo = $this->repoGroup->getLocalRepo(); |
120 | 120 | |
121 | 121 | // Retrievalable from the archive? |
122 | - $file = OldLocalFile::newFromKey( $file_sha1, $localRepo, $timestamp ); |
|
122 | + $file = OldLocalFile::newFromKey($file_sha1, $localRepo, $timestamp); |
|
123 | 123 | |
124 | 124 | // Try the local repo! |
125 | - if ( $file === false ) { |
|
126 | - $files = $localRepo->findBySha1( $file_sha1 ); |
|
127 | - $file = end( $files ); |
|
125 | + if ($file === false) { |
|
126 | + $files = $localRepo->findBySha1($file_sha1); |
|
127 | + $file = end($files); |
|
128 | 128 | } |
129 | 129 | |
130 | - if ( $file instanceof File ) { |
|
130 | + if ($file instanceof File) { |
|
131 | 131 | $file->file_sha1 = $file_sha1; |
132 | 132 | } |
133 | 133 | } |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @param array $config |
31 | 31 | */ |
32 | - public function __construct( $config = [] ) { |
|
33 | - $this->registerHandlers( $config ); |
|
32 | + public function __construct($config = []) { |
|
33 | + $this->registerHandlers($config); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -38,16 +38,16 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @param Cache $cache |
40 | 40 | */ |
41 | - public function setCache( Cache $cache ) { |
|
41 | + public function setCache(Cache $cache) { |
|
42 | 42 | $this->cache = $cache; |
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
46 | 46 | * @since 1.0 |
47 | 47 | */ |
48 | - public static function hasPropertyCollisions( $var ) { |
|
48 | + public static function hasPropertyCollisions($var) { |
|
49 | 49 | |
50 | - if ( !isset( $var['sespgEnabledPropertyList'] ) ) { |
|
50 | + if (!isset($var['sespgEnabledPropertyList'])) { |
|
51 | 51 | return false; |
52 | 52 | } |
53 | 53 | |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | '_APPROVEDSTATUS' => true |
60 | 60 | ]; |
61 | 61 | |
62 | - foreach ( $var['sespgEnabledPropertyList'] as $key ) { |
|
63 | - if ( isset( $list[$key] ) ) { |
|
62 | + foreach ($var['sespgEnabledPropertyList'] as $key) { |
|
63 | + if (isset($list[$key])) { |
|
64 | 64 | return $key; |
65 | 65 | } |
66 | 66 | } |
@@ -73,15 +73,15 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @param array &$vars |
75 | 75 | */ |
76 | - public static function initExtension( &$vars ) { |
|
77 | - $version = 'UNKNOWN' ; |
|
76 | + public static function initExtension(&$vars) { |
|
77 | + $version = 'UNKNOWN'; |
|
78 | 78 | |
79 | 79 | // See https://phabricator.wikimedia.org/T151136 |
80 | - if ( isset( $credits['version'] ) ) { |
|
80 | + if (isset($credits['version'])) { |
|
81 | 81 | $version = $credits['version']; |
82 | 82 | } |
83 | 83 | |
84 | - define( 'SMW_APPROVED_REVS_VERSION', $version ); |
|
84 | + define('SMW_APPROVED_REVS_VERSION', $version); |
|
85 | 85 | |
86 | 86 | /** |
87 | 87 | * @see https://www.semantic-mediawiki.org/wiki/Hooks#SMW::Config::BeforeCompletion |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @param array &$config |
92 | 92 | */ |
93 | - $GLOBALS['wgHooks']['SMW::Config::BeforeCompletion'][] = function( &$config ) { |
|
93 | + $GLOBALS['wgHooks']['SMW::Config::BeforeCompletion'][] = function(&$config) { |
|
94 | 94 | |
95 | - if ( isset( $config['smwgImportFileDirs'] ) ) { |
|
96 | - $config['smwgImportFileDirs'] += [ 'sar' => __DIR__ . '/../data/import' ]; |
|
95 | + if (isset($config['smwgImportFileDirs'])) { |
|
96 | + $config['smwgImportFileDirs'] += ['sar' => __DIR__ . '/../data/import']; |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | return true; |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | * @since 1.0 |
105 | 105 | */ |
106 | 106 | public function register() { |
107 | - foreach ( $this->handlers as $name => $callback ) { |
|
108 | - \Hooks::register( $name, $callback ); |
|
107 | + foreach ($this->handlers as $name => $callback) { |
|
108 | + \Hooks::register($name, $callback); |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
@@ -113,13 +113,13 @@ discard block |
||
113 | 113 | * @since 1.0 |
114 | 114 | */ |
115 | 115 | public function deregister() { |
116 | - foreach ( array_keys( $this->handlers ) as $name ) { |
|
117 | - MediaWikiServices::getInstance()->getHookContainer()->clear( $name ); |
|
116 | + foreach (array_keys($this->handlers) as $name) { |
|
117 | + MediaWikiServices::getInstance()->getHookContainer()->clear($name); |
|
118 | 118 | |
119 | 119 | // Remove registered `wgHooks` hooks that are not cleared by the |
120 | 120 | // previous call |
121 | - if ( isset( $GLOBALS['wgHooks'][$name] ) ) { |
|
122 | - unset( $GLOBALS['wgHooks'][$name] ); |
|
121 | + if (isset($GLOBALS['wgHooks'][$name])) { |
|
122 | + unset($GLOBALS['wgHooks'][$name]); |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | } |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @return boolean |
133 | 133 | */ |
134 | - public function isRegistered( $name ) { |
|
135 | - return \Hooks::isRegistered( $name ); |
|
134 | + public function isRegistered($name) { |
|
135 | + return \Hooks::isRegistered($name); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -142,8 +142,8 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @return array |
144 | 144 | */ |
145 | - public function getHandlers( $name ) { |
|
146 | - return \Hooks::getHandlers( $name ); |
|
145 | + public function getHandlers($name) { |
|
146 | + return \Hooks::getHandlers($name); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -152,13 +152,13 @@ discard block |
||
152 | 152 | * @param Title $title |
153 | 153 | * @param integer $latestRevID |
154 | 154 | */ |
155 | - public function onIsApprovedRevision( $title, $latestRevID ) { |
|
155 | + public function onIsApprovedRevision($title, $latestRevID) { |
|
156 | 156 | |
157 | - $approvedRevsHandler = new ApprovedRevsHandler( |
|
157 | + $approvedRevsHandler = new ApprovedRevsHandler( |
|
158 | 158 | new ApprovedRevsFacade() |
159 | 159 | ); |
160 | 160 | |
161 | - return $approvedRevsHandler->isApprovedUpdate( $title, $latestRevID ); |
|
161 | + return $approvedRevsHandler->isApprovedUpdate($title, $latestRevID); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -167,13 +167,13 @@ discard block |
||
167 | 167 | * @param Title $title |
168 | 168 | * @param Revision|null &$revision |
169 | 169 | */ |
170 | - public function onChangeRevision( $title, &$revision ) { |
|
170 | + public function onChangeRevision($title, &$revision) { |
|
171 | 171 | |
172 | - $approvedRevsHandler = new ApprovedRevsHandler( |
|
172 | + $approvedRevsHandler = new ApprovedRevsHandler( |
|
173 | 173 | new ApprovedRevsFacade() |
174 | 174 | ); |
175 | 175 | |
176 | - $approvedRevsHandler->doChangeRevision( $title, $revision ); |
|
176 | + $approvedRevsHandler->doChangeRevision($title, $revision); |
|
177 | 177 | |
178 | 178 | return true; |
179 | 179 | } |
@@ -184,13 +184,13 @@ discard block |
||
184 | 184 | * @param Title $title |
185 | 185 | * @param integer &$latestRevID |
186 | 186 | */ |
187 | - public function onOverrideRevisionID( $title, &$latestRevID ) { |
|
187 | + public function onOverrideRevisionID($title, &$latestRevID) { |
|
188 | 188 | |
189 | - $approvedRevsHandler = new ApprovedRevsHandler( |
|
189 | + $approvedRevsHandler = new ApprovedRevsHandler( |
|
190 | 190 | new ApprovedRevsFacade() |
191 | 191 | ); |
192 | 192 | |
193 | - $approvedRevsHandler->doChangeRevisionID( $title, $latestRevID ); |
|
193 | + $approvedRevsHandler->doChangeRevisionID($title, $latestRevID); |
|
194 | 194 | |
195 | 195 | return true; |
196 | 196 | } |
@@ -203,10 +203,10 @@ discard block |
||
203 | 203 | * @param ProertyRegistry $$registry |
204 | 204 | * @param integer &$latestRevID |
205 | 205 | */ |
206 | - public function onInitProperties( $registry ) { |
|
206 | + public function onInitProperties($registry) { |
|
207 | 207 | |
208 | 208 | $propertyRegistry = new PropertyRegistry(); |
209 | - $propertyRegistry->register( $registry ); |
|
209 | + $propertyRegistry->register($registry); |
|
210 | 210 | |
211 | 211 | return true; |
212 | 212 | } |
@@ -219,17 +219,17 @@ discard block |
||
219 | 219 | * @param ProertyRegistry $$registry |
220 | 220 | * @param integer &$latestRevID |
221 | 221 | */ |
222 | - public function onUpdateDataBefore( $store, $semanticData ) { |
|
222 | + public function onUpdateDataBefore($store, $semanticData) { |
|
223 | 223 | |
224 | 224 | $propertyAnnotator = new PropertyAnnotator( |
225 | 225 | new ServicesFactory() |
226 | 226 | ); |
227 | 227 | |
228 | 228 | $propertyAnnotator->setLogger( |
229 | - ApplicationFactory::getInstance()->getMediaWikiLogger( 'smw-approved-revs' ) |
|
229 | + ApplicationFactory::getInstance()->getMediaWikiLogger('smw-approved-revs') |
|
230 | 230 | ); |
231 | 231 | |
232 | - $propertyAnnotator->addAnnotation( $semanticData ); |
|
232 | + $propertyAnnotator->addAnnotation($semanticData); |
|
233 | 233 | |
234 | 234 | return true; |
235 | 235 | } |
@@ -244,11 +244,11 @@ discard block |
||
244 | 244 | * @param integer $rev_id |
245 | 245 | * @param string $content |
246 | 246 | */ |
247 | - public function onApprovedRevsRevisionApproved( $output, $title, $rev_id, $content ) { |
|
247 | + public function onApprovedRevsRevisionApproved($output, $title, $rev_id, $content) { |
|
248 | 248 | |
249 | 249 | $ttl = 60 * 60; // 1hr |
250 | 250 | |
251 | - if ( $this->cache === null ) { |
|
251 | + if ($this->cache === null) { |
|
252 | 252 | $this->cache = ApplicationFactory::getInstance()->getCache(); |
253 | 253 | } |
254 | 254 | |
@@ -257,8 +257,8 @@ discard block |
||
257 | 257 | // annotations. It is to ensure that when an agent switches to a blank |
258 | 258 | // version (no SMW related annotations or categories) the update is carried |
259 | 259 | // out and the store is able to remove any remaining annotations. |
260 | - $key = smwfCacheKey( 'smw:parseraftertidy', $title->getPrefixedDBKey() ); |
|
261 | - $this->cache->save( $key, $rev_id, $ttl ); |
|
260 | + $key = smwfCacheKey('smw:parseraftertidy', $title->getPrefixedDBKey()); |
|
261 | + $this->cache->save($key, $rev_id, $ttl); |
|
262 | 262 | |
263 | 263 | return true; |
264 | 264 | } |
@@ -273,17 +273,17 @@ discard block |
||
273 | 273 | * @param integer $timestamp |
274 | 274 | * @param string $sha1 |
275 | 275 | */ |
276 | - public function onApprovedRevsFileRevisionApproved( $parser, $title, $timestamp, $sha1 ) { |
|
276 | + public function onApprovedRevsFileRevisionApproved($parser, $title, $timestamp, $sha1) { |
|
277 | 277 | |
278 | 278 | $ttl = 60 * 60; // 1hr |
279 | 279 | |
280 | - if ( $this->cache === null ) { |
|
280 | + if ($this->cache === null) { |
|
281 | 281 | $this->cache = ApplicationFactory::getInstance()->getCache(); |
282 | 282 | } |
283 | 283 | |
284 | 284 | // @see onApprovedRevsRevisionApproved for the same reason |
285 | - $key = smwfCacheKey( 'smw:parseraftertidy', $title->getPrefixedDBKey() ); |
|
286 | - $this->cache->save( $key, $sha1, $ttl ); |
|
285 | + $key = smwfCacheKey('smw:parseraftertidy', $title->getPrefixedDBKey()); |
|
286 | + $this->cache->save($key, $sha1, $ttl); |
|
287 | 287 | |
288 | 288 | return true; |
289 | 289 | } |
@@ -296,27 +296,27 @@ discard block |
||
296 | 296 | * @param Title $title |
297 | 297 | * @param File &$file |
298 | 298 | */ |
299 | - public function onChangeFile( $title, &$file ) { |
|
299 | + public function onChangeFile($title, &$file) { |
|
300 | 300 | |
301 | 301 | $approvedRevsHandler = new ApprovedRevsHandler( |
302 | 302 | new ApprovedRevsFacade() |
303 | 303 | ); |
304 | 304 | |
305 | - $approvedRevsHandler->doChangeFile( $title, $file ); |
|
305 | + $approvedRevsHandler->doChangeFile($title, $file); |
|
306 | 306 | |
307 | 307 | return true; |
308 | 308 | } |
309 | 309 | |
310 | - private function registerHandlers( $config ) { |
|
310 | + private function registerHandlers($config) { |
|
311 | 311 | $this->handlers = [ |
312 | - 'ApprovedRevsRevisionApproved' => [ $this, 'onApprovedRevsRevisionApproved' ], |
|
313 | - 'ApprovedRevsFileRevisionApproved' => [ $this, 'onApprovedRevsFileRevisionApproved' ], |
|
314 | - 'SMW::RevisionGuard::IsApprovedRevision' => [ $this, 'onIsApprovedRevision' ], |
|
315 | - 'SMW::RevisionGuard::ChangeRevision' => [ $this, 'onChangeRevision' ], |
|
316 | - 'SMW::RevisionGuard::ChangeRevisionID' => [ $this, 'onOverrideRevisionID' ], |
|
317 | - 'SMW::RevisionGuard::ChangeFile' => [ $this, 'onChangeFile' ], |
|
318 | - 'SMW::Property::initProperties' => [ $this, 'onInitProperties' ], |
|
319 | - 'SMWStore::updateDataBefore' => [ $this, 'onUpdateDataBefore' ], |
|
312 | + 'ApprovedRevsRevisionApproved' => [$this, 'onApprovedRevsRevisionApproved'], |
|
313 | + 'ApprovedRevsFileRevisionApproved' => [$this, 'onApprovedRevsFileRevisionApproved'], |
|
314 | + 'SMW::RevisionGuard::IsApprovedRevision' => [$this, 'onIsApprovedRevision'], |
|
315 | + 'SMW::RevisionGuard::ChangeRevision' => [$this, 'onChangeRevision'], |
|
316 | + 'SMW::RevisionGuard::ChangeRevisionID' => [$this, 'onOverrideRevisionID'], |
|
317 | + 'SMW::RevisionGuard::ChangeFile' => [$this, 'onChangeFile'], |
|
318 | + 'SMW::Property::initProperties' => [$this, 'onInitProperties'], |
|
319 | + 'SMWStore::updateDataBefore' => [$this, 'onUpdateDataBefore'], |
|
320 | 320 | ]; |
321 | 321 | } |
322 | 322 | |
@@ -325,9 +325,9 @@ discard block |
||
325 | 325 | */ |
326 | 326 | public static function onExtensionFunction() { |
327 | 327 | |
328 | - if ( !defined( 'SMW_VERSION' ) ) { |
|
329 | - if ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' ) { |
|
330 | - die( "\nThe 'Semantic Approved Revs' extension requires the 'Semantic MediaWiki' extension to be installed and enabled.\n" ); |
|
328 | + if (!defined('SMW_VERSION')) { |
|
329 | + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { |
|
330 | + die("\nThe 'Semantic Approved Revs' extension requires the 'Semantic MediaWiki' extension to be installed and enabled.\n"); |
|
331 | 331 | } else { |
332 | 332 | die( |
333 | 333 | '<b>Error:</b> The <a href="https://github.com/SemanticMediaWiki/SemanticApprovedRevs/">Semantic Approved Revs</a> extension' . |
@@ -340,9 +340,9 @@ discard block |
||
340 | 340 | // its `extension.json` doesn't set the constant so we have to rely on |
341 | 341 | // active class loading (which is an anti-pattern) to check whether the |
342 | 342 | // extension is enabled or not! |
343 | - if ( !class_exists( 'ApprovedRevs' ) ) { |
|
344 | - if ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' ) { |
|
345 | - die( "\nThe 'Semantic Approved Revs' extension requires the 'Approved Revs' extension to be installed and enabled.\n" ); |
|
343 | + if (!class_exists('ApprovedRevs')) { |
|
344 | + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { |
|
345 | + die("\nThe 'Semantic Approved Revs' extension requires the 'Approved Revs' extension to be installed and enabled.\n"); |
|
346 | 346 | } else { |
347 | 347 | die( |
348 | 348 | '<b>Error:</b> The <a href="https://github.com/SemanticMediaWiki/SemanticApprovedRevs/">Semantic Approved Revs</a> extension' . |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | } |
352 | 352 | } |
353 | 353 | |
354 | - if ( defined( 'SESP_VERSION' ) && version_compare( SESP_VERSION, '2.1.0', '<' ) && ( $prop = Hooks::hasPropertyCollisions( $GLOBALS ) ) !== false ) { |
|
354 | + if (defined('SESP_VERSION') && version_compare(SESP_VERSION, '2.1.0', '<') && ($prop = Hooks::hasPropertyCollisions($GLOBALS)) !== false) { |
|
355 | 355 | die( |
356 | 356 | "\nPlease remove the `$prop` property (defined by the SemanticExtraSpecialProperties extension) and switch to the new SESP version 2.1" . |
357 | 357 | " to avoid collision with the 'Semantic Approved Revs' list of properties.\n" |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @param Title|null $title |
49 | 49 | * @param string $type of log (default: approval) |
50 | 50 | */ |
51 | - public function __construct( IDatabase $dbr, Title $title = null , $type = 'approval' ) { |
|
51 | + public function __construct(IDatabase $dbr, Title $title = null, $type = 'approval') { |
|
52 | 52 | $this->dbr = $dbr; |
53 | 53 | $this->dbKey = $title instanceof Title ? $title->getDBkey() : null; |
54 | 54 | $this->type = $type; |
@@ -80,13 +80,13 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return User |
82 | 82 | */ |
83 | - public function getUserForLogEntry( Title $title = null, $type = 'approval' ) { |
|
83 | + public function getUserForLogEntry(Title $title = null, $type = 'approval') { |
|
84 | 84 | |
85 | - $this->init( $title, $type ); |
|
85 | + $this->init($title, $type); |
|
86 | 86 | $logLine = $this->getLog()->current(); |
87 | 87 | |
88 | - if ( $logLine && $logLine->user_id ) { |
|
89 | - return User::newFromID( $logLine->user_id ); |
|
88 | + if ($logLine && $logLine->user_id) { |
|
89 | + return User::newFromID($logLine->user_id); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
@@ -98,13 +98,13 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @return Timestamp |
100 | 100 | */ |
101 | - public function getDateOfLogEntry( Title $title = null, $type = 'approval' ) { |
|
101 | + public function getDateOfLogEntry(Title $title = null, $type = 'approval') { |
|
102 | 102 | |
103 | - $this->init( $title, $type ); |
|
103 | + $this->init($title, $type); |
|
104 | 104 | $logLine = $this->getLog()->current(); |
105 | 105 | |
106 | - if ( $logLine && $logLine->log_timestamp ) { |
|
107 | - return new MWTimestamp( $logLine->log_timestamp ); |
|
106 | + if ($logLine && $logLine->log_timestamp) { |
|
107 | + return new MWTimestamp($logLine->log_timestamp); |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | |
@@ -116,12 +116,12 @@ discard block |
||
116 | 116 | * |
117 | 117 | * @return string |
118 | 118 | */ |
119 | - public function getStatusOfLogEntry( Title $title = null, $type = 'approval' ) { |
|
119 | + public function getStatusOfLogEntry(Title $title = null, $type = 'approval') { |
|
120 | 120 | |
121 | - $this->init( $title, $type ); |
|
121 | + $this->init($title, $type); |
|
122 | 122 | $logLine = $this->getLog()->current(); |
123 | 123 | |
124 | - if ( $logLine && $logLine->log_action ) { |
|
124 | + if ($logLine && $logLine->log_action) { |
|
125 | 125 | return $logLine->log_action; |
126 | 126 | } |
127 | 127 | } |
@@ -129,26 +129,26 @@ discard block |
||
129 | 129 | /** |
130 | 130 | * Take care of loading from the cache or filling the query. |
131 | 131 | */ |
132 | - private function init( $title, $type ) { |
|
132 | + private function init($title, $type) { |
|
133 | 133 | |
134 | 134 | $this->dbKey = $title instanceof Title ? $title->getDBkey() : null; |
135 | 135 | $this->type = $type; |
136 | 136 | |
137 | - if ( $this->query ) { |
|
137 | + if ($this->query) { |
|
138 | 138 | return; |
139 | 139 | } |
140 | 140 | |
141 | - if ( !isset( self::$titleCache[ $this->dbKey . '#' . $this->type ] ) ) { |
|
141 | + if (!isset(self::$titleCache[$this->dbKey . '#' . $this->type])) { |
|
142 | 142 | $this->query = DatabaseLogEntry::getSelectQueryData(); |
143 | 143 | |
144 | 144 | $this->query['conds'] = [ |
145 | 145 | 'log_type' => $this->type, |
146 | 146 | 'log_title' => $this->dbKey |
147 | 147 | ]; |
148 | - $this->query['options'] = [ 'ORDER BY' => 'log_timestamp desc' ]; |
|
149 | - self::$titleCache[ $this->dbKey ] = $this; |
|
148 | + $this->query['options'] = ['ORDER BY' => 'log_timestamp desc']; |
|
149 | + self::$titleCache[$this->dbKey] = $this; |
|
150 | 150 | } else { |
151 | - $cache = self::$titleCache[ $this->dbKey . '#' . $this->type ]; |
|
151 | + $cache = self::$titleCache[$this->dbKey . '#' . $this->type]; |
|
152 | 152 | $this->query = $cache->getQuery(); |
153 | 153 | $this->log = $cache->getLog(); |
154 | 154 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | */ |
164 | 164 | private function getLog() { |
165 | 165 | |
166 | - if ( $this->log !== null ) { |
|
166 | + if ($this->log !== null) { |
|
167 | 167 | return $this->log; |
168 | 168 | } |
169 | 169 | |
@@ -178,13 +178,13 @@ discard block |
||
178 | 178 | $query['join_conds'] |
179 | 179 | ); |
180 | 180 | |
181 | - if ( $this->log === null ) { |
|
181 | + if ($this->log === null) { |
|
182 | 182 | $this->log = new ArrayIterator( |
183 | - [ (object)[ |
|
183 | + [(object)[ |
|
184 | 184 | 'user_id' => null, |
185 | 185 | 'log_timestamp' => null, |
186 | 186 | 'log_action' => null |
187 | - ] ] |
|
187 | + ]] |
|
188 | 188 | ); |
189 | 189 | } |
190 | 190 |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * |
38 | 38 | * @param ServicesFactory $servicesFactory |
39 | 39 | */ |
40 | - public function __construct( ServicesFactory $servicesFactory ) { |
|
40 | + public function __construct(ServicesFactory $servicesFactory) { |
|
41 | 41 | $this->servicesFactory = $servicesFactory; |
42 | 42 | } |
43 | 43 | |
@@ -46,31 +46,31 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @param SemanticData $semanticData |
48 | 48 | */ |
49 | - public function addAnnotation( SemanticData $semanticData ) { |
|
49 | + public function addAnnotation(SemanticData $semanticData) { |
|
50 | 50 | |
51 | - $time = microtime( true ); |
|
51 | + $time = microtime(true); |
|
52 | 52 | |
53 | - if ( !$this->canAnnotate( $semanticData->getSubject() ) ) { |
|
53 | + if (!$this->canAnnotate($semanticData->getSubject())) { |
|
54 | 54 | return; |
55 | 55 | } |
56 | 56 | |
57 | - if ( $this->propertyAnnotators === [] ) { |
|
57 | + if ($this->propertyAnnotators === []) { |
|
58 | 58 | $this->initPropertyAnnotators(); |
59 | 59 | } |
60 | 60 | |
61 | - foreach ( $this->propertyAnnotators as $propertyAnnotator ) { |
|
62 | - $propertyAnnotator->addAnnotation( $semanticData ); |
|
61 | + foreach ($this->propertyAnnotators as $propertyAnnotator) { |
|
62 | + $propertyAnnotator->addAnnotation($semanticData); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | $this->logger->info( |
66 | - [ 'SemanticApprovedRevs', 'procTime:{procTime}' ], |
|
67 | - [ 'procTime' => round( ( microtime( true ) - $time ), 5 ) ] |
|
66 | + ['SemanticApprovedRevs', 'procTime:{procTime}'], |
|
67 | + ['procTime' => round((microtime(true) - $time), 5)] |
|
68 | 68 | ); |
69 | 69 | } |
70 | 70 | |
71 | - private function canAnnotate( $subject ) { |
|
71 | + private function canAnnotate($subject) { |
|
72 | 72 | |
73 | - if ( $subject === null || $subject->getTitle() === null || $subject->getTitle()->isSpecialPage() ) { |
|
73 | + if ($subject === null || $subject->getTitle() === null || $subject->getTitle()->isSpecialPage()) { |
|
74 | 74 | return false; |
75 | 75 | } |
76 | 76 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | /** |
25 | 25 | * @since 1.0 |
26 | 26 | */ |
27 | - public function setConnection( \DatabaseBase $connection ) { |
|
27 | + public function setConnection(\DatabaseBase $connection) { |
|
28 | 28 | $this->connection = $connection; |
29 | 29 | } |
30 | 30 | |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function getConnection() { |
37 | 37 | |
38 | - if ( $this->connection === null ) { |
|
39 | - $this->connection = wfGetDB( DB_REPLICA ); |
|
38 | + if ($this->connection === null) { |
|
39 | + $this->connection = wfGetDB(DB_REPLICA); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | return $this->connection; |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | * @param string $type which log entries to get (default: approval) |
59 | 59 | * @return DatabaseLogReader |
60 | 60 | */ |
61 | - public function newDatabaseLogReader( Title $title = null, $type = 'approval' ) { |
|
62 | - return new DatabaseLogReader( $this->getConnection(), $title, $type ); |
|
61 | + public function newDatabaseLogReader(Title $title = null, $type = 'approval') { |
|
62 | + return new DatabaseLogReader($this->getConnection(), $title, $type); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @return ApprovedByPropertyAnnotator |
69 | 69 | */ |
70 | 70 | public function newApprovedByPropertyAnnotator() { |
71 | - return new ApprovedByPropertyAnnotator( $this->newDatabaseLogReader() ); |
|
71 | + return new ApprovedByPropertyAnnotator($this->newDatabaseLogReader()); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @return ApprovedStatusPropertyAnnotator |
78 | 78 | */ |
79 | 79 | public function newApprovedStatusPropertyAnnotator() { |
80 | - return new ApprovedStatusPropertyAnnotator( $this->newDatabaseLogReader() ); |
|
80 | + return new ApprovedStatusPropertyAnnotator($this->newDatabaseLogReader()); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @return ApprovedDatePropertyAnnotator |
87 | 87 | */ |
88 | 88 | public function newApprovedDatePropertyAnnotator() { |
89 | - return new ApprovedDatePropertyAnnotator( $this->newDatabaseLogReader() ); |
|
89 | + return new ApprovedDatePropertyAnnotator($this->newDatabaseLogReader()); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @return ApprovedRevPropertyAnnotator |
96 | 96 | */ |
97 | 97 | public function newApprovedRevPropertyAnnotator() { |
98 | - return new ApprovedRevPropertyAnnotator( $this->newApprovedRevsFacade() ); |
|
98 | + return new ApprovedRevPropertyAnnotator($this->newApprovedRevsFacade()); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | } |
@@ -24,8 +24,8 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @return integer|null |
26 | 26 | */ |
27 | - public function getApprovedRevID( Title $title ) { |
|
28 | - return ApprovedRevs::getApprovedRevID( $title ); |
|
27 | + public function getApprovedRevID(Title $title) { |
|
28 | + return ApprovedRevs::getApprovedRevID($title); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @return boolean |
37 | 37 | */ |
38 | - public function hasApprovedRevision( Title $title ) { |
|
39 | - return ApprovedRevs::hasApprovedRevision( $title ); |
|
38 | + public function hasApprovedRevision(Title $title) { |
|
39 | + return ApprovedRevs::hasApprovedRevision($title); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @return [] |
48 | 48 | */ |
49 | - public function getApprovedFileInfo( Title $title ) { |
|
50 | - return ApprovedRevs::getApprovedFileInfo( $title ); |
|
49 | + public function getApprovedFileInfo(Title $title) { |
|
50 | + return ApprovedRevs::getApprovedFileInfo($title); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @param Title $title |
57 | 57 | */ |
58 | - public function clearApprovedFileInfo( Title $title ) { |
|
59 | - ApprovedRevs::clearApprovedFileInfo( $title ); |
|
58 | + public function clearApprovedFileInfo(Title $title) { |
|
59 | + ApprovedRevs::clearApprovedFileInfo($title); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | use SMW\DIProperty; |
6 | 6 | use SMW\SemanticData; |
7 | -use SMWDITime as DITime;; |
|
7 | +use SMWDITime as DITime; ; |
|
8 | 8 | use SMW\ApprovedRevs\DatabaseLogReader; |
9 | 9 | use SMW\ApprovedRevs\PropertyRegistry; |
10 | 10 | use User; |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | /** |
30 | 30 | * @param DatabaseLogReader $databaseLogReader |
31 | 31 | */ |
32 | - public function __construct( DatabaseLogReader $databaseLogReader ) { |
|
32 | + public function __construct(DatabaseLogReader $databaseLogReader) { |
|
33 | 33 | $this->databaseLogReader = $databaseLogReader; |
34 | 34 | } |
35 | 35 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @param integer $approvedDate |
40 | 40 | */ |
41 | - public function setApprovedDate( $approvedDate ) { |
|
41 | + public function setApprovedDate($approvedDate) { |
|
42 | 42 | $this->approvedDate = $approvedDate; |
43 | 43 | } |
44 | 44 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @return DIProperty |
49 | 49 | */ |
50 | 50 | public function newDIProperty() { |
51 | - return new DIProperty( PropertyRegistry::SAR_PROP_APPROVED_DATE ); |
|
51 | + return new DIProperty(PropertyRegistry::SAR_PROP_APPROVED_DATE); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @param SemanticData $semanticData |
58 | 58 | */ |
59 | - public function addAnnotation( SemanticData $semanticData ) { |
|
59 | + public function addAnnotation(SemanticData $semanticData) { |
|
60 | 60 | |
61 | - if ( $this->approvedDate === null ) { |
|
61 | + if ($this->approvedDate === null) { |
|
62 | 62 | $this->approvedDate = $this->databaseLogReader->getDateOfLogEntry( |
63 | 63 | $semanticData->getSubject()->getTitle(), |
64 | 64 | 'approval' |
@@ -67,16 +67,16 @@ discard block |
||
67 | 67 | |
68 | 68 | $property = $this->newDIProperty(); |
69 | 69 | $dataItem = $this->newDITime(); |
70 | - $semanticData->removeProperty( $property ); |
|
70 | + $semanticData->removeProperty($property); |
|
71 | 71 | |
72 | - if ( $dataItem ) { |
|
73 | - $semanticData->addPropertyObjectValue( $property, $dataItem ); |
|
72 | + if ($dataItem) { |
|
73 | + $semanticData->addPropertyObjectValue($property, $dataItem); |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
77 | 77 | private function newDITime() { |
78 | 78 | |
79 | - if ( $this->approvedDate === null || is_bool( $this->approvedDate ) ) { |
|
79 | + if ($this->approvedDate === null || is_bool($this->approvedDate)) { |
|
80 | 80 | return; |
81 | 81 | } |
82 | 82 | |
@@ -84,11 +84,11 @@ discard block |
||
84 | 84 | |
85 | 85 | return new DITime( |
86 | 86 | DITime::CM_GREGORIAN, |
87 | - $date->format( 'Y' ), |
|
88 | - $date->format( 'm' ), |
|
89 | - $date->format( 'd' ), |
|
90 | - $date->format( 'H' ), |
|
91 | - $date->format( 'i' ) |
|
87 | + $date->format('Y'), |
|
88 | + $date->format('m'), |
|
89 | + $date->format('d'), |
|
90 | + $date->format('H'), |
|
91 | + $date->format('i') |
|
92 | 92 | ); |
93 | 93 | } |
94 | 94 |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | /** |
29 | 29 | * @param DatabaseLogReader $databaseLogReader |
30 | 30 | */ |
31 | - public function __construct( DatabaseLogReader $databaseLogReader ) { |
|
31 | + public function __construct(DatabaseLogReader $databaseLogReader) { |
|
32 | 32 | $this->databaseLogReader = $databaseLogReader; |
33 | 33 | } |
34 | 34 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * |
38 | 38 | * @param string $approvedStatus |
39 | 39 | */ |
40 | - public function setApprovedStatus( $approvedStatus ) { |
|
40 | + public function setApprovedStatus($approvedStatus) { |
|
41 | 41 | $this->approvedStatus = $approvedStatus; |
42 | 42 | } |
43 | 43 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @return DIProperty |
48 | 48 | */ |
49 | 49 | public function newDIProperty() { |
50 | - return new DIProperty( PropertyRegistry::SAR_PROP_APPROVED_STATUS ); |
|
50 | + return new DIProperty(PropertyRegistry::SAR_PROP_APPROVED_STATUS); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @param SemanticData $semanticData |
57 | 57 | */ |
58 | - public function addAnnotation( SemanticData $semanticData ) { |
|
58 | + public function addAnnotation(SemanticData $semanticData) { |
|
59 | 59 | |
60 | - if ( $this->approvedStatus === null ) { |
|
60 | + if ($this->approvedStatus === null) { |
|
61 | 61 | $this->approvedStatus = $this->databaseLogReader->getStatusOfLogEntry( |
62 | 62 | $semanticData->getSubject()->getTitle(), |
63 | 63 | 'approval' |
@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | $property = $this->newDIProperty(); |
68 | - $semanticData->removeProperty( $property ); |
|
68 | + $semanticData->removeProperty($property); |
|
69 | 69 | |
70 | - if ( is_string( $this->approvedStatus ) && $this->approvedStatus !== '' ) { |
|
70 | + if (is_string($this->approvedStatus) && $this->approvedStatus !== '') { |
|
71 | 71 | $semanticData->addPropertyObjectValue( |
72 | 72 | $property, |
73 | - new DIBlob( $this->approvedStatus ) |
|
73 | + new DIBlob($this->approvedStatus) |
|
74 | 74 | ); |
75 | 75 | } |
76 | 76 | } |