Index: trunk/extensions/AbuseFilter/AbuseFilter.hooks.php |
— | — | @@ -4,6 +4,10 @@ |
5 | 5 | } |
6 | 6 | |
7 | 7 | class AbuseFilterHooks { |
| 8 | + |
| 9 | + /** |
| 10 | + * @var AbuseFilterVariableHolder |
| 11 | + */ |
8 | 12 | static $successful_action_vars = false; |
9 | 13 | // So far, all of the error message out-params for these hooks accept HTML. |
10 | 14 | // Hooray! |
— | — | @@ -12,8 +16,8 @@ |
13 | 17 | * Entry points for MediaWiki hook 'EditFilterMerged' |
14 | 18 | * |
15 | 19 | * @param $editor EditPage instance (object) |
16 | | - * @param $text Content of the edit box |
17 | | - * @param &$error Error message to return |
| 20 | + * @param $text string Content of the edit box |
| 21 | + * @param &$error string Error message to return |
18 | 22 | * @param $summary Edit summary for page |
19 | 23 | * @return bool |
20 | 24 | */ |
— | — | @@ -68,6 +72,18 @@ |
69 | 73 | return true; |
70 | 74 | } |
71 | 75 | |
| 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 | + */ |
72 | 88 | public static function onArticleSaveComplete( |
73 | 89 | &$article, &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor, |
74 | 90 | &$flags, $revision |
— | — | @@ -102,7 +118,7 @@ |
103 | 119 | $log_ids = $vars->getVar('global_log_ids')->toNative(); |
104 | 120 | |
105 | 121 | global $wgAbuseFilterCentralDB; |
106 | | - $fdb = wfGetDB( DB_MASTER, array(), $wgAbuseFilterCentralDB ); |
| 122 | + $dbw = wfGetDB( DB_MASTER, array(), $wgAbuseFilterCentralDB ); |
107 | 123 | |
108 | 124 | if ( count($log_ids) ) { |
109 | 125 | $dbw->update( 'abuse_filter_log', |
— | — | @@ -116,6 +132,11 @@ |
117 | 133 | return true; |
118 | 134 | } |
119 | 135 | |
| 136 | + /** |
| 137 | + * @param $user |
| 138 | + * @param $promote |
| 139 | + * @return bool |
| 140 | + */ |
120 | 141 | public static function onGetAutoPromoteGroups( $user, &$promote ) { |
121 | 142 | global $wgMemc; |
122 | 143 | |
— | — | @@ -128,6 +149,14 @@ |
129 | 150 | return true; |
130 | 151 | } |
131 | 152 | |
| 153 | + /** |
| 154 | + * @param $oldTitle Title |
| 155 | + * @param $newTitle Title |
| 156 | + * @param $user User |
| 157 | + * @param $error |
| 158 | + * @param $reason |
| 159 | + * @return bool |
| 160 | + */ |
132 | 161 | public static function onAbortMove( $oldTitle, $newTitle, $user, &$error, $reason ) { |
133 | 162 | $vars = new AbuseFilterVariableHolder; |
134 | 163 | |
— | — | @@ -149,22 +178,34 @@ |
150 | 179 | return $filter_result == '' || $filter_result === true; |
151 | 180 | } |
152 | 181 | |
| 182 | + /** |
| 183 | + * @param $article Article |
| 184 | + * @param $user User |
| 185 | + * @param $reason string |
| 186 | + * @param $error |
| 187 | + * @return bool |
| 188 | + */ |
153 | 189 | public static function onArticleDelete( &$article, &$user, &$reason, &$error ) { |
154 | 190 | $vars = new AbuseFilterVariableHolder; |
155 | 191 | |
156 | 192 | global $wgUser; |
157 | 193 | $vars->addHolder( AbuseFilter::generateUserVars( $wgUser ) ); |
158 | | - $vars->addHolder( AbuseFilter::generateTitleVars( $article->mTitle, 'ARTICLE' ) ); |
| 194 | + $vars->addHolder( AbuseFilter::generateTitleVars( $article->getTitle(), 'ARTICLE' ) ); |
159 | 195 | $vars->setVar( 'SUMMARY', $reason ); |
160 | 196 | $vars->setVar( 'ACTION', 'delete' ); |
161 | 197 | |
162 | | - $filter_result = AbuseFilter::filterAction( $vars, $article->mTitle ); |
| 198 | + $filter_result = AbuseFilter::filterAction( $vars, $article->getTitle() ); |
163 | 199 | |
164 | 200 | $error = $filter_result; |
165 | 201 | |
166 | 202 | return $filter_result == '' || $filter_result === true; |
167 | 203 | } |
168 | 204 | |
| 205 | + /** |
| 206 | + * @param $user User |
| 207 | + * @param $message |
| 208 | + * @return bool |
| 209 | + */ |
169 | 210 | public static function onAbortNewAccount( $user, &$message ) { |
170 | 211 | if ( $user->getName() == wfMsgForContent( 'abusefilter-blocker' ) ) { |
171 | 212 | $message = wfMsg( 'abusefilter-accountreserved' ); |
— | — | @@ -189,10 +230,14 @@ |
190 | 231 | return $filter_result == '' || $filter_result === true; |
191 | 232 | } |
192 | 233 | |
| 234 | + /** |
| 235 | + * @param $recentChange RecentChange |
| 236 | + * @return bool |
| 237 | + */ |
193 | 238 | public static function onRecentChangeSave( $recentChange ) { |
194 | 239 | $title = Title::makeTitle( |
195 | | - $recentChange->mAttribs['rc_namespace'], |
196 | | - $recentChange->mAttribs['rc_title'] |
| 240 | + $recentChange->getAttribute( 'rc_namespace' ), |
| 241 | + $recentChange->getAttribute( 'rc_title' ) |
197 | 242 | ); |
198 | 243 | $action = $recentChange->mAttribs['rc_log_type'] ? |
199 | 244 | $recentChange->mAttribs['rc_log_type'] : 'edit'; |
— | — | @@ -214,6 +259,10 @@ |
215 | 260 | return true; |
216 | 261 | } |
217 | 262 | |
| 263 | + /** |
| 264 | + * @param $emptyTags array |
| 265 | + * @return bool |
| 266 | + */ |
218 | 267 | public static function onListDefinedTags( &$emptyTags ) { |
219 | 268 | # This is a pretty awful hack. |
220 | 269 | $dbr = wfGetDB( DB_SLAVE ); |
— | — | @@ -238,6 +287,7 @@ |
239 | 288 | |
240 | 289 | /** |
241 | 290 | * @param $updater DatabaseUpdater |
| 291 | + * @throws MWException |
242 | 292 | * @return bool |
243 | 293 | */ |
244 | 294 | public static function onLoadExtensionSchemaUpdates( $updater = null ) { |
— | — | @@ -299,11 +349,16 @@ |
300 | 350 | return true; |
301 | 351 | } |
302 | 352 | |
| 353 | + /** |
| 354 | + * @param $id |
| 355 | + * @param $nt Title |
| 356 | + * @param $tools |
| 357 | + * @return bool |
| 358 | + */ |
303 | 359 | public static function onContributionsToolLinks( $id, $nt, &$tools ) { |
304 | 360 | global $wgUser; |
305 | 361 | if ( $wgUser->isAllowed( 'abusefilter-log' ) ) { |
306 | | - $sk = $wgUser->getSkin(); |
307 | | - $tools[] = $sk->link( |
| 362 | + $tools[] = Linker::link( |
308 | 363 | SpecialPage::getTitleFor( 'AbuseLog' ), |
309 | 364 | wfMsg( 'abusefilter-log-linkoncontribs' ), |
310 | 365 | array( 'title' => |
— | — | @@ -314,6 +369,12 @@ |
315 | 370 | return true; |
316 | 371 | } |
317 | 372 | |
| 373 | + /** |
| 374 | + * @param $saveName |
| 375 | + * @param $tempName |
| 376 | + * @param $error |
| 377 | + * @return bool |
| 378 | + */ |
318 | 379 | public static function onUploadVerification( $saveName, $tempName, &$error ) { |
319 | 380 | $vars = new AbuseFilterVariableHolder; |
320 | 381 | |