Index: trunk/extensions/AbuseFilter/special/SpecialAbuseLog.php |
— | — | @@ -111,10 +111,6 @@ |
112 | 112 | $this->getOutput()->addHTML( $output ); |
113 | 113 | } |
114 | 114 | |
115 | | - /** |
116 | | - * @param $id |
117 | | - * @return mixed |
118 | | - */ |
119 | 115 | function showHideForm( $id ) { |
120 | 116 | if ( !$this->getUser()->isAllowed( 'abusefilter-hide-log' ) ) { |
121 | 117 | $this->getOutput()->addWikiMsg( 'abusefilter-log-hide-forbidden' ); |
— | — | @@ -161,10 +157,6 @@ |
162 | 158 | $form->show(); |
163 | 159 | } |
164 | 160 | |
165 | | - /** |
166 | | - * @param $fields |
167 | | - * @return bool |
168 | | - */ |
169 | 161 | function saveHideForm( $fields ) { |
170 | 162 | $logid = $this->getRequest()->getVal( 'hide' ); |
171 | 163 | |
— | — | @@ -231,10 +223,6 @@ |
232 | 224 | } |
233 | 225 | } |
234 | 226 | |
235 | | - /** |
236 | | - * @param $id |
237 | | - * @return mixed |
238 | | - */ |
239 | 227 | function showDetails( $id ) { |
240 | 228 | $out = $this->getOutput(); |
241 | 229 | |
— | — | @@ -264,7 +252,7 @@ |
265 | 253 | return; |
266 | 254 | } |
267 | 255 | |
268 | | - if ( $this->isHidden( $row ) && !self::canSeeHidden() ) { |
| 256 | + if ( $row->afl_deleted && !self::canSeeHidden() ) { |
269 | 257 | $out->addWikiMsg( 'abusefilter-log-details-hidden' ); |
270 | 258 | return; |
271 | 259 | } |
— | — | @@ -345,8 +333,6 @@ |
346 | 334 | } |
347 | 335 | |
348 | 336 | /** |
349 | | - * @param $filter_id null |
350 | | - * @param $filter_hidden null |
351 | 337 | * @return bool |
352 | 338 | */ |
353 | 339 | static function canSeeDetails( $filter_id = null, $filter_hidden = null ) { |
— | — | @@ -380,49 +366,25 @@ |
381 | 367 | return $wgUser->isAllowed( 'abusefilter-hidden-log' ); |
382 | 368 | } |
383 | 369 | |
384 | | - /** |
385 | | - * @param $row |
386 | | - * @param $li bool |
387 | | - * @return String |
388 | | - */ |
389 | 370 | function formatRow( $row, $li = true ) { |
390 | 371 | $user = $this->getUser(); |
| 372 | + $sk = $this->getSkin(); |
391 | 373 | $lang = $this->getLanguage(); |
392 | 374 | |
393 | 375 | $actionLinks = array(); |
394 | 376 | |
395 | 377 | $title = Title::makeTitle( $row->afl_namespace, $row->afl_title ); |
396 | 378 | |
397 | | - $diffLink = false; |
398 | | - |
399 | | - if ( self::isHidden($row) && ! $this->canSeeHidden() ) { |
400 | | - return ''; |
401 | | - } |
402 | | - |
403 | 379 | if ( !$row->afl_wiki ) { |
404 | | - $pageLink = Linker::link( $title ); |
405 | | - if ( $row->afl_rev_id ) { |
406 | | - $diffLink = Linker::link( $title, |
407 | | - wfMessage('abusefilter-log-diff')->parse(), array(), |
408 | | - array( 'diff' => 'prev', 'oldid' => $row->afl_rev_id ) ); |
409 | | - } |
| 380 | + $pageLink = $sk->link( $title ); |
410 | 381 | } else { |
411 | 382 | $pageLink = WikiMap::makeForeignLink( $row->afl_wiki, $row->afl_title ); |
412 | | - |
413 | | - if ( $row->afl_rev_id ) { |
414 | | - $diffUrl = WikiMap::getForeignURL( $row->afl_wiki, $row->afl_title ); |
415 | | - $diffUrl = wfAppendQuery( $diffUrl, |
416 | | - array( 'diff' => 'prev', 'oldid' => $row->afl_rev_id ) ); |
417 | | - |
418 | | - $diffLink = Linker::makeExternalLink( $diffUrl, |
419 | | - wfMessage('abusefilter-log-diff')->parse() ); |
420 | | - } |
421 | 383 | } |
422 | 384 | |
423 | 385 | if ( !$row->afl_wiki ) { |
424 | 386 | // Local user |
425 | | - $userLink = Linker::userLink( $row->afl_user, $row->afl_user_text ) . |
426 | | - Linker::userToolLinks( $row->afl_user, $row->afl_user_text ); |
| 387 | + $userLink = $sk->userLink( $row->afl_user, $row->afl_user_text ) . |
| 388 | + $sk->userToolLinks( $row->afl_user, $row->afl_user_text ); |
427 | 389 | } else { |
428 | 390 | $userLink = WikiMap::foreignUserLink( $row->afl_wiki, $row->afl_user_text ); |
429 | 391 | $userLink .= ' (' . WikiMap::getWikiName( $row->afl_wiki ) . ')'; |
— | — | @@ -458,11 +420,11 @@ |
459 | 421 | |
460 | 422 | if ( self::canSeeDetails( $row->afl_filter, $filter_hidden ) ) { |
461 | 423 | $examineTitle = SpecialPage::getTitleFor( 'AbuseFilter', 'examine/log/' . $row->afl_id ); |
462 | | - $detailsLink = Linker::makeKnownLinkObj( |
| 424 | + $detailsLink = $sk->makeKnownLinkObj( |
463 | 425 | $this->getTitle($row->afl_id), |
464 | 426 | wfMsg( 'abusefilter-log-detailslink' ) |
465 | 427 | ); |
466 | | - $examineLink = Linker::link( |
| 428 | + $examineLink = $sk->link( |
467 | 429 | $examineTitle, |
468 | 430 | wfMsgExt( 'abusefilter-changeslist-examine', 'parseinline' ), |
469 | 431 | array() |
— | — | @@ -471,11 +433,8 @@ |
472 | 434 | $actionLinks[] = $detailsLink; |
473 | 435 | $actionLinks[] = $examineLink; |
474 | 436 | |
475 | | - if ($diffLink) |
476 | | - $actionLinks[] = $diffLink; |
477 | | - |
478 | 437 | if ( $user->isAllowed( 'abusefilter-hide-log' ) ) { |
479 | | - $hideLink = Linker::link( |
| 438 | + $hideLink = $sk->link( |
480 | 439 | $this->getTitle(), |
481 | 440 | wfMsg( 'abusefilter-log-hidelink' ), |
482 | 441 | array(), |
— | — | @@ -492,11 +451,11 @@ |
493 | 452 | 'Special:AbuseFilter/' . $globalIndex ); |
494 | 453 | |
495 | 454 | $linkText = wfMessage( 'abusefilter-log-detailedentry-global' )->numParams( $globalIndex )->escaped(); |
496 | | - $filterLink = Linker::makeExternalLink( $globalURL, $linkText ); |
| 455 | + $filterLink = $sk->makeExternalLink( $globalURL, $linkText ); |
497 | 456 | } else { |
498 | 457 | $title = SpecialPage::getTitleFor( 'AbuseFilter', $row->afl_filter ); |
499 | 458 | $linkText = wfMessage( 'abusefilter-log-detailedentry-local' )->numParams( $row->afl_filter )->escaped(); |
500 | | - $filterLink = Linker::link( $title, $linkText ); |
| 459 | + $filterLink = $sk->link( $title, $linkText ); |
501 | 460 | } |
502 | 461 | $description = wfMsgExt( 'abusefilter-log-detailedentry-meta', |
503 | 462 | array( 'parseinline', 'replaceafter' ), |
— | — | @@ -519,19 +478,16 @@ |
520 | 479 | $timestamp, |
521 | 480 | $userLink, |
522 | 481 | $row->afl_action, |
523 | | - Linker::link( $title ), |
| 482 | + $sk->link( $title ), |
524 | 483 | $actions_taken, |
525 | 484 | $parsed_comments |
526 | 485 | ) |
527 | 486 | ); |
528 | 487 | } |
529 | 488 | |
530 | | - if ( $this->isHidden($row) === true ) { |
| 489 | + if ( $row->afl_deleted ) { |
531 | 490 | $description .= ' '. |
532 | 491 | wfMsgExt( 'abusefilter-log-hidden', 'parseinline' ); |
533 | | - } elseif ( $this->isHidden($row) === 'implicit' ) { |
534 | | - $description .= ' '. |
535 | | - wfMsgExt( 'abusefilter-log-hidden-implicit', 'parseinline' ); |
536 | 492 | } |
537 | 493 | |
538 | 494 | return $li ? Xml::tags( 'li', null, $description ) : $description; |
— | — | @@ -551,25 +507,6 @@ |
552 | 508 | |
553 | 509 | return $notDeletedCond; |
554 | 510 | } |
555 | | - |
556 | | - /** |
557 | | - * Given a log entry row, decides whether or not it can be viewed by the public. |
558 | | - * |
559 | | - * @param $row object The abuse_filter_log row object. |
560 | | - * |
561 | | - * @return Mixed true if the item is explicitly hidden, false if it is not. |
562 | | - * The string 'implicit' if it is hidden because the corresponding revision is hidden. |
563 | | - */ |
564 | | - public static function isHidden( $row ) { |
565 | | - if ( $row->afl_rev_id ) { |
566 | | - $revision = Revision::newFromId( $row->afl_rev_id ); |
567 | | - if ( $revision && $revision->getVisibility() != 0 ) { |
568 | | - return 'implicit'; |
569 | | - } |
570 | | - } |
571 | | - |
572 | | - return (bool)$row->afl_deleted; |
573 | | - } |
574 | 511 | } |
575 | 512 | |
576 | 513 | class AbuseLogPager extends ReverseChronologicalPager { |
— | — | @@ -584,11 +521,6 @@ |
585 | 522 | */ |
586 | 523 | public $mConds; |
587 | 524 | |
588 | | - /** |
589 | | - * @param $form |
590 | | - * @param array $conds |
591 | | - * @param bool $details |
592 | | - */ |
593 | 525 | function __construct( $form, $conds = array(), $details = false ) { |
594 | 526 | $this->mForm = $form; |
595 | 527 | $this->mConds = $conds; |
Index: trunk/extensions/AbuseFilter/AbuseFilter.parser.php |
— | — | @@ -74,20 +74,11 @@ |
75 | 75 | var $type; |
76 | 76 | var $data; |
77 | 77 | |
78 | | - /** |
79 | | - * @param string $type |
80 | | - * @param null $val |
81 | | - */ |
82 | 78 | public function __construct( $type = self::DNull, $val = null ) { |
83 | 79 | $this->type = $type; |
84 | 80 | $this->data = $val; |
85 | 81 | } |
86 | 82 | |
87 | | - /** |
88 | | - * @param $var |
89 | | - * @return AFPData |
90 | | - * @throws AFPException |
91 | | - */ |
92 | 83 | public static function newFromPHPVar( $var ) { |
93 | 84 | if ( is_string( $var ) ) { |
94 | 85 | return new AFPData( self::DString, $var ); |
— | — | @@ -112,18 +103,10 @@ |
113 | 104 | } |
114 | 105 | } |
115 | 106 | |
116 | | - /** |
117 | | - * @return AFPData |
118 | | - */ |
119 | 107 | public function dup() { |
120 | 108 | return new AFPData( $this->type, $this->data ); |
121 | 109 | } |
122 | 110 | |
123 | | - /** |
124 | | - * @param $orig AFPData |
125 | | - * @param $target |
126 | | - * @return AFPData |
127 | | - */ |
128 | 111 | public static function castTypes( $orig, $target ) { |
129 | 112 | if ( $orig->type == $target ) { |
130 | 113 | return $orig->dup(); |
— | — | @@ -137,7 +120,7 @@ |
138 | 121 | return new AFPData( self::DBool, (bool)count( $orig->data ) ); |
139 | 122 | } |
140 | 123 | if ( $target == self::DFloat ) { |
141 | | - return new AFPData( self::DFloat, floatval( count( $orig->data ) ) ); |
| 124 | + return new AFPData( self::DFloat, doubleval( count( $orig->data ) ) ); |
142 | 125 | } |
143 | 126 | if ( $target == self::DInt ) { |
144 | 127 | return new AFPData( self::DInt, intval( count( $orig->data ) ) ); |
— | — | @@ -155,7 +138,7 @@ |
156 | 139 | return new AFPData( self::DBool, (bool)$orig->data ); |
157 | 140 | } |
158 | 141 | if ( $target == self::DFloat ) { |
159 | | - return new AFPData( self::DFloat, floatval( $orig->data ) ); |
| 142 | + return new AFPData( self::DFloat, doubleval( $orig->data ) ); |
160 | 143 | } |
161 | 144 | if ( $target == self::DInt ) { |
162 | 145 | return new AFPData( self::DInt, intval( $orig->data ) ); |
— | — | @@ -168,28 +151,14 @@ |
169 | 152 | } |
170 | 153 | } |
171 | 154 | |
172 | | - /** |
173 | | - * @param $value AFPData |
174 | | - * @return AFPData |
175 | | - */ |
176 | 155 | public static function boolInvert( $value ) { |
177 | 156 | return new AFPData( self::DBool, !$value->toBool() ); |
178 | 157 | } |
179 | 158 | |
180 | | - /** |
181 | | - * @param $base AFPData |
182 | | - * @param $exponent AFPData |
183 | | - * @return AFPData |
184 | | - */ |
185 | 159 | public static function pow( $base, $exponent ) { |
186 | 160 | return new AFPData( self::DFloat, pow( $base->toFloat(), $exponent->toFloat() ) ); |
187 | 161 | } |
188 | 162 | |
189 | | - /** |
190 | | - * @param $a AFPData |
191 | | - * @param $b AFPData |
192 | | - * @return AFPData |
193 | | - */ |
194 | 163 | public static function keywordIn( $a, $b ) { |
195 | 164 | $a = $a->toString(); |
196 | 165 | $b = $b->toString(); |
— | — | @@ -201,11 +170,6 @@ |
202 | 171 | return new AFPData( self::DBool, in_string( $a, $b ) ); |
203 | 172 | } |
204 | 173 | |
205 | | - /** |
206 | | - * @param $a AFPData |
207 | | - * @param $b AFPData |
208 | | - * @return AFPData |
209 | | - */ |
210 | 174 | public static function keywordContains( $a, $b ) { |
211 | 175 | $a = $a->toString(); |
212 | 176 | $b = $b->toString(); |
— | — | @@ -217,11 +181,6 @@ |
218 | 182 | return new AFPData( self::DBool, in_string( $b, $a ) ); |
219 | 183 | } |
220 | 184 | |
221 | | - /** |
222 | | - * @param $value |
223 | | - * @param $list |
224 | | - * @return bool |
225 | | - */ |
226 | 185 | public static function listContains( $value, $list ) { |
227 | 186 | // Should use built-in PHP function somehow |
228 | 187 | foreach ( $list->data as $item ) { |
— | — | @@ -232,21 +191,11 @@ |
233 | 192 | return false; |
234 | 193 | } |
235 | 194 | |
236 | | - /** |
237 | | - * @param $d1 AFPData |
238 | | - * @param $d2 AFPData |
239 | | - * @return bool |
240 | | - */ |
241 | 195 | public static function equals( $d1, $d2 ) { |
242 | 196 | return $d1->type != self::DList && $d2->type != self::DList && |
243 | 197 | $d1->toString() === $d2->toString(); |
244 | 198 | } |
245 | 199 | |
246 | | - /** |
247 | | - * @param $str AFPData |
248 | | - * @param $pattern AFPData |
249 | | - * @return AFPData |
250 | | - */ |
251 | 200 | public static function keywordLike( $str, $pattern ) { |
252 | 201 | $str = $str->toString(); |
253 | 202 | $pattern = $pattern->toString(); |
— | — | @@ -256,14 +205,6 @@ |
257 | 206 | return new AFPData( self::DBool, (bool)$result ); |
258 | 207 | } |
259 | 208 | |
260 | | - /** |
261 | | - * @param $str AFPData |
262 | | - * @param $regex AFPData |
263 | | - * @param $pos |
264 | | - * @param $insensitive bool |
265 | | - * @return AFPData |
266 | | - * @throws Exception |
267 | | - */ |
268 | 209 | public static function keywordRegex( $str, $regex, $pos, $insensitive = false ) { |
269 | 210 | $str = $str->toString(); |
270 | 211 | $pattern = $regex->toString(); |
— | — | @@ -287,20 +228,10 @@ |
288 | 229 | return new AFPData( self::DBool, (bool)$result ); |
289 | 230 | } |
290 | 231 | |
291 | | - /** |
292 | | - * @param $str |
293 | | - * @param $regex |
294 | | - * @param $pos |
295 | | - * @return AFPData |
296 | | - */ |
297 | 232 | public static function keywordRegexInsensitive( $str, $regex, $pos ) { |
298 | 233 | return self::keywordRegex( $str, $regex, $pos, true ); |
299 | 234 | } |
300 | 235 | |
301 | | - /** |
302 | | - * @param $data AFPData |
303 | | - * @return AFPData |
304 | | - */ |
305 | 236 | public static function unaryMinus( $data ) { |
306 | 237 | if ( $data->type == self::DInt ) { |
307 | 238 | return new AFPData( $data->type, - $data->toInt() ); |
— | — | @@ -309,13 +240,6 @@ |
310 | 241 | } |
311 | 242 | } |
312 | 243 | |
313 | | - /** |
314 | | - * @param $a AFPData |
315 | | - * @param $b AFPData |
316 | | - * @param $op string |
317 | | - * @return AFPData |
318 | | - * @throws AFPException |
319 | | - */ |
320 | 244 | public static function boolOp( $a, $b, $op ) { |
321 | 245 | $a = $a->toBool(); |
322 | 246 | $b = $b->toBool(); |
— | — | @@ -331,13 +255,6 @@ |
332 | 256 | throw new AFPException( "Invalid boolean operation: {$op}" ); // Should never happen. |
333 | 257 | } |
334 | 258 | |
335 | | - /** |
336 | | - * @param $a AFPData |
337 | | - * @param $b AFPData |
338 | | - * @param $op string |
339 | | - * @return AFPData |
340 | | - * @throws AFPException |
341 | | - */ |
342 | 259 | public static function compareOp( $a, $b, $op ) { |
343 | 260 | if ( $op == '==' || $op == '=' ) { |
344 | 261 | return new AFPData( self::DBool, self::equals( $a, $b ) ); |
— | — | @@ -368,15 +285,6 @@ |
369 | 286 | throw new AFPException( "Invalid comparison operation: {$op}" ); // Should never happen |
370 | 287 | } |
371 | 288 | |
372 | | - /** |
373 | | - * @param $a AFPData |
374 | | - * @param $b AFPData |
375 | | - * @param $op string |
376 | | - * @param $pos |
377 | | - * @return AFPData |
378 | | - * @throws AFPUserVisibleException |
379 | | - * @throws AFPException |
380 | | - */ |
381 | 289 | public static function mulRel( $a, $b, $op, $pos ) { |
382 | 290 | // Figure out the type. |
383 | 291 | if ( $a->type == self::DFloat || $b->type == self::DFloat || |
— | — | @@ -407,17 +315,12 @@ |
408 | 316 | if ( $type == self::DInt ) { |
409 | 317 | $data = intval( $data ); |
410 | 318 | } else { |
411 | | - $data = floatval( $data ); |
| 319 | + $data = doubleval( $data ); |
412 | 320 | } |
413 | 321 | |
414 | 322 | return new AFPData( $type, $data ); |
415 | 323 | } |
416 | 324 | |
417 | | - /** |
418 | | - * @param $a AFPData |
419 | | - * @param $b AFPData |
420 | | - * @return AFPData |
421 | | - */ |
422 | 325 | public static function sum( $a, $b ) { |
423 | 326 | if ( $a->type == self::DString || $b->type == self::DString ) { |
424 | 327 | return new AFPData( self::DString, $a->toString() . $b->toString() ); |
— | — | @@ -428,11 +331,6 @@ |
429 | 332 | } |
430 | 333 | } |
431 | 334 | |
432 | | - /** |
433 | | - * @param $a AFPData |
434 | | - * @param $b AFPData |
435 | | - * @return AFPData |
436 | | - */ |
437 | 335 | public static function sub( $a, $b ) { |
438 | 336 | return new AFPData( self::DFloat, $a->toFloat() - $b->toFloat() ); |
439 | 337 | } |
— | — | @@ -440,40 +338,6 @@ |
441 | 339 | /** Convert shorteners */ |
442 | 340 | |
443 | 341 | /** |
444 | | - * @throws MWException |
445 | | - * @return mixed |
446 | | - */ |
447 | | - public function toNative() { |
448 | | - switch( $this->type ) { |
449 | | - case self::DBool: |
450 | | - return $this->toBool(); |
451 | | - break; |
452 | | - case self::DString: |
453 | | - return $this->toString(); |
454 | | - break; |
455 | | - case self::DFloat: |
456 | | - return $this->toFloat(); |
457 | | - break; |
458 | | - case self::DInt: |
459 | | - return $this->toInt(); |
460 | | - break; |
461 | | - case self::DList: |
462 | | - $input = $this->toList(); |
463 | | - $output = array(); |
464 | | - foreach( $input as $item ) { |
465 | | - $output[] = $item->toNative(); |
466 | | - } |
467 | | - return $output; |
468 | | - break; |
469 | | - case self::DNull: |
470 | | - return null; |
471 | | - break; |
472 | | - default: |
473 | | - throw new MWException( "Unknown type" ); |
474 | | - } |
475 | | - } |
476 | | - |
477 | | - /** |
478 | 342 | * @return bool |
479 | 343 | */ |
480 | 344 | public function toBool() { |
— | — | @@ -537,15 +401,6 @@ |
538 | 402 | $this->pos = $pos; |
539 | 403 | } |
540 | 404 | |
541 | | - /** |
542 | | - * @param $errno |
543 | | - * @param $errstr |
544 | | - * @param $errfile |
545 | | - * @param $errline |
546 | | - * @param $context |
547 | | - * @return bool |
548 | | - * @throws AFPUserVisibleException |
549 | | - */ |
550 | 405 | function handleError( $errno, $errstr, $errfile, $errline, $context ) { |
551 | 406 | if ( error_reporting() == 0 ) { |
552 | 407 | return true; |
— | — | @@ -567,13 +422,8 @@ |
568 | 423 | } |
569 | 424 | |
570 | 425 | class AbuseFilterParser { |
571 | | - var $mParams, $mCode, $mTokens, $mPos, $mCur, $mShortCircuit, $mAllowShort, $mLen; |
| 426 | + var $mParams, $mVars, $mCode, $mTokens, $mPos, $mCur, $mShortCircuit, $mAllowShort; |
572 | 427 | |
573 | | - /** |
574 | | - * @var AbuseFilterVariableHolder |
575 | | - */ |
576 | | - var $mVars; |
577 | | - |
578 | 428 | // length,lcase,ccnorm,rmdoubles,specialratio,rmspecials,norm,count |
579 | 429 | static $mFunctions = array( |
580 | 430 | 'lcase' => 'funcLc', |
— | — | @@ -646,10 +496,6 @@ |
647 | 497 | $this->mAllowShort = true; |
648 | 498 | } |
649 | 499 | |
650 | | - /** |
651 | | - * @param $filter |
652 | | - * @return array|bool |
653 | | - */ |
654 | 500 | public function checkSyntax( $filter ) { |
655 | 501 | try { |
656 | 502 | $origAS = $this->mAllowShort; |
— | — | @@ -663,18 +509,11 @@ |
664 | 510 | return true; |
665 | 511 | } |
666 | 512 | |
667 | | - /** |
668 | | - * @param $name |
669 | | - * @param $value |
670 | | - */ |
671 | 513 | public function setVar( $name, $value ) { |
672 | 514 | $name = strtolower( $name ); |
673 | 515 | $this->mVars->setVar( $name, $value ); |
674 | 516 | } |
675 | 517 | |
676 | | - /** |
677 | | - * @param $vars |
678 | | - */ |
679 | 518 | public function setVars( $vars ) { |
680 | 519 | if ( is_array( $vars ) ) { |
681 | 520 | foreach ( $vars as $name => $var ) { |
— | — | @@ -685,9 +524,6 @@ |
686 | 525 | } |
687 | 526 | } |
688 | 527 | |
689 | | - /** |
690 | | - * @return AFPToken |
691 | | - */ |
692 | 528 | protected function move( ) { |
693 | 529 | wfProfileIn( __METHOD__ ); |
694 | 530 | list( $val, $type, $code, $offset ) = |
— | — | @@ -699,28 +535,17 @@ |
700 | 536 | return $this->mCur = $token; |
701 | 537 | } |
702 | 538 | |
703 | | - /** |
704 | | - * getState() function allows parser state to be rollbacked to several tokens back |
705 | | - * @return AFPParserState |
706 | | - */ |
| 539 | + // getState() and setState() function allows parser state to be rollbacked to several tokens back |
707 | 540 | protected function getState() { |
708 | 541 | return new AFPParserState( $this->mCur, $this->mPos ); |
709 | 542 | } |
710 | 543 | |
711 | | - /** |
712 | | - * setState() function allows parser state to be rollbacked to several tokens back |
713 | | - * @param AFPParserState $state |
714 | | - */ |
715 | 544 | protected function setState( AFPParserState $state ) { |
716 | 545 | $this->mCur = $state->token; |
717 | 546 | $this->mPos = $state->pos; |
718 | 547 | self::$lastHandledToken = $state->lastInput; |
719 | 548 | } |
720 | 549 | |
721 | | - /** |
722 | | - * @return mixed |
723 | | - * @throws AFPUserVisibleException |
724 | | - */ |
725 | 550 | protected function skipOverBraces() { |
726 | 551 | if ( !( $this->mCur->type == AFPToken::TBrace && $this->mCur->value == '(' ) || !$this->mShortCircuit ) { |
727 | 552 | return; |
— | — | @@ -743,26 +568,14 @@ |
744 | 569 | throw new AFPUserVisibleException( 'expectednotfound', $this->mCur->pos, array( ')' ) ); |
745 | 570 | } |
746 | 571 | |
747 | | - /** |
748 | | - * @param $code |
749 | | - * @return bool |
750 | | - */ |
751 | 572 | public function parse( $code ) { |
752 | 573 | return $this->intEval( $code )->toBool(); |
753 | 574 | } |
754 | 575 | |
755 | | - /** |
756 | | - * @param $filter |
757 | | - * @return string |
758 | | - */ |
759 | 576 | public function evaluateExpression( $filter ) { |
760 | 577 | return $this->intEval( $filter )->toString(); |
761 | 578 | } |
762 | 579 | |
763 | | - /** |
764 | | - * @param $code |
765 | | - * @return AFPData |
766 | | - */ |
767 | 580 | function intEval( $code ) { |
768 | 581 | // Setup, resetting |
769 | 582 | $this->mCode = $code; |
— | — | @@ -775,11 +588,6 @@ |
776 | 589 | return $result; |
777 | 590 | } |
778 | 591 | |
779 | | - /** |
780 | | - * @param $a |
781 | | - * @param $b |
782 | | - * @return int |
783 | | - */ |
784 | 592 | static function lengthCompare( $a, $b ) { |
785 | 593 | if ( strlen( $a ) == strlen( $b ) ) { |
786 | 594 | return 0; |
— | — | @@ -794,7 +602,6 @@ |
795 | 603 | * Handles unexpected characters after the expression |
796 | 604 | * |
797 | 605 | * @param $result |
798 | | - * @throws AFPUserVisibleException |
799 | 606 | */ |
800 | 607 | protected function doLevelEntry( &$result ) { |
801 | 608 | $this->doLevelSemicolon( $result ); |
— | — | @@ -821,8 +628,6 @@ |
822 | 629 | * Handles multiple expressions |
823 | 630 | * |
824 | 631 | * @param $result |
825 | | - * @throws AFPUserVisibleException |
826 | | - * @return |
827 | 632 | */ |
828 | 633 | protected function doLevelSet( &$result ) { |
829 | 634 | if ( $this->mCur->type == AFPToken::TID ) { |
— | — | @@ -886,10 +691,6 @@ |
887 | 692 | $this->doLevelConditions( $result ); |
888 | 693 | } |
889 | 694 | |
890 | | - /** |
891 | | - * @param $result |
892 | | - * @throws AFPUserVisibleException |
893 | | - */ |
894 | 695 | protected function doLevelConditions( &$result ) { |
895 | 696 | if ( $this->mCur->type == AFPToken::TKeyword && $this->mCur->value == 'if' ) { |
896 | 697 | $this->move(); |
— | — | @@ -1004,9 +805,6 @@ |
1005 | 806 | } |
1006 | 807 | } |
1007 | 808 | |
1008 | | - /** |
1009 | | - * @param $result AFPData |
1010 | | - */ |
1011 | 809 | protected function doLevelBoolOps( &$result ) { |
1012 | 810 | $this->doLevelCompares( $result ); |
1013 | 811 | $ops = array( '&', '|', '^' ); |
— | — | @@ -1045,9 +843,6 @@ |
1046 | 844 | } |
1047 | 845 | } |
1048 | 846 | |
1049 | | - /** |
1050 | | - * @param $result |
1051 | | - */ |
1052 | 847 | protected function doLevelCompares( &$result ) { |
1053 | 848 | AbuseFilter::triggerLimiter(); |
1054 | 849 | $this->doLevelSumRels( $result ); |
— | — | @@ -1063,9 +858,6 @@ |
1064 | 859 | } |
1065 | 860 | } |
1066 | 861 | |
1067 | | - /** |
1068 | | - * @param $result |
1069 | | - */ |
1070 | 862 | protected function doLevelSumRels( &$result ) { |
1071 | 863 | $this->doLevelMulRels( $result ); |
1072 | 864 | wfProfileIn( __METHOD__ ); |
— | — | @@ -1085,9 +877,6 @@ |
1086 | 878 | wfProfileOut( __METHOD__ ); |
1087 | 879 | } |
1088 | 880 | |
1089 | | - /** |
1090 | | - * @param $result |
1091 | | - */ |
1092 | 881 | protected function doLevelMulRels( &$result ) { |
1093 | 882 | $this->doLevelPow( $result ); |
1094 | 883 | wfProfileIn( __METHOD__ ); |
— | — | @@ -1102,9 +891,6 @@ |
1103 | 892 | wfProfileOut( __METHOD__ ); |
1104 | 893 | } |
1105 | 894 | |
1106 | | - /** |
1107 | | - * @param $result |
1108 | | - */ |
1109 | 895 | protected function doLevelPow( &$result ) { |
1110 | 896 | $this->doLevelBoolInvert( $result ); |
1111 | 897 | wfProfileIn( __METHOD__ ); |
— | — | @@ -1117,9 +903,6 @@ |
1118 | 904 | wfProfileOut( __METHOD__ ); |
1119 | 905 | } |
1120 | 906 | |
1121 | | - /** |
1122 | | - * @param $result |
1123 | | - */ |
1124 | 907 | protected function doLevelBoolInvert( &$result ) { |
1125 | 908 | if ( $this->mCur->type == AFPToken::TOp && $this->mCur->value == '!' ) { |
1126 | 909 | $this->move(); |
— | — | @@ -1132,9 +915,6 @@ |
1133 | 916 | } |
1134 | 917 | } |
1135 | 918 | |
1136 | | - /** |
1137 | | - * @param $result |
1138 | | - */ |
1139 | 919 | protected function doLevelSpecialWords( &$result ) { |
1140 | 920 | $this->doLevelUnarys( $result ); |
1141 | 921 | $keyword = strtolower( $this->mCur->value ); |
— | — | @@ -1166,9 +946,6 @@ |
1167 | 947 | } |
1168 | 948 | } |
1169 | 949 | |
1170 | | - /** |
1171 | | - * @param $result |
1172 | | - */ |
1173 | 950 | protected function doLevelUnarys( &$result ) { |
1174 | 951 | $op = $this->mCur->value; |
1175 | 952 | if ( $this->mCur->type == AFPToken::TOp && ( $op == "+" || $op == "-" ) ) { |
— | — | @@ -1184,10 +961,6 @@ |
1185 | 962 | } |
1186 | 963 | } |
1187 | 964 | |
1188 | | - /** |
1189 | | - * @param $result |
1190 | | - * @throws AFPUserVisibleException |
1191 | | - */ |
1192 | 965 | protected function doLevelListElements( &$result ) { |
1193 | 966 | $this->doLevelBraces( $result ); |
1194 | 967 | while ( $this->mCur->type == AFPToken::TSquareBracket && $this->mCur->value == '[' ) { |
— | — | @@ -1211,10 +984,6 @@ |
1212 | 985 | } |
1213 | 986 | } |
1214 | 987 | |
1215 | | - /** |
1216 | | - * @param $result |
1217 | | - * @throws AFPUserVisibleException |
1218 | | - */ |
1219 | 988 | protected function doLevelBraces( &$result ) { |
1220 | 989 | if ( $this->mCur->type == AFPToken::TBrace && $this->mCur->value == '(' ) { |
1221 | 990 | if ( $this->mShortCircuit ) { |
— | — | @@ -1234,10 +1003,6 @@ |
1235 | 1004 | } |
1236 | 1005 | } |
1237 | 1006 | |
1238 | | - /** |
1239 | | - * @param $result |
1240 | | - * @throws AFPUserVisibleException |
1241 | | - */ |
1242 | 1007 | protected function doLevelFunction( &$result ) { |
1243 | 1008 | if ( $this->mCur->type == AFPToken::TID && isset( self::$mFunctions[$this->mCur->value] ) ) { |
1244 | 1009 | wfProfileIn( __METHOD__ ); |
— | — | @@ -1306,11 +1071,6 @@ |
1307 | 1072 | } |
1308 | 1073 | } |
1309 | 1074 | |
1310 | | - /** |
1311 | | - * @param $result |
1312 | | - * @throws AFPUserVisibleException |
1313 | | - * @return AFPData |
1314 | | - */ |
1315 | 1075 | protected function doLevelAtom( &$result ) { |
1316 | 1076 | wfProfileIn( __METHOD__ ); |
1317 | 1077 | $tok = $this->mCur->value; |
— | — | @@ -1393,11 +1153,6 @@ |
1394 | 1154 | |
1395 | 1155 | /* End of levels */ |
1396 | 1156 | |
1397 | | - /** |
1398 | | - * @param $var |
1399 | | - * @return AFPData |
1400 | | - * @throws AFPUserVisibleException |
1401 | | - */ |
1402 | 1157 | protected function getVarValue( $var ) { |
1403 | 1158 | wfProfileIn( __METHOD__ ); |
1404 | 1159 | $var = strtolower( $var ); |
— | — | @@ -1418,11 +1173,6 @@ |
1419 | 1174 | } |
1420 | 1175 | } |
1421 | 1176 | |
1422 | | - /** |
1423 | | - * @param $name |
1424 | | - * @param $value |
1425 | | - * @throws AFPUserVisibleException |
1426 | | - */ |
1427 | 1177 | protected function setUserVariable( $name, $value ) { |
1428 | 1178 | $builderValues = AbuseFilter::getBuilderValues(); |
1429 | 1179 | if ( array_key_exists( $name, $builderValues['vars'] ) ) { |
— | — | @@ -1431,13 +1181,6 @@ |
1432 | 1182 | $this->mVars->setVar( $name, $value ); |
1433 | 1183 | } |
1434 | 1184 | |
1435 | | - /** |
1436 | | - * @param $code |
1437 | | - * @param $offset |
1438 | | - * @return array |
1439 | | - * @throws AFPException |
1440 | | - * @throws AFPUserVisibleException |
1441 | | - */ |
1442 | 1185 | static function nextToken( $code, $offset ) { |
1443 | 1186 | $tok = ''; |
1444 | 1187 | |
— | — | @@ -1618,7 +1361,7 @@ |
1619 | 1362 | |
1620 | 1363 | return array( |
1621 | 1364 | $float |
1622 | | - ? floatval( $num ) |
| 1365 | + ? doubleval( $num ) |
1623 | 1366 | : intval( $num ), |
1624 | 1367 | $float |
1625 | 1368 | ? AFPToken::TFloat |
— | — | @@ -1650,12 +1393,6 @@ |
1651 | 1394 | } |
1652 | 1395 | |
1653 | 1396 | // Built-in functions |
1654 | | - |
1655 | | - /** |
1656 | | - * @param $args |
1657 | | - * @return AFPData |
1658 | | - * @throws AFPUserVisibleException |
1659 | | - */ |
1660 | 1397 | protected function funcLc( $args ) { |
1661 | 1398 | global $wgContLang; |
1662 | 1399 | if ( count( $args ) < 1 ) { |
— | — | @@ -1669,11 +1406,6 @@ |
1670 | 1407 | return new AFPData( AFPData::DString, $wgContLang->lc( $s ) ); |
1671 | 1408 | } |
1672 | 1409 | |
1673 | | - /** |
1674 | | - * @param $args |
1675 | | - * @return AFPData |
1676 | | - * @throws AFPUserVisibleException |
1677 | | - */ |
1678 | 1410 | protected function funcLen( $args ) { |
1679 | 1411 | if ( count( $args ) < 1 ) { |
1680 | 1412 | throw new AFPUserVisibleException( |
— | — | @@ -1686,11 +1418,6 @@ |
1687 | 1419 | return new AFPData( AFPData::DInt, mb_strlen( $s, 'utf-8' ) ); |
1688 | 1420 | } |
1689 | 1421 | |
1690 | | - /** |
1691 | | - * @param $args |
1692 | | - * @return AFPData |
1693 | | - * @throws AFPUserVisibleException |
1694 | | - */ |
1695 | 1422 | protected function funcSimpleNorm( $args ) { |
1696 | 1423 | if ( count( $args ) < 1 ) { |
1697 | 1424 | throw new AFPUserVisibleException( |
— | — | @@ -1706,11 +1433,6 @@ |
1707 | 1434 | return new AFPData( AFPData::DString, $s ); |
1708 | 1435 | } |
1709 | 1436 | |
1710 | | - /** |
1711 | | - * @param $args |
1712 | | - * @return AFPData |
1713 | | - * @throws AFPUserVisibleException |
1714 | | - */ |
1715 | 1437 | protected function funcSpecialRatio( $args ) { |
1716 | 1438 | if ( count( $args ) < 1 ) { |
1717 | 1439 | throw new AFPUserVisibleException( |
— | — | @@ -1732,11 +1454,6 @@ |
1733 | 1455 | return new AFPData( AFPData::DFloat, $val ); |
1734 | 1456 | } |
1735 | 1457 | |
1736 | | - /** |
1737 | | - * @param $args |
1738 | | - * @return AFPData |
1739 | | - * @throws AFPUserVisibleException |
1740 | | - */ |
1741 | 1458 | protected function funcCount( $args ) { |
1742 | 1459 | if ( count( $args ) < 1 ) { |
1743 | 1460 | throw new AFPUserVisibleException( |
— | — | @@ -1767,12 +1484,6 @@ |
1768 | 1485 | return new AFPData( AFPData::DInt, $count ); |
1769 | 1486 | } |
1770 | 1487 | |
1771 | | - /** |
1772 | | - * @param $args |
1773 | | - * @return AFPData |
1774 | | - * @throws AFPUserVisibleException |
1775 | | - * @throws Exception |
1776 | | - */ |
1777 | 1488 | protected function funcRCount( $args ) { |
1778 | 1489 | if ( count( $args ) < 1 ) { |
1779 | 1490 | throw new AFPUserVisibleException( |
— | — | @@ -1808,11 +1519,6 @@ |
1809 | 1520 | return new AFPData( AFPData::DInt, $count ); |
1810 | 1521 | } |
1811 | 1522 | |
1812 | | - /** |
1813 | | - * @param $args |
1814 | | - * @return AFPData |
1815 | | - * @throws AFPUserVisibleException |
1816 | | - */ |
1817 | 1523 | protected function funcIPInRange( $args ) { |
1818 | 1524 | if ( count( $args ) < 2 ) { |
1819 | 1525 | throw new AFPUserVisibleException( |
— | — | @@ -1830,11 +1536,6 @@ |
1831 | 1537 | return new AFPData( AFPData::DBool, $result ); |
1832 | 1538 | } |
1833 | 1539 | |
1834 | | - /** |
1835 | | - * @param $args |
1836 | | - * @return AFPData |
1837 | | - * @throws AFPUserVisibleException |
1838 | | - */ |
1839 | 1540 | protected function funcCCNorm( $args ) { |
1840 | 1541 | if ( count( $args ) < 1 ) { |
1841 | 1542 | throw new AFPUserVisibleException( |
— | — | @@ -1851,11 +1552,6 @@ |
1852 | 1553 | return new AFPData( AFPData::DString, $s ); |
1853 | 1554 | } |
1854 | 1555 | |
1855 | | - /** |
1856 | | - * @param $args array |
1857 | | - * @return AFPData |
1858 | | - * @throws AFPUserVisibleException |
1859 | | - */ |
1860 | 1556 | protected function funcContainsAny( $args ) { |
1861 | 1557 | if ( count( $args ) < 2 ) { |
1862 | 1558 | throw new AFPUserVisibleException( |
— | — | @@ -1892,10 +1588,6 @@ |
1893 | 1589 | return new AFPData( AFPData::DBool, $ok ); |
1894 | 1590 | } |
1895 | 1591 | |
1896 | | - /** |
1897 | | - * @param $s |
1898 | | - * @return mixed |
1899 | | - */ |
1900 | 1592 | protected function ccnorm( $s ) { |
1901 | 1593 | static $equivset = null; |
1902 | 1594 | static $replacementArray = null; |
— | — | @@ -1909,35 +1601,20 @@ |
1910 | 1602 | return $replacementArray->replace( $s ); |
1911 | 1603 | } |
1912 | 1604 | |
1913 | | - /** |
1914 | | - * @param $s string |
1915 | | - * @return array|string |
1916 | | - */ |
1917 | 1605 | protected function rmspecials( $s ) { |
1918 | | - return preg_replace( '/[^\p{L}\p{N}]/u', '', $s ); |
| 1606 | + $s = preg_replace( '/[^\p{L}\p{N}]/u', '', $s ); |
| 1607 | + |
| 1608 | + return $s; |
1919 | 1609 | } |
1920 | 1610 | |
1921 | | - /** |
1922 | | - * @param $s string |
1923 | | - * @return array|string |
1924 | | - */ |
1925 | 1611 | protected function rmdoubles( $s ) { |
1926 | 1612 | return preg_replace( '/(.)\1+/us', '\1', $s ); |
1927 | 1613 | } |
1928 | 1614 | |
1929 | | - /** |
1930 | | - * @param $s string |
1931 | | - * @return array|string |
1932 | | - */ |
1933 | 1615 | protected function rmwhitespace( $s ) { |
1934 | 1616 | return preg_replace( '/\s+/u', '', $s ); |
1935 | 1617 | } |
1936 | 1618 | |
1937 | | - /** |
1938 | | - * @param $args array |
1939 | | - * @return AFPData |
1940 | | - * @throws AFPUserVisibleException |
1941 | | - */ |
1942 | 1619 | protected function funcRMSpecials( $args ) { |
1943 | 1620 | if ( count( $args ) < 1 ) { |
1944 | 1621 | throw new AFPUserVisibleException( |
— | — | @@ -1953,11 +1630,6 @@ |
1954 | 1631 | return new AFPData( AFPData::DString, $s ); |
1955 | 1632 | } |
1956 | 1633 | |
1957 | | - /** |
1958 | | - * @param $args array |
1959 | | - * @return AFPData |
1960 | | - * @throws AFPUserVisibleException |
1961 | | - */ |
1962 | 1634 | protected function funcRMWhitespace( $args ) { |
1963 | 1635 | if ( count( $args ) < 1 ) { |
1964 | 1636 | throw new AFPUserVisibleException( |
— | — | @@ -1973,11 +1645,6 @@ |
1974 | 1646 | return new AFPData( AFPData::DString, $s ); |
1975 | 1647 | } |
1976 | 1648 | |
1977 | | - /** |
1978 | | - * @param $args array |
1979 | | - * @return AFPData |
1980 | | - * @throws AFPUserVisibleException |
1981 | | - */ |
1982 | 1649 | protected function funcRMDoubles( $args ) { |
1983 | 1650 | if ( count( $args ) < 1 ) { |
1984 | 1651 | throw new AFPUserVisibleException( |
— | — | @@ -1993,11 +1660,6 @@ |
1994 | 1661 | return new AFPData( AFPData::DString, $s ); |
1995 | 1662 | } |
1996 | 1663 | |
1997 | | - /** |
1998 | | - * @param $args array |
1999 | | - * @return AFPData |
2000 | | - * @throws AFPUserVisibleException |
2001 | | - */ |
2002 | 1664 | protected function funcNorm( $args ) { |
2003 | 1665 | if ( count( $args ) < 1 ) { |
2004 | 1666 | throw new AFPUserVisibleException( |
— | — | @@ -2016,11 +1678,6 @@ |
2017 | 1679 | return new AFPData( AFPData::DString, $s ); |
2018 | 1680 | } |
2019 | 1681 | |
2020 | | - /** |
2021 | | - * @param $args array |
2022 | | - * @return AFPData |
2023 | | - * @throws AFPUserVisibleException |
2024 | | - */ |
2025 | 1682 | protected function funcSubstr( $args ) { |
2026 | 1683 | if ( count( $args ) < 2 ) { |
2027 | 1684 | throw new AFPUserVisibleException( |
— | — | @@ -2044,11 +1701,6 @@ |
2045 | 1702 | return new AFPData( AFPData::DString, $result ); |
2046 | 1703 | } |
2047 | 1704 | |
2048 | | - /** |
2049 | | - * @param $args array |
2050 | | - * @return AFPData |
2051 | | - * @throws AFPUserVisibleException |
2052 | | - */ |
2053 | 1705 | protected function funcStrPos( $args ) { |
2054 | 1706 | if ( count( $args ) < 2 ) { |
2055 | 1707 | throw new AFPUserVisibleException( |
— | — | @@ -2075,11 +1727,6 @@ |
2076 | 1728 | return new AFPData( AFPData::DInt, $result ); |
2077 | 1729 | } |
2078 | 1730 | |
2079 | | - /** |
2080 | | - * @param $args array |
2081 | | - * @return AFPData |
2082 | | - * @throws AFPUserVisibleException |
2083 | | - */ |
2084 | 1731 | protected function funcStrReplace( $args ) { |
2085 | 1732 | if ( count( $args ) < 3 ) { |
2086 | 1733 | throw new AFPUserVisibleException( |
— | — | @@ -2096,11 +1743,6 @@ |
2097 | 1744 | return new AFPData( AFPData::DString, str_replace( $search, $replace, $subject ) ); |
2098 | 1745 | } |
2099 | 1746 | |
2100 | | - /** |
2101 | | - * @param $args array |
2102 | | - * @return AFPData |
2103 | | - * @throws AFPUserVisibleException |
2104 | | - */ |
2105 | 1747 | protected function funcStrRegexEscape( $args ) { |
2106 | 1748 | if ( count( $args ) < 1 ) { |
2107 | 1749 | throw new AFPUserVisibleException( 'notenoughargs', $this->mCur->pos, |
— | — | @@ -2113,11 +1755,6 @@ |
2114 | 1756 | return new AFPData( AFPData::DString, preg_quote( $string ) ); |
2115 | 1757 | } |
2116 | 1758 | |
2117 | | - /** |
2118 | | - * @param $args array |
2119 | | - * @return mixed |
2120 | | - * @throws AFPUserVisibleException |
2121 | | - */ |
2122 | 1759 | protected function funcSetVar( $args ) { |
2123 | 1760 | if ( count( $args ) < 2 ) { |
2124 | 1761 | throw new AFPUserVisibleException( |
— | — | @@ -2135,11 +1772,6 @@ |
2136 | 1773 | return $value; |
2137 | 1774 | } |
2138 | 1775 | |
2139 | | - /** |
2140 | | - * @param $args array |
2141 | | - * @return AFPData |
2142 | | - * @throws AFPUserVisibleException |
2143 | | - */ |
2144 | 1776 | protected function castString( $args ) { |
2145 | 1777 | if ( count( $args ) < 1 ) { |
2146 | 1778 | throw new AFPUserVisibleException( 'noparams', $this->mCur->pos, array( __METHOD__ ) ); |
— | — | @@ -2149,11 +1781,6 @@ |
2150 | 1782 | return AFPData::castTypes( $val, AFPData::DString ); |
2151 | 1783 | } |
2152 | 1784 | |
2153 | | - /** |
2154 | | - * @param $args array |
2155 | | - * @return AFPData |
2156 | | - * @throws AFPUserVisibleException |
2157 | | - */ |
2158 | 1785 | protected function castInt( $args ) { |
2159 | 1786 | if ( count( $args ) < 1 ) { |
2160 | 1787 | throw new AFPUserVisibleException( 'noparams', $this->mCur->pos, array( __METHOD__ ) ); |
— | — | @@ -2163,11 +1790,6 @@ |
2164 | 1791 | return AFPData::castTypes( $val, AFPData::DInt ); |
2165 | 1792 | } |
2166 | 1793 | |
2167 | | - /** |
2168 | | - * @param $args array |
2169 | | - * @return AFPData |
2170 | | - * @throws AFPUserVisibleException |
2171 | | - */ |
2172 | 1794 | protected function castFloat( $args ) { |
2173 | 1795 | if ( count( $args ) < 1 ) { |
2174 | 1796 | throw new AFPUserVisibleException( 'noparams', $this->mCur->pos, array( __METHOD__ ) ); |
— | — | @@ -2177,11 +1799,6 @@ |
2178 | 1800 | return AFPData::castTypes( $val, AFPData::DFloat ); |
2179 | 1801 | } |
2180 | 1802 | |
2181 | | - /** |
2182 | | - * @param $args array |
2183 | | - * @return AFPData |
2184 | | - * @throws AFPUserVisibleException |
2185 | | - */ |
2186 | 1803 | protected function castBool( $args ) { |
2187 | 1804 | if ( count( $args ) < 1 ) { |
2188 | 1805 | throw new AFPUserVisibleException( 'noparams', $this->mCur->pos, array( __METHOD__ ) ); |
Index: trunk/extensions/AbuseFilter/AbuseFilter.php |
— | — | @@ -78,7 +78,6 @@ |
79 | 79 | $wgHooks['ContributionsToolLinks'][] = 'AbuseFilterHooks::onContributionsToolLinks'; |
80 | 80 | $wgHooks['UploadVerification'][] = 'AbuseFilterHooks::onUploadVerification'; |
81 | 81 | $wgHooks['MakeGlobalVariablesScript'][] = 'AbuseFilterHooks::onMakeGlobalVariablesScript'; |
82 | | -$wgHooks['ArticleSaveComplete'][] = 'AbuseFilterHooks::onArticleSaveComplete'; |
83 | 82 | |
84 | 83 | $wgAvailableRights[] = 'abusefilter-modify'; |
85 | 84 | $wgAvailableRights[] = 'abusefilter-log-detail'; |
Index: trunk/extensions/AbuseFilter/db_patches/patch-afl_action_id.sql |
— | — | @@ -1,10 +0,0 @@ |
2 | | -ALTER TABLE /*_*/abuse_filter_log |
3 | | - ADD COLUMN afl_rev_id int unsigned; |
4 | | -ALTER TABLE /*_*/abuse_filter_log |
5 | | - ADD KEY (afl_rev_id); |
6 | | - |
7 | | -ALTER TABLE /*_*/abuse_filter_log |
8 | | - ADD COLUMN afl_log_id int unsigned; |
9 | | -ALTER TABLE /*_*/abuse_filter_log |
10 | | - ADD KEY (afl_log_id); |
\ No newline at end of file |
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewDiff.php |
— | — | @@ -94,7 +94,7 @@ |
95 | 95 | 'history/' . $this->mFilter . '/item/' . $other['meta']['history_id'] ); |
96 | 96 | global $wgOut; |
97 | 97 | $wgOut->redirect( $t->getFullURL() ); |
98 | | - return null; |
| 98 | + return; |
99 | 99 | } |
100 | 100 | |
101 | 101 | } elseif ( $spec == 'next' && !in_array( $otherSpec, $dependentSpecs ) ) { |
— | — | @@ -117,7 +117,7 @@ |
118 | 118 | 'history/' . $this->mFilter . '/item/' . $other['meta']['history_id'] ); |
119 | 119 | global $wgOut; |
120 | 120 | $wgOut->redirect( $t->getFullURL() ); |
121 | | - return null; |
| 121 | + return; |
122 | 122 | } |
123 | 123 | } |
124 | 124 | |
— | — | @@ -148,11 +148,6 @@ |
149 | 149 | ); |
150 | 150 | } |
151 | 151 | |
152 | | - /** |
153 | | - * @param $timestamp |
154 | | - * @param $history_id |
155 | | - * @return string |
156 | | - */ |
157 | 152 | function formatVersionLink( $timestamp, $history_id ) { |
158 | 153 | $filter = $this->mFilter; |
159 | 154 | $text = $this->getLanguage()->timeanddate( $timestamp, true ); |
— | — | @@ -163,9 +158,6 @@ |
164 | 159 | return $link; |
165 | 160 | } |
166 | 161 | |
167 | | - /** |
168 | | - * @return string |
169 | | - */ |
170 | 162 | function formatDiff() { |
171 | 163 | $oldVersion = $this->mOldVersion; |
172 | 164 | $newVersion = $this->mNewVersion; |
— | — | @@ -257,10 +249,6 @@ |
258 | 250 | return $html; |
259 | 251 | } |
260 | 252 | |
261 | | - /** |
262 | | - * @param $actions |
263 | | - * @return array |
264 | | - */ |
265 | 253 | function stringifyActions( $actions ) { |
266 | 254 | $lines = array(); |
267 | 255 | |
— | — | @@ -276,10 +264,6 @@ |
277 | 265 | return $lines; |
278 | 266 | } |
279 | 267 | |
280 | | - /** |
281 | | - * @param $msg |
282 | | - * @return String |
283 | | - */ |
284 | 268 | function getHeaderRow( $msg ) { |
285 | 269 | $html = wfMsgExt( $msg, 'parseinline' ); |
286 | 270 | $html = Xml::tags( 'th', array( 'colspan' => 3 ), $html ); |
— | — | @@ -288,13 +272,6 @@ |
289 | 273 | return $html; |
290 | 274 | } |
291 | 275 | |
292 | | - /** |
293 | | - * @param $msg |
294 | | - * @param $old |
295 | | - * @param $new |
296 | | - * @param string $format |
297 | | - * @return string |
298 | | - */ |
299 | 276 | function getSimpleRow( $msg, $old, $new, $format = 'wikitext' ) { |
300 | 277 | $row = ''; |
301 | 278 | |
— | — | @@ -323,12 +300,6 @@ |
324 | 301 | return Xml::tags( 'tr', null, $row ) . "\n"; |
325 | 302 | } |
326 | 303 | |
327 | | - /** |
328 | | - * @param $msg |
329 | | - * @param $old |
330 | | - * @param $new |
331 | | - * @return string |
332 | | - */ |
333 | 304 | function getMultiLineRow( $msg, $old, $new ) { |
334 | 305 | if ( !is_array( $old ) ) { |
335 | 306 | $old = explode( "\n", preg_replace( "/\\\r\\\n?/", "\n", $old ) ); |
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterView.php |
— | — | @@ -53,12 +53,6 @@ |
54 | 54 | } |
55 | 55 | |
56 | 56 | class AbuseFilterChangesList extends OldChangesList { |
57 | | - |
58 | | - /** |
59 | | - * @param $s |
60 | | - * @param $rc |
61 | | - * @param $classes array |
62 | | - */ |
63 | 57 | public function insertExtra( &$s, &$rc, &$classes ) { |
64 | 58 | $examineParams = empty( $rc->examineParams ) ? array() : $rc->examineParams; |
65 | 59 | |
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewHistory.php |
— | — | @@ -118,6 +118,7 @@ |
119 | 119 | } |
120 | 120 | |
121 | 121 | function formatValue( $name, $value ) { |
| 122 | + $sk = $this->getSkin(); |
122 | 123 | $lang = $this->getLanguage(); |
123 | 124 | |
124 | 125 | $row = $this->mCurrentRow; |
— | — | @@ -129,12 +130,12 @@ |
130 | 131 | case 'afh_timestamp': |
131 | 132 | $title = SpecialPage::getTitleFor( 'AbuseFilter', |
132 | 133 | 'history/' . $row->afh_filter . '/item/' . $row->afh_id ); |
133 | | - $formatted = Linker::link( $title, $lang->timeanddate( $row->afh_timestamp, true ) ); |
| 134 | + $formatted = $sk->link( $title, $lang->timeanddate( $row->afh_timestamp, true ) ); |
134 | 135 | break; |
135 | 136 | case 'afh_user_text': |
136 | 137 | $formatted = |
137 | | - Linker::userLink( $row->afh_user, $row->afh_user_text ) . ' ' . |
138 | | - Linker::userToolLinks( $row->afh_user, $row->afh_user_text ); |
| 138 | + $sk->userLink( $row->afh_user, $row->afh_user_text ) . ' ' . |
| 139 | + $sk->userToolLinks( $row->afh_user, $row->afh_user_text ); |
139 | 140 | break; |
140 | 141 | case 'afh_public_comments': |
141 | 142 | $formatted = $this->getOutput()->parse( $value ); |
— | — | @@ -157,12 +158,12 @@ |
158 | 159 | break; |
159 | 160 | case 'afh_filter': |
160 | 161 | $title = $this->mPage->getTitle( strval( $value ) ); |
161 | | - $formatted = Linker::link( $title, $value ); |
| 162 | + $formatted = $sk->link( $title, $value ); |
162 | 163 | break; |
163 | 164 | case 'afh_id': |
164 | 165 | $title = $this->mPage->getTitle( |
165 | 166 | 'history/' . $row->afh_filter . "/diff/prev/$value" ); |
166 | | - $formatted = Linker::link( $title, wfMsgExt( 'abusefilter-history-diff', 'parseinline' ) ); |
| 167 | + $formatted = $sk->link( $title, wfMsgExt( 'abusefilter-history-diff', 'parseinline' ) ); |
167 | 168 | break; |
168 | 169 | default: |
169 | 170 | $formatted = "Unable to format $name"; |
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewEdit.php |
— | — | @@ -240,12 +240,6 @@ |
241 | 241 | } |
242 | 242 | } |
243 | 243 | |
244 | | - /** |
245 | | - * @param $error |
246 | | - * @param $filter |
247 | | - * @param $history_id null |
248 | | - * @return bool|String |
249 | | - */ |
250 | 244 | function buildFilterEditor( $error, $filter, $history_id = null ) { |
251 | 245 | if ( $filter === null ) { |
252 | 246 | return false; |
— | — | @@ -255,13 +249,14 @@ |
256 | 250 | $out = $this->getOutput(); |
257 | 251 | $lang = $this->getLanguage(); |
258 | 252 | $user = $this->getUser(); |
| 253 | + $sk = $this->getSkin(); |
259 | 254 | |
260 | 255 | // Load from request OR database. |
261 | 256 | list( $row, $actions ) = $this->loadRequest( $filter, $history_id ); |
262 | 257 | |
263 | 258 | if ( !$row ) { |
264 | 259 | $out->addWikiMsg( 'abusefilter-edit-badfilter' ); |
265 | | - $out->addHTML( Linker::link( $this->getTitle(), wfMsg( 'abusefilter-return' ) ) ); |
| 260 | + $out->addHTML( $sk->link( $this->getTitle(), wfMsg( 'abusefilter-return' ) ) ); |
266 | 261 | return; |
267 | 262 | } |
268 | 263 | |
— | — | @@ -306,7 +301,7 @@ |
307 | 302 | $count_display = wfMsgExt( 'abusefilter-hitcount', array( 'parseinline' ), |
308 | 303 | $lang->formatNum( $count ) |
309 | 304 | ); |
310 | | - $hitCount = Linker::makeKnownLinkObj( |
| 305 | + $hitCount = $sk->makeKnownLinkObj( |
311 | 306 | SpecialPage::getTitleFor( 'AbuseLog' ), |
312 | 307 | $count_display, |
313 | 308 | 'wpSearchFilter=' . $row->af_id |
— | — | @@ -392,7 +387,7 @@ |
393 | 388 | if ( $filter != 'new' && $user->isAllowed( 'abusefilter-revert' ) ) { |
394 | 389 | $tools .= Xml::tags( |
395 | 390 | 'p', null, |
396 | | - Linker::link( |
| 391 | + $sk->link( |
397 | 392 | $this->getTitle( 'revert/' . $filter ), |
398 | 393 | wfMsg( 'abusefilter-edit-revert' ) |
399 | 394 | ) |
— | — | @@ -403,15 +398,15 @@ |
404 | 399 | // Test link |
405 | 400 | $tools .= Xml::tags( |
406 | 401 | 'p', null, |
407 | | - Linker::link( |
| 402 | + $sk->link( |
408 | 403 | $this->getTitle( "test/$filter" ), |
409 | 404 | wfMsgExt( 'abusefilter-edit-test-link', 'parseinline' ) |
410 | 405 | ) |
411 | 406 | ); |
412 | 407 | // Last modification details |
413 | 408 | $userLink = |
414 | | - Linker::userLink( $row->af_user, $row->af_user_text ) . |
415 | | - Linker::userToolLinks( $row->af_user, $row->af_user_text ); |
| 409 | + $sk->userLink( $row->af_user, $row->af_user_text ) . |
| 410 | + $sk->userToolLinks( $row->af_user, $row->af_user_text ); |
416 | 411 | $userName = $row->af_user_text; |
417 | 412 | $fields['abusefilter-edit-lastmod'] = |
418 | 413 | wfMsgExt( |
— | — | @@ -426,7 +421,7 @@ |
427 | 422 | ); |
428 | 423 | $history_display = wfMsgExt( 'abusefilter-edit-viewhistory', array( 'parseinline' ) ); |
429 | 424 | $fields['abusefilter-edit-history'] = |
430 | | - Linker::makeKnownLinkObj( $this->getTitle( 'history/' . $filter ), $history_display ); |
| 425 | + $sk->makeKnownLinkObj( $this->getTitle( 'history/' . $filter ), $history_display ); |
431 | 426 | } |
432 | 427 | |
433 | 428 | // Add export |
— | — | @@ -468,11 +463,6 @@ |
469 | 464 | return $output; |
470 | 465 | } |
471 | 466 | |
472 | | - /** |
473 | | - * @param $row |
474 | | - * @param $actions |
475 | | - * @return string |
476 | | - */ |
477 | 467 | function buildConsequenceEditor( $row, $actions ) { |
478 | 468 | global $wgAbuseFilterAvailableActions; |
479 | 469 | |
— | — | @@ -491,12 +481,6 @@ |
492 | 482 | return $output; |
493 | 483 | } |
494 | 484 | |
495 | | - /** |
496 | | - * @param $action |
497 | | - * @param $set |
498 | | - * @param $parameters |
499 | | - * @return string |
500 | | - */ |
501 | 485 | function buildConsequenceSelector( $action, $set, $parameters ) { |
502 | 486 | global $wgAbuseFilterAvailableActions; |
503 | 487 | |
— | — | @@ -657,10 +641,6 @@ |
658 | 642 | } |
659 | 643 | } |
660 | 644 | |
661 | | - /** |
662 | | - * @param $warnMsg |
663 | | - * @return string |
664 | | - */ |
665 | 645 | function getExistingSelector( $warnMsg ) { |
666 | 646 | $existingSelector = new XmlSelect( |
667 | 647 | 'wpFilterWarnMessage', |
— | — | @@ -698,10 +678,6 @@ |
699 | 679 | return $existingSelector->getHTML(); |
700 | 680 | } |
701 | 681 | |
702 | | - /** |
703 | | - * @param $id |
704 | | - * @return array|null |
705 | | - */ |
706 | 682 | function loadFilterData( $id ) { |
707 | 683 | if ( $id == 'new' ) { |
708 | 684 | $obj = new stdClass; |
— | — | @@ -761,11 +737,6 @@ |
762 | 738 | return array( $row, $actions ); |
763 | 739 | } |
764 | 740 | |
765 | | - /** |
766 | | - * @param $filter |
767 | | - * @param null $history_id |
768 | | - * @return array|null |
769 | | - */ |
770 | 741 | function loadRequest( $filter, $history_id = null ) { |
771 | 742 | static $row = null; |
772 | 743 | static $actions = null; |
— | — | @@ -866,10 +837,6 @@ |
867 | 838 | return array( $row, $actions ); |
868 | 839 | } |
869 | 840 | |
870 | | - /** |
871 | | - * @param $id |
872 | | - * @return array |
873 | | - */ |
874 | 841 | function loadHistoryItem( $id ) { |
875 | 842 | $dbr = wfGetDB( DB_SLAVE ); |
876 | 843 | |
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewRevert.php |
— | — | @@ -9,6 +9,7 @@ |
10 | 10 | |
11 | 11 | $user = $this->getUser(); |
12 | 12 | $out = $this->getOutput(); |
| 13 | + $sk = $this->getSkin(); |
13 | 14 | |
14 | 15 | if ( !$user->isAllowed( 'abusefilter-revert' ) ) { |
15 | 16 | throw new PermissionsError( 'abusefilter-revert' ); |
— | — | @@ -66,11 +67,11 @@ |
67 | 68 | array( 'parseinline', 'replaceafter' ), |
68 | 69 | array( |
69 | 70 | $lang->timeanddate( $result['timestamp'], true ), |
70 | | - Linker::userLink( $result['userid'], $result['user'] ), |
| 71 | + $sk->userLink( $result['userid'], $result['user'] ), |
71 | 72 | $result['action'], |
72 | | - Linker::link( $result['title'] ), |
| 73 | + $sk->link( $result['title'] ), |
73 | 74 | $lang->commaList( $displayActions ), |
74 | | - Linker::link( |
| 75 | + $sk->link( |
75 | 76 | SpecialPage::getTitleFor( 'AbuseLog' ), |
76 | 77 | wfMsgNoTrans( 'abusefilter-log-detailslink' ), |
77 | 78 | array(), |
— | — | @@ -89,7 +90,7 @@ |
90 | 91 | Html::hidden( 'title', $this->getTitle( "revert/$filter" )->getPrefixedText() ) . |
91 | 92 | Html::hidden( 'wpPeriodStart', $this->origPeriodStart ) . |
92 | 93 | Html::hidden( 'wpPeriodEnd', $this->origPeriodEnd ) . |
93 | | - Xml::inputLabel( |
| 94 | + Html::inputLabel( |
94 | 95 | wfMsg( 'abusefilter-revert-reasonfield' ), |
95 | 96 | 'wpReason', 'wpReason', 45 |
96 | 97 | ) . |
Index: trunk/extensions/AbuseFilter/AbuseFilter.class.php |
— | — | @@ -120,10 +120,6 @@ |
121 | 121 | ); |
122 | 122 | public static $editboxName = null; |
123 | 123 | |
124 | | - /** |
125 | | - * @param $context IContextSource |
126 | | - * @param $pageType |
127 | | - */ |
128 | 124 | public static function addNavigationLinks( IContextSource $context, $pageType ) { |
129 | 125 | $linkDefs = array( |
130 | 126 | 'home' => 'Special:AbuseFilter', |
— | — | @@ -163,7 +159,7 @@ |
164 | 160 | if ( $name == $pageType ) { |
165 | 161 | $links[] = Xml::tags( 'strong', null, $msg ); |
166 | 162 | } else { |
167 | | - $links[] = Linker::link( $title, $msg ); |
| 163 | + $links[] = $context->getSkin()->link( $title, $msg ); |
168 | 164 | } |
169 | 165 | } |
170 | 166 | |
— | — | @@ -196,9 +192,6 @@ |
197 | 193 | return $vars; |
198 | 194 | } |
199 | 195 | |
200 | | - /** |
201 | | - * @return array |
202 | | - */ |
203 | 196 | public static function getBuilderValues() { |
204 | 197 | static $realValues = null; |
205 | 198 | |
— | — | @@ -212,10 +205,6 @@ |
213 | 206 | return $realValues; |
214 | 207 | } |
215 | 208 | |
216 | | - /** |
217 | | - * @param $filter |
218 | | - * @return bool |
219 | | - */ |
220 | 209 | public static function filterHidden( $filter ) { |
221 | 210 | $globalIndex = self::decodeGlobalName( $filter ); |
222 | 211 | if ( $globalIndex ) { |
— | — | @@ -237,10 +226,6 @@ |
238 | 227 | return $hidden ? true : false; |
239 | 228 | } |
240 | 229 | |
241 | | - /** |
242 | | - * @param $val int |
243 | | - * @throws MWException |
244 | | - */ |
245 | 230 | public static function triggerLimiter( $val = 1 ) { |
246 | 231 | self::$condCount += $val; |
247 | 232 | |
— | — | @@ -257,8 +242,9 @@ |
258 | 243 | } |
259 | 244 | |
260 | 245 | /** |
261 | | - * @param $title Title |
262 | | - * @param $prefix |
| 246 | + * @static |
| 247 | + * @param $title Title |
| 248 | + * @param $prefix |
263 | 249 | * @return AbuseFilterVariableHolder |
264 | 250 | */ |
265 | 251 | public static function generateTitleVars( $title, $prefix ) { |
— | — | @@ -294,10 +280,6 @@ |
295 | 281 | return $vars; |
296 | 282 | } |
297 | 283 | |
298 | | - /** |
299 | | - * @param $filter |
300 | | - * @return mixed |
301 | | - */ |
302 | 284 | public static function checkSyntax( $filter ) { |
303 | 285 | global $wgAbuseFilterParserClass; |
304 | 286 | |
— | — | @@ -306,11 +288,6 @@ |
307 | 289 | return $parser->checkSyntax( $filter ); |
308 | 290 | } |
309 | 291 | |
310 | | - /** |
311 | | - * @param $expr |
312 | | - * @param array $vars |
313 | | - * @return string |
314 | | - */ |
315 | 292 | public static function evaluateExpression( $expr, $vars = array() ) { |
316 | 293 | global $wgAbuseFilterParserClass; |
317 | 294 | |
— | — | @@ -325,20 +302,8 @@ |
326 | 303 | return $parser->evaluateExpression( $expr ); |
327 | 304 | } |
328 | 305 | |
329 | | - /** |
330 | | - * @param $conds |
331 | | - * @param $vars |
332 | | - * @param $ignoreError bool |
333 | | - * @param $keepVars string |
334 | | - * @return bool |
335 | | - * @throws Exception |
336 | | - */ |
337 | | - public static function checkConditions( |
338 | | - $conds, |
339 | | - $vars, |
340 | | - $ignoreError = true, |
341 | | - $keepVars = 'resetvars' |
342 | | - ) { |
| 306 | + public static function checkConditions( $conds, $vars, $ignoreError = true, |
| 307 | + $keepVars = 'resetvars' ) { |
343 | 308 | global $wgAbuseFilterParserClass; |
344 | 309 | |
345 | 310 | static $parser; |
— | — | @@ -423,14 +388,6 @@ |
424 | 389 | return $filter_matched; |
425 | 390 | } |
426 | 391 | |
427 | | - /** |
428 | | - * @static |
429 | | - * @param $row |
430 | | - * @param $vars |
431 | | - * @param $profile bool |
432 | | - * @param $prefix string |
433 | | - * @return bool |
434 | | - */ |
435 | 392 | public static function checkFilter( $row, $vars, $profile = false, $prefix = '' ) { |
436 | 393 | $filterID = $prefix . $row->af_id; |
437 | 394 | |
— | — | @@ -444,12 +401,8 @@ |
445 | 402 | |
446 | 403 | // Check conditions... |
447 | 404 | $pattern = trim( $row->af_pattern ); |
448 | | - if ( self::checkConditions( |
449 | | - $pattern, |
450 | | - $vars, |
451 | | - true /* ignore errors */, |
452 | | - 'keepvars' |
453 | | - ) ) { |
| 405 | + if ( self::checkConditions( $pattern, $vars, true /* ignore errors */, |
| 406 | + 'keepvars' ) ) { |
454 | 407 | // Record match. |
455 | 408 | $result = true; |
456 | 409 | } else { |
— | — | @@ -470,9 +423,6 @@ |
471 | 424 | return $result; |
472 | 425 | } |
473 | 426 | |
474 | | - /** |
475 | | - * @param $filter |
476 | | - */ |
477 | 427 | public static function resetFilterProfile( $filter ) { |
478 | 428 | global $wgMemc; |
479 | 429 | $countKey = wfMemcKey( 'abusefilter', 'profile', $filter, 'count' ); |
— | — | @@ -482,11 +432,6 @@ |
483 | 433 | $wgMemc->delete( $totalKey ); |
484 | 434 | } |
485 | 435 | |
486 | | - /** |
487 | | - * @param $filter |
488 | | - * @param $time |
489 | | - * @param $conds |
490 | | - */ |
491 | 436 | public static function recordProfilingResult( $filter, $time, $conds ) { |
492 | 437 | global $wgMemc; |
493 | 438 | |
— | — | @@ -509,10 +454,6 @@ |
510 | 455 | } |
511 | 456 | } |
512 | 457 | |
513 | | - /** |
514 | | - * @param $filter |
515 | | - * @return array |
516 | | - */ |
517 | 458 | public static function getFilterProfile( $filter ) { |
518 | 459 | global $wgMemc; |
519 | 460 | |
— | — | @@ -542,7 +483,7 @@ |
543 | 484 | * |
544 | 485 | * @param $filter string |
545 | 486 | * |
546 | | - * @return string|bool |
| 487 | + * @return string|false |
547 | 488 | */ |
548 | 489 | public static function decodeGlobalName( $filter ) { |
549 | 490 | if ( strpos( $filter, 'global-' ) == 0 ) { |
— | — | @@ -552,10 +493,6 @@ |
553 | 494 | return false; |
554 | 495 | } |
555 | 496 | |
556 | | - /** |
557 | | - * @param $filters array |
558 | | - * @return array |
559 | | - */ |
560 | 497 | public static function getConsequencesForFilters( $filters ) { |
561 | 498 | $globalFilters = array(); |
562 | 499 | $localFilters = array(); |
— | — | @@ -591,12 +528,6 @@ |
592 | 529 | return $consequences; |
593 | 530 | } |
594 | 531 | |
595 | | - /** |
596 | | - * @param $dbr DatabaseBase |
597 | | - * @param $filters array |
598 | | - * @param $prefix string |
599 | | - * @return array |
600 | | - */ |
601 | 532 | public static function loadConsequencesFromDB( $dbr, $filters, $prefix = '' ) { |
602 | 533 | $actionsByFilter = array(); |
603 | 534 | foreach ( $filters as $filter ) { |
— | — | @@ -731,11 +662,6 @@ |
732 | 663 | return array( $actionsTaken, implode( "\n", $messages ) ); |
733 | 664 | } |
734 | 665 | |
735 | | - /** |
736 | | - * @param $vars AbuseFilterVariableHolder |
737 | | - * @param $title |
738 | | - * @return bool |
739 | | - */ |
740 | 666 | public static function filterAction( $vars, $title ) { |
741 | 667 | global $wgUser, $wgTitle; |
742 | 668 | |
— | — | @@ -756,10 +682,8 @@ |
757 | 683 | |
758 | 684 | $filter_matched = self::checkAllFilters( $vars ); |
759 | 685 | |
760 | | - $matched_filters = array_keys( array_filter( $filter_matched ) ); |
761 | | - |
762 | 686 | // Short-cut any remaining code if no filters were hit. |
763 | | - if ( count( $matched_filters ) == 0 ) { |
| 687 | + if ( count( array_filter( $filter_matched ) ) == 0 ) { |
764 | 688 | wfProfileOut( __METHOD__ ); |
765 | 689 | return true; |
766 | 690 | } |
— | — | @@ -767,7 +691,7 @@ |
768 | 692 | wfProfileIn( __METHOD__ . '-block' ); |
769 | 693 | |
770 | 694 | list( $actions_taken, $error_msg ) = self::executeFilterActions( |
771 | | - $matched_filters, $title, $vars ); |
| 695 | + array_keys( array_filter( $filter_matched ) ), $title, $vars ); |
772 | 696 | |
773 | 697 | $action = $vars->getVar( 'ACTION' )->toString(); |
774 | 698 | |
— | — | @@ -797,13 +721,6 @@ |
798 | 722 | return $error_msg; |
799 | 723 | } |
800 | 724 | |
801 | | - /** |
802 | | - * @param $actions_taken |
803 | | - * @param $log_template |
804 | | - * @param $action |
805 | | - * @param $vars AbuseFilterVariableHolder |
806 | | - * @return mixed |
807 | | - */ |
808 | 725 | public static function addLogEntries( $actions_taken, $log_template, $action, $vars ) { |
809 | 726 | wfProfileIn( __METHOD__ ); |
810 | 727 | $dbw = wfGetDB( DB_MASTER ); |
— | — | @@ -866,11 +783,7 @@ |
867 | 784 | // Increment trigger counter |
868 | 785 | $wgMemc->incr( self::filterMatchesKey() ); |
869 | 786 | |
870 | | - $local_log_ids = array(); |
871 | | - foreach( $log_rows as $row ) { |
872 | | - $dbw->insert( 'abuse_filter_log', $row, __METHOD__ ); |
873 | | - $local_log_ids[] = $dbw->insertId(); |
874 | | - } |
| 787 | + $dbw->insert( 'abuse_filter_log', $log_rows, __METHOD__ ); |
875 | 788 | |
876 | 789 | if ( count( $logged_local_filters ) ) { |
877 | 790 | // Update hit-counter. |
— | — | @@ -881,8 +794,6 @@ |
882 | 795 | ); |
883 | 796 | } |
884 | 797 | |
885 | | - $global_log_ids = array(); |
886 | | - |
887 | 798 | // Global stuff |
888 | 799 | if ( count( $logged_global_filters ) ) { |
889 | 800 | $vars->computeDBVars(); |
— | — | @@ -895,9 +806,7 @@ |
896 | 807 | global $wgAbuseFilterCentralDB; |
897 | 808 | $fdb = wfGetDB( DB_MASTER, array(), $wgAbuseFilterCentralDB ); |
898 | 809 | |
899 | | - foreach( $central_log_rows as $row ) { |
900 | | - $fdb->insert( 'abuse_filter_log', $row, __METHOD__ ); |
901 | | - } |
| 810 | + $fdb->insert( 'abuse_filter_log', $central_log_rows, __METHOD__ ); |
902 | 811 | |
903 | 812 | $fdb->update( 'abuse_filter', |
904 | 813 | array( 'af_hit_count=af_hit_count+1' ), |
— | — | @@ -906,9 +815,6 @@ |
907 | 816 | ); |
908 | 817 | } |
909 | 818 | |
910 | | - $vars->setVar( 'global_log_ids', $global_log_ids ); |
911 | | - $vars->setVar( 'local_log_ids', $local_log_ids ); |
912 | | - |
913 | 819 | // Check for emergency disabling. |
914 | 820 | $total = $wgMemc->get( AbuseFilter::filterUsedKey() ); |
915 | 821 | self::checkEmergencyDisable( $logged_local_filters, $total ); |
— | — | @@ -990,7 +896,7 @@ |
991 | 897 | * |
992 | 898 | * @param $stored_dump |
993 | 899 | * |
994 | | - * @return object|AbuseFilterVariableHolder |
| 900 | + * @return object |
995 | 901 | */ |
996 | 902 | public static function loadVarDump( $stored_dump ) { |
997 | 903 | wfProfileIn( __METHOD__ ); |
— | — | @@ -1034,14 +940,6 @@ |
1035 | 941 | return $obj; |
1036 | 942 | } |
1037 | 943 | |
1038 | | - /** |
1039 | | - * @param $action string |
1040 | | - * @param $parameters array |
1041 | | - * @param $title Title |
1042 | | - * @param $vars AbuseFilterVariableHolder |
1043 | | - * @param $rule_desc |
1044 | | - * @return string |
1045 | | - */ |
1046 | 944 | public static function takeConsequenceAction( $action, $parameters, $title, |
1047 | 945 | $vars, $rule_desc ) |
1048 | 946 | { |
— | — | @@ -1201,14 +1099,6 @@ |
1202 | 1100 | return $display; |
1203 | 1101 | } |
1204 | 1102 | |
1205 | | - /** |
1206 | | - * @param $throttleId |
1207 | | - * @param $types |
1208 | | - * @param $title |
1209 | | - * @param $rateCount |
1210 | | - * @param $ratePeriod |
1211 | | - * @return bool |
1212 | | - */ |
1213 | 1103 | public static function isThrottled( $throttleId, $types, $title, $rateCount, $ratePeriod ) { |
1214 | 1104 | global $wgMemc; |
1215 | 1105 | |
— | — | @@ -1237,11 +1127,6 @@ |
1238 | 1128 | return false; // NOT THROTTLED |
1239 | 1129 | } |
1240 | 1130 | |
1241 | | - /** |
1242 | | - * @param $type |
1243 | | - * @param $title Title |
1244 | | - * @return Int|string |
1245 | | - */ |
1246 | 1131 | public static function throttleIdentifier( $type, $title ) { |
1247 | 1132 | global $wgUser; |
1248 | 1133 | |
— | — | @@ -1272,12 +1157,6 @@ |
1273 | 1158 | return $identifier; |
1274 | 1159 | } |
1275 | 1160 | |
1276 | | - /** |
1277 | | - * @param $throttleId |
1278 | | - * @param $type |
1279 | | - * @param $title Title |
1280 | | - * @return String |
1281 | | - */ |
1282 | 1161 | public static function throttleKey( $throttleId, $type, $title ) { |
1283 | 1162 | $types = explode( ',', $type ); |
1284 | 1163 | |
— | — | @@ -1292,17 +1171,10 @@ |
1293 | 1172 | return wfMemcKey( 'abusefilter', 'throttle', $throttleId, $type, $identifier ); |
1294 | 1173 | } |
1295 | 1174 | |
1296 | | - /** |
1297 | | - * @param $user User |
1298 | | - * @return String |
1299 | | - */ |
1300 | 1175 | public static function autoPromoteBlockKey( $user ) { |
1301 | 1176 | return wfMemcKey( 'abusefilter', 'block-autopromote', $user->getId() ); |
1302 | 1177 | } |
1303 | 1178 | |
1304 | | - /** |
1305 | | - * @param $filters |
1306 | | - */ |
1307 | 1179 | public static function recordStats( $filters ) { |
1308 | 1180 | global $wgAbuseFilterConditionLimit, $wgMemc; |
1309 | 1181 | |
— | — | @@ -1341,10 +1213,6 @@ |
1342 | 1214 | wfProfileOut( __METHOD__ ); |
1343 | 1215 | } |
1344 | 1216 | |
1345 | | - /** |
1346 | | - * @param $filters |
1347 | | - * @param $total |
1348 | | - */ |
1349 | 1217 | public static function checkEmergencyDisable( $filters, $total ) { |
1350 | 1218 | global $wgAbuseFilterEmergencyDisableThreshold, $wgAbuseFilterEmergencyDisableCount, |
1351 | 1219 | $wgAbuseFilterEmergencyDisableAge, $wgMemc; |
— | — | @@ -1383,31 +1251,18 @@ |
1384 | 1252 | } |
1385 | 1253 | } |
1386 | 1254 | |
1387 | | - /** |
1388 | | - * @return String |
1389 | | - */ |
1390 | 1255 | public static function filterLimitReachedKey() { |
1391 | 1256 | return wfMemcKey( 'abusefilter', 'stats', 'overflow' ); |
1392 | 1257 | } |
1393 | 1258 | |
1394 | | - /** |
1395 | | - * @return String |
1396 | | - */ |
1397 | 1259 | public static function filterUsedKey() { |
1398 | 1260 | return wfMemcKey( 'abusefilter', 'stats', 'total' ); |
1399 | 1261 | } |
1400 | 1262 | |
1401 | | - /** |
1402 | | - * @param $filter |
1403 | | - * @return String |
1404 | | - */ |
1405 | 1263 | public static function filterMatchesKey( $filter = null ) { |
1406 | 1264 | return wfMemcKey( 'abusefilter', 'stats', 'matches', $filter ); |
1407 | 1265 | } |
1408 | 1266 | |
1409 | | - /** |
1410 | | - * @return User |
1411 | | - */ |
1412 | 1267 | public static function getFilterUser() { |
1413 | 1268 | $user = User::newFromName( wfMsgForContent( 'abusefilter-blocker' ) ); |
1414 | 1269 | $user->load(); |
— | — | @@ -1442,7 +1297,6 @@ |
1443 | 1298 | * @param $textName String |
1444 | 1299 | * @param $addResultDiv Boolean |
1445 | 1300 | * @param $canEdit Boolean |
1446 | | - * @return string |
1447 | 1301 | */ |
1448 | 1302 | static function buildEditBox( $rules, $textName = 'wpFilterRules', $addResultDiv = true, |
1449 | 1303 | $canEdit = true ) { |
— | — | @@ -1567,10 +1421,6 @@ |
1568 | 1422 | return array_unique( $differences ); |
1569 | 1423 | } |
1570 | 1424 | |
1571 | | - /** |
1572 | | - * @param $row |
1573 | | - * @return array |
1574 | | - */ |
1575 | 1425 | static function translateFromHistory( $row ) { |
1576 | 1426 | # Translate into an abuse_filter row with some black magic. |
1577 | 1427 | # This is ever so slightly evil! |
— | — | @@ -1606,20 +1456,12 @@ |
1607 | 1457 | return array( $af_row, $actions_output ); |
1608 | 1458 | } |
1609 | 1459 | |
1610 | | - /** |
1611 | | - * @param $action string |
1612 | | - * @return String |
1613 | | - */ |
1614 | 1460 | static function getActionDisplay( $action ) { |
1615 | 1461 | $display = wfMsg( "abusefilter-action-$action" ); |
1616 | 1462 | $display = wfEmptyMsg( "abusefilter-action-$action", $display ) ? $action : $display; |
1617 | 1463 | return $display; |
1618 | 1464 | } |
1619 | 1465 | |
1620 | | - /** |
1621 | | - * @param $row |
1622 | | - * @return AbuseFilterVariableHolder|null |
1623 | | - */ |
1624 | 1466 | public static function getVarsFromRCRow( $row ) { |
1625 | 1467 | if ( $row->rc_this_oldid ) { |
1626 | 1468 | // It's an edit. |
— | — | @@ -1639,10 +1481,6 @@ |
1640 | 1482 | return $vars; |
1641 | 1483 | } |
1642 | 1484 | |
1643 | | - /** |
1644 | | - * @param $row |
1645 | | - * @return AbuseFilterVariableHolder |
1646 | | - */ |
1647 | 1485 | public static function getCreateVarsFromRCRow( $row ) { |
1648 | 1486 | $vars = new AbuseFilterVariableHolder; |
1649 | 1487 | |
— | — | @@ -1659,10 +1497,6 @@ |
1660 | 1498 | return $vars; |
1661 | 1499 | } |
1662 | 1500 | |
1663 | | - /** |
1664 | | - * @param $row |
1665 | | - * @return AbuseFilterVariableHolder |
1666 | | - */ |
1667 | 1501 | public static function getEditVarsFromRCRow( $row ) { |
1668 | 1502 | $vars = new AbuseFilterVariableHolder; |
1669 | 1503 | $title = Title::makeTitle( $row->rc_namespace, $row->rc_title ); |
— | — | @@ -1696,10 +1530,6 @@ |
1697 | 1531 | return $vars; |
1698 | 1532 | } |
1699 | 1533 | |
1700 | | - /** |
1701 | | - * @param $row |
1702 | | - * @return AbuseFilterVariableHolder |
1703 | | - */ |
1704 | 1534 | public static function getMoveVarsFromRCRow( $row ) { |
1705 | 1535 | $vars = new AbuseFilterVariableHolder; |
1706 | 1536 | |
— | — | @@ -1729,8 +1559,8 @@ |
1730 | 1560 | } |
1731 | 1561 | |
1732 | 1562 | /** |
1733 | | - * @param $title Title |
1734 | | - * @param $article Array |
| 1563 | + * @static |
| 1564 | + * @param $title Title |
1735 | 1565 | * @return AbuseFilterVariableHolder |
1736 | 1566 | */ |
1737 | 1567 | public static function getEditVars( $title, $article = null ) { |
— | — | @@ -1789,10 +1619,6 @@ |
1790 | 1620 | return $vars; |
1791 | 1621 | } |
1792 | 1622 | |
1793 | | - /** |
1794 | | - * @param $vars AbuseFilterVariableHolder |
1795 | | - * @return string |
1796 | | - */ |
1797 | 1623 | public static function buildVarDumpTable( $vars ) { |
1798 | 1624 | // Export all values |
1799 | 1625 | if ( $vars instanceof AbuseFilterVariableHolder ) { |
— | — | @@ -1846,32 +1672,20 @@ |
1847 | 1673 | return $output; |
1848 | 1674 | } |
1849 | 1675 | |
1850 | | - /** |
1851 | | - * @param $page |
1852 | | - * @param $type |
1853 | | - * @param $title Title |
1854 | | - * @param $sk Skin |
1855 | | - * @param $args array |
1856 | | - * @return String |
1857 | | - */ |
1858 | 1676 | static function modifyActionText( $page, $type, $title, $sk, $args ) { |
1859 | 1677 | list( $history_id, $filter_id ) = $args; |
1860 | 1678 | |
1861 | | - $filter_link = Linker::link( $title ); |
| 1679 | + $filter_link = $sk ? $sk->link( $title ) : $title->getCanonicalURL(); |
1862 | 1680 | |
1863 | 1681 | $details_title = SpecialPage::getTitleFor( 'AbuseFilter', "history/$filter_id/diff/prev/$history_id" ); |
1864 | 1682 | $details_text = wfMsgExt( 'abusefilter-log-detailslink', 'parseinline' ); |
1865 | | - $details_link = Linker::link( $details_title, $details_text ); |
| 1683 | + $details_link = |
| 1684 | + $sk ? $sk->link( $details_title, $details_text ) : $details_title->getCanonicalURL(); |
1866 | 1685 | |
1867 | 1686 | return wfMsgExt( 'abusefilter-log-entry-modify', |
1868 | 1687 | array( 'parseinline', 'replaceafter' ), array( $filter_link, $details_link ) ); |
1869 | 1688 | } |
1870 | 1689 | |
1871 | | - /** |
1872 | | - * @param $action |
1873 | | - * @param $parameters |
1874 | | - * @return String |
1875 | | - */ |
1876 | 1690 | static function formatAction( $action, $parameters ) { |
1877 | 1691 | global $wgLang; |
1878 | 1692 | if ( count( $parameters ) == 0 ) { |
— | — | @@ -1884,10 +1698,6 @@ |
1885 | 1699 | return $displayAction; |
1886 | 1700 | } |
1887 | 1701 | |
1888 | | - /** |
1889 | | - * @param $value array |
1890 | | - * @return string |
1891 | | - */ |
1892 | 1702 | static function formatFlags( $value ) { |
1893 | 1703 | global $wgLang; |
1894 | 1704 | $flags = array_filter( explode( ',', $value ) ); |
— | — | @@ -1898,9 +1708,6 @@ |
1899 | 1709 | return $wgLang->commaList( $flags_display ); |
1900 | 1710 | } |
1901 | 1711 | |
1902 | | - /** |
1903 | | - * @param $data string |
1904 | | - */ |
1905 | 1712 | static function sendToUDP( $data ) { |
1906 | 1713 | global $wgAbuseFilterUDPPrefix, $wgAbuseFilterUDPAddress, $wgAbuseFilterUDPPort; |
1907 | 1714 | |
— | — | @@ -1912,15 +1719,11 @@ |
1913 | 1720 | ); |
1914 | 1721 | } |
1915 | 1722 | |
1916 | | - /** |
1917 | | - * @param $filterID |
1918 | | - * @return bool|mixed|string |
1919 | | - */ |
1920 | 1723 | static function getGlobalFilterDescription( $filterID ) { |
1921 | 1724 | global $wgAbuseFilterCentralDB; |
1922 | 1725 | |
1923 | 1726 | if ( !$wgAbuseFilterCentralDB ) { |
1924 | | - return ''; |
| 1727 | + return; |
1925 | 1728 | } |
1926 | 1729 | |
1927 | 1730 | $fdb = wfGetDB( DB_SLAVE, array(), $wgAbuseFilterCentralDB ); |
Index: trunk/extensions/AbuseFilter/AbuseFilterVariableHolder.php |
— | — | @@ -3,10 +3,6 @@ |
4 | 4 | var $mVars = array(); |
5 | 5 | static $varBlacklist = array( 'context' ); |
6 | 6 | |
7 | | - /** |
8 | | - * @param $variable |
9 | | - * @param $datum |
10 | | - */ |
11 | 7 | function setVar( $variable, $datum ) { |
12 | 8 | $variable = strtolower( $variable ); |
13 | 9 | if ( !( $datum instanceof AFPData || $datum instanceof AFComputedVariable ) ) { |
— | — | @@ -16,20 +12,11 @@ |
17 | 13 | $this->mVars[$variable] = $datum; |
18 | 14 | } |
19 | 15 | |
20 | | - /** |
21 | | - * @param $variable |
22 | | - * @param $method |
23 | | - * @param $parameters |
24 | | - */ |
25 | 16 | function setLazyLoadVar( $variable, $method, $parameters ) { |
26 | 17 | $placeholder = new AFComputedVariable( $method, $parameters ); |
27 | 18 | $this->setVar( $variable, $placeholder ); |
28 | 19 | } |
29 | 20 | |
30 | | - /** |
31 | | - * @param $variable |
32 | | - * @return AFPData |
33 | | - */ |
34 | 21 | function getVar( $variable ) { |
35 | 22 | $variable = strtolower( $variable ); |
36 | 23 | if ( isset( $this->mVars[$variable] ) ) { |
— | — | @@ -45,9 +32,6 @@ |
46 | 33 | } |
47 | 34 | } |
48 | 35 | |
49 | | - /** |
50 | | - * @return AbuseFilterVariableHolder |
51 | | - */ |
52 | 36 | static function merge() { |
53 | 37 | $newHolder = new AbuseFilterVariableHolder; |
54 | 38 | |
— | — | @@ -58,10 +42,6 @@ |
59 | 43 | return $newHolder; |
60 | 44 | } |
61 | 45 | |
62 | | - /** |
63 | | - * @param $addHolder |
64 | | - * @throws MWException |
65 | | - */ |
66 | 46 | function addHolder( $addHolder ) { |
67 | 47 | if ( !is_object( $addHolder ) ) { |
68 | 48 | throw new MWException( 'Invalid argument to AbuseFilterVariableHolder::addHolder' ); |
— | — | @@ -74,9 +54,6 @@ |
75 | 55 | $this->setVar( 'context', 'stored' ); |
76 | 56 | } |
77 | 57 | |
78 | | - /** |
79 | | - * @return array |
80 | | - */ |
81 | 58 | function exportAllVars() { |
82 | 59 | $allVarNames = array_keys( $this->mVars ); |
83 | 60 | $exported = array(); |
— | — | @@ -90,10 +67,6 @@ |
91 | 68 | return $exported; |
92 | 69 | } |
93 | 70 | |
94 | | - /** |
95 | | - * @param $var |
96 | | - * @return bool |
97 | | - */ |
98 | 71 | function varIsSet( $var ) { |
99 | 72 | return array_key_exists( $var, $this->mVars ); |
100 | 73 | } |
— | — | @@ -129,10 +102,6 @@ |
130 | 103 | static $userCache = array(); |
131 | 104 | static $articleCache = array(); |
132 | 105 | |
133 | | - /** |
134 | | - * @param $method |
135 | | - * @param $parameters |
136 | | - */ |
137 | 106 | function __construct( $method, $parameters ) { |
138 | 107 | $this->mMethod = $method; |
139 | 108 | $this->mParameters = $parameters; |
— | — | @@ -150,7 +119,7 @@ |
151 | 120 | function parseNonEditWikitext( $wikitext, $article ) { |
152 | 121 | static $cache = array(); |
153 | 122 | |
154 | | - $cacheKey = md5( $wikitext ) . ':' . $article->getTitle()->getPrefixedText(); |
| 123 | + $cacheKey = md5( $wikitext ) . ':' . $article->mTitle->getPrefixedText(); |
155 | 124 | |
156 | 125 | if ( isset( $cache[$cacheKey] ) ) { |
157 | 126 | return $cache[$cacheKey]; |
— | — | @@ -166,10 +135,6 @@ |
167 | 136 | return $edit; |
168 | 137 | } |
169 | 138 | |
170 | | - /** |
171 | | - * @param $username string |
172 | | - * @return User |
173 | | - */ |
174 | 139 | static function userObjectFromName( $username ) { |
175 | 140 | if ( isset( self::$userCache[$username] ) ) { |
176 | 141 | return self::$userCache[$username]; |
— | — | @@ -195,11 +160,6 @@ |
196 | 161 | return $user; |
197 | 162 | } |
198 | 163 | |
199 | | - /** |
200 | | - * @param $namespace |
201 | | - * @param $title Title |
202 | | - * @return Article |
203 | | - */ |
204 | 164 | static function articleFromTitle( $namespace, $title ) { |
205 | 165 | if ( isset( self::$articleCache["$namespace:$title"] ) ) { |
206 | 166 | return self::$articleCache["$namespace:$title"]; |
— | — | @@ -217,10 +177,6 @@ |
218 | 178 | return self::$articleCache["$namespace:$title"]; |
219 | 179 | } |
220 | 180 | |
221 | | - /** |
222 | | - * @param $article Article |
223 | | - * @return array |
224 | | - */ |
225 | 181 | static function getLinksFromDB( $article ) { |
226 | 182 | // Stolen from ConfirmEdit |
227 | 183 | $id = $article->getId(); |
— | — | @@ -242,12 +198,6 @@ |
243 | 199 | return $links; |
244 | 200 | } |
245 | 201 | |
246 | | - /** |
247 | | - * @param $vars AbuseFilterVariableHolder |
248 | | - * @return AFPData|array|int|mixed|null|string |
249 | | - * @throws MWException |
250 | | - * @throws AFPException |
251 | | - */ |
252 | 202 | function compute( $vars ) { |
253 | 203 | $parameters = $this->mParameters; |
254 | 204 | $result = null; |
Index: trunk/extensions/AbuseFilter/AbuseFilter.i18n.php |
— | — | @@ -91,7 +91,6 @@ |
92 | 92 | 'abusefilter-log-detailedentry-global' => 'global filter $1', |
93 | 93 | 'abusefilter-log-detailedentry-local' => 'filter $1', |
94 | 94 | 'abusefilter-log-detailslink' => 'details', |
95 | | - 'abusefilter-log-diff' => 'diff', |
96 | 95 | 'abusefilter-log-hidelink' => 'adjust visibility', |
97 | 96 | 'abusefilter-log-details-legend' => 'Details for log entry $1', |
98 | 97 | 'abusefilter-log-details-var' => 'Variable', |
— | — | @@ -104,7 +103,7 @@ |
105 | 104 | 'abusefilter-log-linkoncontribs' => 'abuse log', |
106 | 105 | 'abusefilter-log-linkoncontribs-text' => 'Abuse log for this user', |
107 | 106 | 'abusefilter-log-hidden' => '(entry hidden)', |
108 | | - 'abusefilter-log-hidden-implicit' => '(hidden because revision has been deleted)', |
| 107 | + 'abusefilter-log-hide' => 'hide or unhide', // @todo FIXME: Message unused? |
109 | 108 | 'abusefilter-log-cannot-see-details' => 'You do not have permission to see details of this entry.', |
110 | 109 | 'abusefilter-log-details-hidden' => 'You cannot view the details for this entry because it is hidden from public view.', |
111 | 110 | |
Index: trunk/extensions/AbuseFilter/api/ApiQueryAbuseLog.php |
— | — | @@ -73,7 +73,6 @@ |
74 | 74 | $this->addFieldsIf( 'afl_var_dump', $fld_details ); |
75 | 75 | $this->addFieldsIf( 'afl_actions', $fld_result ); |
76 | 76 | $this->addFieldsIf( 'afl_deleted', $fld_hidden ); |
77 | | - $this->addFields( 'afl_rev_id' ); |
78 | 77 | |
79 | 78 | if ( $fld_filter ) { |
80 | 79 | $this->addTables( 'abuse_filter' ); |
— | — | @@ -111,11 +110,6 @@ |
112 | 111 | $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->afl_timestamp ) ); |
113 | 112 | break; |
114 | 113 | } |
115 | | - if ( SpecialAbuseLog::isHidden($row) && |
116 | | - !SpecialAbuseLog::canSeeHidden( $user ) |
117 | | - ) { |
118 | | - continue; |
119 | | - } |
120 | 114 | $entry = array(); |
121 | 115 | if ( $fld_ids ) { |
122 | 116 | $entry['id'] = intval( $row->afl_id ); |
— | — | @@ -153,10 +147,7 @@ |
154 | 148 | } |
155 | 149 | |
156 | 150 | if ( $fld_hidden ) { |
157 | | - $val = SpecialAbuseLog::isHidden($row); |
158 | | - if ( $val ) { |
159 | | - $entry['hidden'] = $val; |
160 | | - } |
| 151 | + $entry['hidden'] = $row->afl_deleted; |
161 | 152 | } |
162 | 153 | |
163 | 154 | if ( $entry ) { |
Index: trunk/extensions/AbuseFilter/AbuseFilter.hooks.php |
— | — | @@ -4,11 +4,6 @@ |
5 | 5 | } |
6 | 6 | |
7 | 7 | class AbuseFilterHooks { |
8 | | - |
9 | | - /** |
10 | | - * @var AbuseFilterVariableHolder |
11 | | - */ |
12 | | - static $successful_action_vars = false; |
13 | 8 | // So far, all of the error message out-params for these hooks accept HTML. |
14 | 9 | // Hooray! |
15 | 10 | |
— | — | @@ -16,8 +11,8 @@ |
17 | 12 | * Entry points for MediaWiki hook 'EditFilterMerged' |
18 | 13 | * |
19 | 14 | * @param $editor EditPage instance (object) |
20 | | - * @param $text string Content of the edit box |
21 | | - * @param &$error string Error message to return |
| 15 | + * @param $text Content of the edit box |
| 16 | + * @param &$error Error message to return |
22 | 17 | * @param $summary Edit summary for page |
23 | 18 | * @return bool |
24 | 19 | */ |
— | — | @@ -25,8 +20,6 @@ |
26 | 21 | // Load vars |
27 | 22 | $vars = new AbuseFilterVariableHolder; |
28 | 23 | |
29 | | - self::$successful_action_vars = false; |
30 | | - |
31 | 24 | // Check for null edits. |
32 | 25 | $oldtext = ''; |
33 | 26 | |
— | — | @@ -48,9 +41,9 @@ |
49 | 42 | |
50 | 43 | global $wgUser; |
51 | 44 | $vars->addHolder( AbuseFilter::generateUserVars( $wgUser ) ); |
52 | | - $vars->addHolder( AbuseFilter::generateTitleVars( $title , 'article' ) ); |
53 | | - $vars->setVar( 'action', 'edit' ); |
54 | | - $vars->setVar( 'summary', $summary ); |
| 45 | + $vars->addHolder( AbuseFilter::generateTitleVars( $title , 'ARTICLE' ) ); |
| 46 | + $vars->setVar( 'ACTION', 'edit' ); |
| 47 | + $vars->setVar( 'SUMMARY', $summary ); |
55 | 48 | $vars->setVar( 'minor_edit', $editor->minoredit ); |
56 | 49 | |
57 | 50 | $vars->setVar( 'old_wikitext', $oldtext ); |
— | — | @@ -66,77 +59,9 @@ |
67 | 60 | $editor->showEditForm(); |
68 | 61 | return false; |
69 | 62 | } |
70 | | - |
71 | | - self::$successful_action_vars = $vars; |
72 | | - |
73 | 63 | return true; |
74 | 64 | } |
75 | 65 | |
76 | | - /** |
77 | | - * @param $article Article |
78 | | - * @param $user User |
79 | | - * @param $text string |
80 | | - * @param $summary string |
81 | | - * @param $minoredit bool |
82 | | - * @param $watchthis bool |
83 | | - * @param $sectionanchor |
84 | | - * @param $flags |
85 | | - * @param $revision Revision |
86 | | - * @return bool |
87 | | - */ |
88 | | - public static function onArticleSaveComplete( |
89 | | - &$article, &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor, |
90 | | - &$flags, $revision |
91 | | - ) { |
92 | | - if ( ! self::$successful_action_vars ) { |
93 | | - return true; |
94 | | - } |
95 | | - |
96 | | - $vars = self::$successful_action_vars; |
97 | | - |
98 | | - if ( $vars->getVar('article_prefixedtext')->toString() !== |
99 | | - $article->getTitle()->getPrefixedText() |
100 | | - ) { |
101 | | - return true; |
102 | | - } |
103 | | - |
104 | | - if ( $vars->getVar('local_log_ids') ) { |
105 | | - // Now actually do our storage |
106 | | - $log_ids = $vars->getVar('local_log_ids')->toNative(); |
107 | | - $dbw = wfGetDB( DB_MASTER ); |
108 | | - |
109 | | - if ( count($log_ids) ) { |
110 | | - $dbw->update( 'abuse_filter_log', |
111 | | - array( 'afl_rev_id' => $revision->getId() ), |
112 | | - array( 'afl_id' => $log_ids ), |
113 | | - __METHOD__ |
114 | | - ); |
115 | | - } |
116 | | - } |
117 | | - |
118 | | - if ( $vars->getVar('global_log_ids') ) { |
119 | | - $log_ids = $vars->getVar('global_log_ids')->toNative(); |
120 | | - |
121 | | - global $wgAbuseFilterCentralDB; |
122 | | - $dbw = wfGetDB( DB_MASTER, array(), $wgAbuseFilterCentralDB ); |
123 | | - |
124 | | - if ( count($log_ids) ) { |
125 | | - $dbw->update( 'abuse_filter_log', |
126 | | - array( 'afl_rev_id' => $revision->getId() ), |
127 | | - array( 'afl_id' => $log_ids, 'afl_wiki' => wfWikiId() ), |
128 | | - __METHOD__ |
129 | | - ); |
130 | | - } |
131 | | - } |
132 | | - |
133 | | - return true; |
134 | | - } |
135 | | - |
136 | | - /** |
137 | | - * @param $user |
138 | | - * @param $promote |
139 | | - * @return bool |
140 | | - */ |
141 | 66 | public static function onGetAutoPromoteGroups( $user, &$promote ) { |
142 | 67 | global $wgMemc; |
143 | 68 | |
— | — | @@ -149,14 +74,6 @@ |
150 | 75 | return true; |
151 | 76 | } |
152 | 77 | |
153 | | - /** |
154 | | - * @param $oldTitle Title |
155 | | - * @param $newTitle Title |
156 | | - * @param $user User |
157 | | - * @param $error |
158 | | - * @param $reason |
159 | | - * @return bool |
160 | | - */ |
161 | 78 | public static function onAbortMove( $oldTitle, $newTitle, $user, &$error, $reason ) { |
162 | 79 | $vars = new AbuseFilterVariableHolder; |
163 | 80 | |
— | — | @@ -178,34 +95,22 @@ |
179 | 96 | return $filter_result == '' || $filter_result === true; |
180 | 97 | } |
181 | 98 | |
182 | | - /** |
183 | | - * @param $article Article |
184 | | - * @param $user User |
185 | | - * @param $reason string |
186 | | - * @param $error |
187 | | - * @return bool |
188 | | - */ |
189 | 99 | public static function onArticleDelete( &$article, &$user, &$reason, &$error ) { |
190 | 100 | $vars = new AbuseFilterVariableHolder; |
191 | 101 | |
192 | 102 | global $wgUser; |
193 | 103 | $vars->addHolder( AbuseFilter::generateUserVars( $wgUser ) ); |
194 | | - $vars->addHolder( AbuseFilter::generateTitleVars( $article->getTitle(), 'ARTICLE' ) ); |
| 104 | + $vars->addHolder( AbuseFilter::generateTitleVars( $article->mTitle, 'ARTICLE' ) ); |
195 | 105 | $vars->setVar( 'SUMMARY', $reason ); |
196 | 106 | $vars->setVar( 'ACTION', 'delete' ); |
197 | 107 | |
198 | | - $filter_result = AbuseFilter::filterAction( $vars, $article->getTitle() ); |
| 108 | + $filter_result = AbuseFilter::filterAction( $vars, $article->mTitle ); |
199 | 109 | |
200 | 110 | $error = $filter_result; |
201 | 111 | |
202 | 112 | return $filter_result == '' || $filter_result === true; |
203 | 113 | } |
204 | 114 | |
205 | | - /** |
206 | | - * @param $user User |
207 | | - * @param $message |
208 | | - * @return bool |
209 | | - */ |
210 | 115 | public static function onAbortNewAccount( $user, &$message ) { |
211 | 116 | if ( $user->getName() == wfMsgForContent( 'abusefilter-blocker' ) ) { |
212 | 117 | $message = wfMsg( 'abusefilter-accountreserved' ); |
— | — | @@ -230,14 +135,10 @@ |
231 | 136 | return $filter_result == '' || $filter_result === true; |
232 | 137 | } |
233 | 138 | |
234 | | - /** |
235 | | - * @param $recentChange RecentChange |
236 | | - * @return bool |
237 | | - */ |
238 | 139 | public static function onRecentChangeSave( $recentChange ) { |
239 | 140 | $title = Title::makeTitle( |
240 | | - $recentChange->getAttribute( 'rc_namespace' ), |
241 | | - $recentChange->getAttribute( 'rc_title' ) |
| 141 | + $recentChange->mAttribs['rc_namespace'], |
| 142 | + $recentChange->mAttribs['rc_title'] |
242 | 143 | ); |
243 | 144 | $action = $recentChange->mAttribs['rc_log_type'] ? |
244 | 145 | $recentChange->mAttribs['rc_log_type'] : 'edit'; |
— | — | @@ -259,10 +160,6 @@ |
260 | 161 | return true; |
261 | 162 | } |
262 | 163 | |
263 | | - /** |
264 | | - * @param $emptyTags array |
265 | | - * @return bool |
266 | | - */ |
267 | 164 | public static function onListDefinedTags( &$emptyTags ) { |
268 | 165 | # This is a pretty awful hack. |
269 | 166 | $dbr = wfGetDB( DB_SLAVE ); |
— | — | @@ -287,7 +184,6 @@ |
288 | 185 | |
289 | 186 | /** |
290 | 187 | * @param $updater DatabaseUpdater |
291 | | - * @throws MWException |
292 | 188 | * @return bool |
293 | 189 | */ |
294 | 190 | public static function onLoadExtensionSchemaUpdates( $updater = null ) { |
— | — | @@ -305,7 +201,6 @@ |
306 | 202 | $updater->addExtensionUpdate( array( 'addField', 'abuse_filter', 'af_deleted', "$dir/db_patches/patch-af_deleted.sql", true ) ); |
307 | 203 | $updater->addExtensionUpdate( array( 'addField', 'abuse_filter', 'af_actions', "$dir/db_patches/patch-af_actions.sql", true ) ); |
308 | 204 | $updater->addExtensionUpdate( array( 'addField', 'abuse_filter', 'af_global', "$dir/db_patches/patch-global_filters.sql", true ) ); |
309 | | - $updater->addExtensionUpdate( array( 'addField', 'abuse_filter_log', 'afl_rev_id', "$dir/db_patches/patch-afl_action_id.sql", true ) ); |
310 | 205 | if ( $updater->getDB()->getType() == 'mysql' ) { |
311 | 206 | $updater->addExtensionUpdate( array( 'addIndex', 'abuse_filter_log', 'filter_timestamp', "$dir/db_patches/patch-fix-indexes.sql", true ) ); |
312 | 207 | } else { |
— | — | @@ -353,16 +248,11 @@ |
354 | 249 | } |
355 | 250 | } |
356 | 251 | |
357 | | - /** |
358 | | - * @param $id |
359 | | - * @param $nt Title |
360 | | - * @param $tools |
361 | | - * @return bool |
362 | | - */ |
363 | 252 | public static function onContributionsToolLinks( $id, $nt, &$tools ) { |
364 | 253 | global $wgUser; |
365 | 254 | if ( $wgUser->isAllowed( 'abusefilter-log' ) ) { |
366 | | - $tools[] = Linker::link( |
| 255 | + $sk = $wgUser->getSkin(); |
| 256 | + $tools[] = $sk->link( |
367 | 257 | SpecialPage::getTitleFor( 'AbuseLog' ), |
368 | 258 | wfMsg( 'abusefilter-log-linkoncontribs' ), |
369 | 259 | array( 'title' => |
— | — | @@ -373,12 +263,6 @@ |
374 | 264 | return true; |
375 | 265 | } |
376 | 266 | |
377 | | - /** |
378 | | - * @param $saveName |
379 | | - * @param $tempName |
380 | | - * @param $error |
381 | | - * @return bool |
382 | | - */ |
383 | 267 | public static function onUploadVerification( $saveName, $tempName, &$error ) { |
384 | 268 | $vars = new AbuseFilterVariableHolder; |
385 | 269 | |