Index: trunk/extensions/AbuseFilter/AbuseFilter.parser.php |
— | — | @@ -546,6 +546,7 @@ |
547 | 547 | } while ($this->mCur->type == AFPToken::TStatementSeparator); |
548 | 548 | } |
549 | 549 | |
| 550 | + /** Handles multiple expressions */ |
550 | 551 | protected function doLevelSet( &$result ) { |
551 | 552 | if( $this->mCur->type == AFPToken::TID ) { |
552 | 553 | $varname = $this->mCur->value; |
— | — | @@ -565,13 +566,14 @@ |
566 | 567 | } |
567 | 568 | $list = $this->mVars->getVar( $varname ); |
568 | 569 | if( $list->type != AFPData::DList ) |
569 | | - throw new AFPUserVisibleException( 'notlist', $this->mCur->pos, array() ); |
| 570 | + throw new AFPUserVisibleException( 'notlist', $this->mCur->pos, array() ); |
570 | 571 | $list = $list->toList(); |
571 | 572 | $this->move(); |
572 | 573 | if( $this->mCur->type == AFPToken::TSquareBracket && $this->mCur->value == ']' ) { |
573 | 574 | $idx = 'new'; |
574 | 575 | } else { |
575 | | - $this->setState( $prev ); $this->move(); |
| 576 | + $this->setState( $prev ); |
| 577 | + $this->move(); |
576 | 578 | $idx = new AFPData(); |
577 | 579 | $this->doLevelSemicolon( $idx ); |
578 | 580 | $idx = $idx->toInt(); |
Index: trunk/extensions/AbuseFilter/SpecialAbuseLog.php |
— | — | @@ -37,7 +37,7 @@ |
38 | 38 | } |
39 | 39 | |
40 | 40 | $detailsid = $wgRequest->getIntOrNull( 'details' ); |
41 | | - if ($detailsid) { |
| 41 | + if ( $detailsid ) { |
42 | 42 | $this->showDetails( $detailsid ); |
43 | 43 | } else { |
44 | 44 | // Show the search form. |
— | — | @@ -54,13 +54,16 @@ |
55 | 55 | $this->mSearchUser = $wgRequest->getText( 'wpSearchUser' ); |
56 | 56 | |
57 | 57 | $t = Title::newFromText( trim($this->mSearchUser) ); |
58 | | - if ($t) { |
| 58 | + if ( $t ) { |
59 | 59 | $this->mSearchUser = $t->getText(); // Username normalisation |
60 | | - } else $this->mSearchUser = null; |
| 60 | + } else { |
| 61 | + $this->mSearchUser = null; |
| 62 | + } |
61 | 63 | |
62 | 64 | $this->mSearchTitle = $wgRequest->getText( 'wpSearchTitle' ); |
63 | | - if ($this->canSeeDetails()) |
| 65 | + if ( $this->canSeeDetails() ) { |
64 | 66 | $this->mSearchFilter = $wgRequest->getIntOrNull( 'wpSearchFilter' ); |
| 67 | + } |
65 | 68 | } |
66 | 69 | |
67 | 70 | function searchForm() { |
— | — | @@ -96,13 +99,15 @@ |
97 | 100 | // Generate conditions list. |
98 | 101 | $conds = array(); |
99 | 102 | |
100 | | - if (!empty($this->mSearchUser)) |
| 103 | + if ( !empty( $this->mSearchUser ) ) { |
101 | 104 | $conds['afl_user_text'] = $this->mSearchUser; |
102 | | - if (!empty($this->mSearchFilter)) |
| 105 | + } |
| 106 | + if ( !empty( $this->mSearchFilter ) ) { |
103 | 107 | $conds['afl_filter'] = $this->mSearchFilter; |
| 108 | + } |
104 | 109 | |
105 | 110 | $searchTitle = Title::newFromText( $this->mSearchTitle ); |
106 | | - if ($this->mSearchTitle && $searchTitle) { |
| 111 | + if ( $this->mSearchTitle && $searchTitle ) { |
107 | 112 | $conds['afl_namespace'] = $searchTitle->getNamespace(); |
108 | 113 | $conds['afl_title'] = $searchTitle->getDBKey(); |
109 | 114 | } |
— | — | @@ -116,7 +121,7 @@ |
117 | 122 | } |
118 | 123 | |
119 | 124 | function showDetails( $id ) { |
120 | | - if (!$this->canSeeDetails()) { |
| 125 | + if ( !$this->canSeeDetails() ) { |
121 | 126 | return; |
122 | 127 | } |
123 | 128 | |
— | — | @@ -126,8 +131,9 @@ |
127 | 132 | array( 'afl_id' => $id ), __METHOD__, |
128 | 133 | array( 'abuse_filter' => array( 'left join', 'af_id=afl_filter') ) ); |
129 | 134 | |
130 | | - if (!$row) |
| 135 | + if ( !$row ) { |
131 | 136 | return; |
| 137 | + } |
132 | 138 | |
133 | 139 | $output = ''; |
134 | 140 | |
— | — | @@ -177,7 +183,7 @@ |
178 | 184 | // Build a table. |
179 | 185 | $output .= AbuseFilter::buildVarDumpTable( $vars ); |
180 | 186 | |
181 | | - if ($this->canSeePrivate()) { |
| 187 | + if ( $this->canSeePrivate() ) { |
182 | 188 | // Private stuff, like IPs. |
183 | 189 | $header = |
184 | 190 | Xml::element( 'th', null, wfMsg( 'abusefilter-log-details-var' ) ) . |
— | — | @@ -214,8 +220,8 @@ |
215 | 221 | |
216 | 222 | function canSeeDetails() { |
217 | 223 | global $wgUser; |
218 | | - return !count($this->getTitle()->getUserPermissionsErrors( |
219 | | - 'abusefilter-log-detail', $wgUser, true, array( 'ns-specialprotected' ) )); |
| 224 | + return !count( $this->getTitle()->getUserPermissionsErrors( |
| 225 | + 'abusefilter-log-detail', $wgUser, true, array( 'ns-specialprotected' ) ) ); |
220 | 226 | } |
221 | 227 | |
222 | 228 | function canSeePrivate() { |
— | — | @@ -231,19 +237,19 @@ |
232 | 238 | ## One-time setup |
233 | 239 | static $sk=null; |
234 | 240 | |
235 | | - if (is_null($sk)) { |
| 241 | + if ( is_null( $sk ) ) { |
236 | 242 | $sk = $wgUser->getSkin(); |
237 | 243 | } |
238 | 244 | |
239 | 245 | $title = Title::makeTitle( $row->afl_namespace, $row->afl_title ); |
240 | 246 | |
241 | | - if (!$row->afl_wiki) { |
| 247 | + if ( !$row->afl_wiki ) { |
242 | 248 | $pageLink = $sk->link( $title ); |
243 | 249 | } else { |
244 | 250 | $pageLink = WikiMap::makeForeignLink( $row->afl_wiki, $row->afl_title ); |
245 | 251 | } |
246 | 252 | |
247 | | - if (!$row->afl_wiki) { |
| 253 | + if ( !$row->afl_wiki ) { |
248 | 254 | // Local user |
249 | 255 | $user = $sk->userLink( $row->afl_user, $row->afl_user_text ) . |
250 | 256 | $sk->userToolLinks( $row->afl_user, $row->afl_user_text ); |
— | — | @@ -257,10 +263,10 @@ |
258 | 264 | $timestamp = $wgLang->timeanddate( $row->afl_timestamp, true ); |
259 | 265 | |
260 | 266 | $actions_taken = $row->afl_actions; |
261 | | - if ( !strlen( trim( $actions_taken) ) ) { |
| 267 | + if ( !strlen( trim( $actions_taken ) ) ) { |
262 | 268 | $actions_taken = wfMsg( 'abusefilter-log-noactions' ); |
263 | 269 | } else { |
264 | | - $actions = explode(',', $actions_taken); |
| 270 | + $actions = explode( ',', $actions_taken ); |
265 | 271 | $displayActions = array(); |
266 | 272 | |
267 | 273 | foreach( $actions as $action ) { |
— | — | @@ -272,7 +278,7 @@ |
273 | 279 | $globalIndex = AbuseFilter::decodeGlobalName( $row->afl_filter ); |
274 | 280 | |
275 | 281 | global $wgOut; |
276 | | - if ($globalIndex) { |
| 282 | + if ( $globalIndex ) { |
277 | 283 | // Pull global filter description |
278 | 284 | $parsed_comments = |
279 | 285 | $wgOut->parseInline( AbuseFilter::getGlobalFilterDescription( $globalIndex ) ); |
— | — | @@ -280,7 +286,7 @@ |
281 | 287 | $parsed_comments = $wgOut->parseInline( $row->af_public_comments ); |
282 | 288 | } |
283 | 289 | |
284 | | - if ($this->canSeeDetails()) { |
| 290 | + if ( $this->canSeeDetails() ) { |
285 | 291 | $examineTitle = SpecialPage::getTitleFor( 'AbuseFilter', "examine/log/".$row->afl_id ); |
286 | 292 | $detailsLink = $sk->makeKnownLinkObj( |
287 | 293 | $this->getTitle(), |
— | — | @@ -291,7 +297,7 @@ |
292 | 298 | wfMsgExt( 'abusefilter-changeslist-examine', 'parseinline' ), |
293 | 299 | array() ); |
294 | 300 | |
295 | | - if ($globalIndex) { |
| 301 | + if ( $globalIndex ) { |
296 | 302 | global $wgAbuseFilterCentralDB; |
297 | 303 | $globalURL = |
298 | 304 | WikiMap::getForeignURL( $wgAbuseFilterCentralDB, |
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewEdit.php |
— | — | @@ -22,7 +22,7 @@ |
23 | 23 | $didEdit = $this->canEdit() |
24 | 24 | && $wgUser->matchEditToken( $editToken, array( 'abusefilter', $filter ) ); |
25 | 25 | |
26 | | - if ($didEdit) { |
| 26 | + if ( $didEdit ) { |
27 | 27 | // Check syntax |
28 | 28 | $syntaxerr = AbuseFilter::checkSyntax( $wgRequest->getVal( 'wpFilterRules' ) ); |
29 | 29 | if ($syntaxerr !== true ) { |
Index: trunk/extensions/AbuseFilter/AbuseFilterVariableHolder.php |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | |
8 | 8 | function setVar( $variable, $datum ) { |
9 | 9 | $variable = strtolower( $variable ); |
10 | | - if (!( $datum instanceof AFPData || $datum instanceof AFComputedVariable ) ) { |
| 10 | + if ( !( $datum instanceof AFPData || $datum instanceof AFComputedVariable ) ) { |
11 | 11 | $datum = AFPData::newFromPHPVar( $datum ); |
12 | 12 | } |
13 | 13 | |
— | — | @@ -20,15 +20,14 @@ |
21 | 21 | |
22 | 22 | function getVar( $variable ) { |
23 | 23 | $variable = strtolower( $variable ); |
24 | | - if ( isset($this->mVars[$variable]) ) { |
25 | | - |
26 | | - if ($this->mVars[$variable] instanceof AFComputedVariable) { |
| 24 | + if ( isset( $this->mVars[$variable] ) ) { |
| 25 | + if ( $this->mVars[$variable] instanceof AFComputedVariable ) { |
27 | 26 | $value = $this->mVars[$variable]->compute( $this ); |
28 | 27 | $this->setVar( $variable, $value ); |
29 | | - |
30 | 28 | return $value; |
31 | | - } elseif ($this->mVars[$variable] instanceof AFPData) |
| 29 | + } elseif ( $this->mVars[$variable] instanceof AFPData ) { |
32 | 30 | return $this->mVars[$variable]; |
| 31 | + } |
33 | 32 | } else { |
34 | 33 | return new AFPData(); |
35 | 34 | } |
— | — | @@ -45,8 +44,9 @@ |
46 | 45 | } |
47 | 46 | |
48 | 47 | function addHolder( $addHolder ) { |
49 | | - if ( !is_object($addHolder) ) |
| 48 | + if ( !is_object( $addHolder ) ) { |
50 | 49 | throw new MWException( "Invalid argument to AbuseFilterVariableHolder::addHolder" ); |
| 50 | + } |
51 | 51 | $this->mVars = array_merge( $this->mVars, $addHolder->mVars ); |
52 | 52 | } |
53 | 53 | |
— | — | @@ -60,8 +60,9 @@ |
61 | 61 | $exported = array(); |
62 | 62 | |
63 | 63 | foreach( $allVarNames as $varName ) { |
64 | | - if (!in_array( $varName, self::$varBlacklist ) ) |
| 64 | + if ( !in_array( $varName, self::$varBlacklist ) ) { |
65 | 65 | $exported[$varName] = $this->getVar( $varName )->toString(); |
| 66 | + } |
66 | 67 | } |
67 | 68 | |
68 | 69 | return $exported; |
— | — | @@ -80,7 +81,7 @@ |
81 | 82 | 'revision-text-by-timestamp' ); |
82 | 83 | |
83 | 84 | foreach( $this->mVars as $name => $value ) { |
84 | | - if ($value instanceof AFComputedVariable && |
| 85 | + if ( $value instanceof AFComputedVariable && |
85 | 86 | in_array( $value->mMethod, $dbTypes ) ) { |
86 | 87 | $value = $value->compute( $this ); |
87 | 88 | $this->setVar( $name, $value ); |
— | — | @@ -106,8 +107,9 @@ |
107 | 108 | |
108 | 109 | $cacheKey = md5($wikitext).':'.$article->mTitle->getPrefixedText(); |
109 | 110 | |
110 | | - if ( isset( $cache[$cacheKey] ) ) |
| 111 | + if ( isset( $cache[$cacheKey] ) ) { |
111 | 112 | return $cache[$cacheKey]; |
| 113 | + } |
112 | 114 | |
113 | 115 | global $wgParser; |
114 | 116 | $edit = (object)array(); |
— | — | @@ -120,15 +122,17 @@ |
121 | 123 | } |
122 | 124 | |
123 | 125 | static function userObjectFromName( $username ) { |
124 | | - if ( isset( self::$userCache[$username] ) ) |
| 126 | + if ( isset( self::$userCache[$username] ) ) { |
125 | 127 | return self::$userCache[$username]; |
| 128 | + } |
126 | 129 | |
127 | 130 | wfDebug( "Couldn't find user $username in cache\n" ); |
128 | 131 | |
129 | | - if (IP::isIPAddress( $username )) { |
| 132 | + if ( IP::isIPAddress( $username ) ) { |
130 | 133 | $u = new User; |
131 | 134 | $u->setName( $username ); |
132 | | - return self::$userCache[$username] = $u; |
| 135 | + self::$userCache[$username] = $u; |
| 136 | + return $u; |
133 | 137 | } |
134 | 138 | |
135 | 139 | $user = User::newFromName( $username ); |
— | — | @@ -139,8 +143,9 @@ |
140 | 144 | } |
141 | 145 | |
142 | 146 | static function articleFromTitle( $namespace, $title ) { |
143 | | - if ( isset( self::$articleCache["$namespace:$title"] ) ) |
| 147 | + if ( isset( self::$articleCache["$namespace:$title"] ) ) { |
144 | 148 | return self::$articleCache["$namespace:$title"]; |
| 149 | + } |
145 | 150 | |
146 | 151 | wfDebug( "Creating article object for $namespace:$title in cache\n" ); |
147 | 152 | |
— | — | @@ -153,7 +158,9 @@ |
154 | 159 | static function getLinksFromDB( $article ) { |
155 | 160 | // Stolen from ConfirmEdit |
156 | 161 | $id = $article->getId(); |
157 | | - if (!$id) return array(); |
| 162 | + if ( !$id ) { |
| 163 | + return array(); |
| 164 | + } |
158 | 165 | |
159 | 166 | $dbr = wfGetDB( DB_SLAVE ); |
160 | 167 | $res = $dbr->select( 'externallinks', array( 'el_to' ), |
— | — | @@ -260,7 +267,7 @@ |
261 | 268 | $textVar = $parameters['wikitext-var']; |
262 | 269 | |
263 | 270 | $text = $vars->getVar( $textVar )->toString(); |
264 | | - $editInfo = $this->parseNonEditWIkitext( $text, $article ); |
| 271 | + $editInfo = $this->parseNonEditWikitext( $text, $article ); |
265 | 272 | |
266 | 273 | $result = $editInfo->output->getText(); |
267 | 274 | break; |