Index: trunk/phase3/includes/Categoryfinder.php |
— | — | @@ -22,7 +22,6 @@ |
23 | 23 | * |
24 | 24 | */ |
25 | 25 | class Categoryfinder { |
26 | | - |
27 | 26 | var $articles = array(); # The original article IDs passed to the seed function |
28 | 27 | var $deadend = array(); # Array of DBKEY category names for categories that don't have a page |
29 | 28 | var $parents = array(); # Array of [ID => array()] |
— | — | @@ -53,7 +52,7 @@ |
54 | 53 | $this->targets = array(); |
55 | 54 | foreach ( $categories as $c ) { |
56 | 55 | $ct = Title::makeTitleSafe( NS_CATEGORY, $c ); |
57 | | - if( $ct ) { |
| 56 | + if ( $ct ) { |
58 | 57 | $c = $ct->getDBkey(); |
59 | 58 | $this->targets[$c] = $c; |
60 | 59 | } |
— | — | @@ -73,6 +72,7 @@ |
74 | 73 | |
75 | 74 | # Now check if this applies to the individual articles |
76 | 75 | $ret = array(); |
| 76 | + |
77 | 77 | foreach ( $this->articles as $article ) { |
78 | 78 | $conds = $this->targets; |
79 | 79 | if ( $this->check( $article, $conds ) ) { |
— | — | @@ -92,14 +92,20 @@ |
93 | 93 | */ |
94 | 94 | function check( $id , &$conds, $path = array() ) { |
95 | 95 | // Check for loops and stop! |
96 | | - if( in_array( $id, $path ) ) |
| 96 | + if ( in_array( $id, $path ) ) { |
97 | 97 | return false; |
| 98 | + } |
| 99 | + |
98 | 100 | $path[] = $id; |
99 | 101 | |
100 | 102 | # Shortcut (runtime paranoia): No contitions=all matched |
101 | | - if ( count( $conds ) == 0 ) return true; |
| 103 | + if ( count( $conds ) == 0 ) { |
| 104 | + return true; |
| 105 | + } |
102 | 106 | |
103 | | - if ( !isset( $this->parents[$id] ) ) return false; |
| 107 | + if ( !isset( $this->parents[$id] ) ) { |
| 108 | + return false; |
| 109 | + } |
104 | 110 | |
105 | 111 | # iterate through the parents |
106 | 112 | foreach ( $this->parents[$id] as $p ) { |
— | — | @@ -127,7 +133,7 @@ |
128 | 134 | # No sub-parent |
129 | 135 | continue ; |
130 | 136 | } |
131 | | - $done = $this->check( $this->name2id[$pname], $conds,$path ); |
| 137 | + $done = $this->check( $this->name2id[$pname], $conds, $path ); |
132 | 138 | if ( $done || count( $conds ) == 0 ) { |
133 | 139 | # Subparents have done it! |
134 | 140 | return true; |
— | — | @@ -143,10 +149,10 @@ |
144 | 150 | # Find all parents of the article currently in $this->next |
145 | 151 | $layer = array(); |
146 | 152 | $res = $this->dbr->select( |
147 | | - /* FROM */ 'categorylinks', |
148 | | - /* SELECT */ '*', |
149 | | - /* WHERE */ array( 'cl_from' => $this->next ), |
150 | | - __METHOD__ . "-1" |
| 153 | + /* FROM */ 'categorylinks', |
| 154 | + /* SELECT */ '*', |
| 155 | + /* WHERE */ array( 'cl_from' => $this->next ), |
| 156 | + __METHOD__ . "-1" |
151 | 157 | ); |
152 | 158 | while ( $o = $this->dbr->fetchObject( $res ) ) { |
153 | 159 | $k = $o->cl_to ; |
— | — | @@ -159,6 +165,7 @@ |
160 | 166 | |
161 | 167 | # Ignore those we already have |
162 | 168 | if ( in_array ( $k , $this->deadend ) ) continue; |
| 169 | + |
163 | 170 | if ( isset ( $this->name2id[$k] ) ) continue; |
164 | 171 | |
165 | 172 | # Hey, new category! |
— | — | @@ -170,10 +177,10 @@ |
171 | 178 | # Find the IDs of all category pages in $layer, if they exist |
172 | 179 | if ( count ( $layer ) > 0 ) { |
173 | 180 | $res = $this->dbr->select( |
174 | | - /* FROM */ 'page', |
175 | | - /* SELECT */ array( 'page_id', 'page_title' ), |
176 | | - /* WHERE */ array( 'page_namespace' => NS_CATEGORY , 'page_title' => $layer ), |
177 | | - __METHOD__ . "-2" |
| 181 | + /* FROM */ 'page', |
| 182 | + /* SELECT */ array( 'page_id', 'page_title' ), |
| 183 | + /* WHERE */ array( 'page_namespace' => NS_CATEGORY , 'page_title' => $layer ), |
| 184 | + __METHOD__ . "-2" |
178 | 185 | ); |
179 | 186 | while ( $o = $this->dbr->fetchObject( $res ) ) { |
180 | 187 | $id = $o->page_id; |
— | — | @@ -190,4 +197,4 @@ |
191 | 198 | } |
192 | 199 | } |
193 | 200 | |
194 | | -} # END OF CLASS "Categoryfinder" |
| 201 | +} |
Index: trunk/phase3/includes/CategoryPage.php |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | * |
7 | 7 | */ |
8 | 8 | |
9 | | -if( !defined( 'MEDIAWIKI' ) ) |
| 9 | +if ( !defined( 'MEDIAWIKI' ) ) |
10 | 10 | die( 1 ); |
11 | 11 | |
12 | 12 | /** |
— | — | @@ -20,7 +20,7 @@ |
21 | 21 | if ( isset( $diff ) && $diffOnly ) |
22 | 22 | return Article::view(); |
23 | 23 | |
24 | | - if( !wfRunHooks( 'CategoryPageView', array( &$this ) ) ) |
| 24 | + if ( !wfRunHooks( 'CategoryPageView', array( &$this ) ) ) |
25 | 25 | return; |
26 | 26 | |
27 | 27 | if ( NS_CATEGORY == $this->mTitle->getNamespace() ) { |
— | — | @@ -33,18 +33,17 @@ |
34 | 34 | $this->closeShowCategory(); |
35 | 35 | } |
36 | 36 | } |
37 | | - |
| 37 | + |
38 | 38 | /** |
39 | 39 | * Don't return a 404 for categories in use. |
40 | 40 | */ |
41 | 41 | function hasViewableContent() { |
42 | | - if( parent::hasViewableContent() ) { |
| 42 | + if ( parent::hasViewableContent() ) { |
43 | 43 | return true; |
44 | 44 | } else { |
45 | 45 | $cat = Category::newFromTitle( $this->mTitle ); |
46 | 46 | return $cat->getId() != 0; |
47 | 47 | } |
48 | | - |
49 | 48 | } |
50 | 49 | |
51 | 50 | function openShowCategory() { |
— | — | @@ -99,7 +98,7 @@ |
100 | 99 | $this->getPagesSection() . |
101 | 100 | $this->getImageSection(); |
102 | 101 | |
103 | | - if( $r == '' ) { |
| 102 | + if ( $r == '' ) { |
104 | 103 | // If there is no category content to display, only |
105 | 104 | // show the top part of the navigation links. |
106 | 105 | // FIXME: cannot be completely suppressed because it |
— | — | @@ -118,7 +117,7 @@ |
119 | 118 | } |
120 | 119 | |
121 | 120 | wfProfileOut( __METHOD__ ); |
122 | | - return $wgContLang->convert($r); |
| 121 | + return $wgContLang->convert( $r ); |
123 | 122 | } |
124 | 123 | |
125 | 124 | function clearCategoryState() { |
— | — | @@ -126,7 +125,7 @@ |
127 | 126 | $this->articles_start_char = array(); |
128 | 127 | $this->children = array(); |
129 | 128 | $this->children_start_char = array(); |
130 | | - if( $this->showGallery ) { |
| 129 | + if ( $this->showGallery ) { |
131 | 130 | $this->gallery = new ImageGallery(); |
132 | 131 | $this->gallery->setHideBadImages(); |
133 | 132 | } |
— | — | @@ -149,7 +148,7 @@ |
150 | 149 | } |
151 | 150 | |
152 | 151 | /** |
153 | | - * Add a subcategory to the internal lists, using a title object |
| 152 | + * Add a subcategory to the internal lists, using a title object |
154 | 153 | * @deprecated kept for compatibility, please use addSubcategoryObject instead |
155 | 154 | */ |
156 | 155 | function addSubcategory( $title, $sortkey, $pageLength ) { |
— | — | @@ -175,7 +174,7 @@ |
176 | 175 | function getSubcategorySortChar( $title, $sortkey ) { |
177 | 176 | global $wgContLang; |
178 | 177 | |
179 | | - if( $title->getPrefixedText() == $sortkey ) { |
| 178 | + if ( $title->getPrefixedText() == $sortkey ) { |
180 | 179 | $firstChar = $wgContLang->firstChar( $title->getDBkey() ); |
181 | 180 | } else { |
182 | 181 | $firstChar = $wgContLang->firstChar( $sortkey ); |
— | — | @@ -189,7 +188,7 @@ |
190 | 189 | */ |
191 | 190 | function addImage( Title $title, $sortkey, $pageLength, $isRedirect = false ) { |
192 | 191 | if ( $this->showGallery ) { |
193 | | - if( $this->flip ) { |
| 192 | + if ( $this->flip ) { |
194 | 193 | $this->gallery->insert( $title ); |
195 | 194 | } else { |
196 | 195 | $this->gallery->add( $title ); |
— | — | @@ -218,7 +217,7 @@ |
219 | 218 | } |
220 | 219 | |
221 | 220 | function finaliseCategoryState() { |
222 | | - if( $this->flip ) { |
| 221 | + if ( $this->flip ) { |
223 | 222 | $this->children = array_reverse( $this->children ); |
224 | 223 | $this->children_start_char = array_reverse( $this->children_start_char ); |
225 | 224 | $this->articles = array_reverse( $this->articles ); |
— | — | @@ -228,16 +227,17 @@ |
229 | 228 | |
230 | 229 | function doCategoryQuery() { |
231 | 230 | $dbr = wfGetDB( DB_SLAVE, 'category' ); |
232 | | - if( $this->from != '' ) { |
| 231 | + if ( $this->from != '' ) { |
233 | 232 | $pageCondition = 'cl_sortkey >= ' . $dbr->addQuotes( $this->from ); |
234 | 233 | $this->flip = false; |
235 | | - } elseif( $this->until != '' ) { |
| 234 | + } elseif ( $this->until != '' ) { |
236 | 235 | $pageCondition = 'cl_sortkey < ' . $dbr->addQuotes( $this->until ); |
237 | 236 | $this->flip = true; |
238 | 237 | } else { |
239 | 238 | $pageCondition = '1 = 1'; |
240 | 239 | $this->flip = false; |
241 | 240 | } |
| 241 | + |
242 | 242 | $res = $dbr->select( |
243 | 243 | array( 'page', 'categorylinks', 'category' ), |
244 | 244 | array( 'page_title', 'page_namespace', 'page_len', 'page_is_redirect', 'cl_sortkey', |
— | — | @@ -253,8 +253,9 @@ |
254 | 254 | |
255 | 255 | $count = 0; |
256 | 256 | $this->nextPage = null; |
257 | | - while( $x = $dbr->fetchObject ( $res ) ) { |
258 | | - if( ++$count > $this->limit ) { |
| 257 | + |
| 258 | + while ( $x = $dbr->fetchObject ( $res ) ) { |
| 259 | + if ( ++$count > $this->limit ) { |
259 | 260 | // We've reached the one extra which shows that there are |
260 | 261 | // additional pages to be had. Stop here... |
261 | 262 | $this->nextPage = $x->cl_sortkey; |
— | — | @@ -263,10 +264,10 @@ |
264 | 265 | |
265 | 266 | $title = Title::makeTitle( $x->page_namespace, $x->page_title ); |
266 | 267 | |
267 | | - if( $title->getNamespace() == NS_CATEGORY ) { |
| 268 | + if ( $title->getNamespace() == NS_CATEGORY ) { |
268 | 269 | $cat = Category::newFromRow( $x, $title ); |
269 | 270 | $this->addSubcategoryObject( $cat, $x->cl_sortkey, $x->page_len ); |
270 | | - } elseif( $this->showGallery && $title->getNamespace() == NS_FILE ) { |
| 271 | + } elseif ( $this->showGallery && $title->getNamespace() == NS_FILE ) { |
271 | 272 | $this->addImage( $title, $x->cl_sortkey, $x->page_len, $x->page_is_redirect ); |
272 | 273 | } else { |
273 | 274 | $this->addPage( $title, $x->cl_sortkey, $x->page_len, $x->page_is_redirect ); |
— | — | @@ -287,7 +288,8 @@ |
288 | 289 | $rescnt = count( $this->children ); |
289 | 290 | $dbcnt = $this->cat->getSubcatCount(); |
290 | 291 | $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'subcat' ); |
291 | | - if( $rescnt > 0 ) { |
| 292 | + |
| 293 | + if ( $rescnt > 0 ) { |
292 | 294 | # Showing subcategories |
293 | 295 | $r .= "<div id=\"mw-subcategories\">\n"; |
294 | 296 | $r .= '<h2>' . wfMsg( 'subcategories' ) . "</h2>\n"; |
— | — | @@ -312,7 +314,7 @@ |
313 | 315 | $rescnt = count( $this->articles ); |
314 | 316 | $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'article' ); |
315 | 317 | |
316 | | - if( $rescnt > 0 ) { |
| 318 | + if ( $rescnt > 0 ) { |
317 | 319 | $r = "<div id=\"mw-pages\">\n"; |
318 | 320 | $r .= '<h2>' . wfMsg( 'category_header', $ti ) . "</h2>\n"; |
319 | 321 | $r .= $countmsg; |
— | — | @@ -323,7 +325,7 @@ |
324 | 326 | } |
325 | 327 | |
326 | 328 | function getImageSection() { |
327 | | - if( $this->showGallery && ! $this->gallery->isEmpty() ) { |
| 329 | + if ( $this->showGallery && ! $this->gallery->isEmpty() ) { |
328 | 330 | $dbcnt = $this->cat->getFileCount(); |
329 | 331 | $rescnt = $this->gallery->count(); |
330 | 332 | $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'file' ); |
— | — | @@ -337,9 +339,9 @@ |
338 | 340 | } |
339 | 341 | |
340 | 342 | function getCategoryBottom() { |
341 | | - if( $this->until != '' ) { |
| 343 | + if ( $this->until != '' ) { |
342 | 344 | return $this->pagingLinks( $this->title, $this->nextPage, $this->until, $this->limit ); |
343 | | - } elseif( $this->nextPage != '' || $this->from != '' ) { |
| 345 | + } elseif ( $this->nextPage != '' || $this->from != '' ) { |
344 | 346 | return $this->pagingLinks( $this->title, $this->from, $this->nextPage, $this->limit ); |
345 | 347 | } else { |
346 | 348 | return ''; |
— | — | @@ -359,7 +361,7 @@ |
360 | 362 | function formatList( $articles, $articles_start_char, $cutoff = 6 ) { |
361 | 363 | if ( count ( $articles ) > $cutoff ) { |
362 | 364 | return $this->columnList( $articles, $articles_start_char ); |
363 | | - } elseif ( count($articles) > 0) { |
| 365 | + } elseif ( count( $articles ) > 0 ) { |
364 | 366 | // for short lists of articles in categories. |
365 | 367 | return $this->shortList( $articles, $articles_start_char ); |
366 | 368 | } |
— | — | @@ -384,7 +386,7 @@ |
385 | 387 | function columnList( $articles, $articles_start_char ) { |
386 | 388 | $columns = array_combine( $articles, $articles_start_char ); |
387 | 389 | # Split into three columns |
388 | | - $columns = array_chunk( $columns, ceil( count( $columns )/3 ), true /* preserve keys */ ); |
| 390 | + $columns = array_chunk( $columns, ceil( count( $columns ) / 3 ), true /* preserve keys */ ); |
389 | 391 | |
390 | 392 | $ret = '<table width="100%"><tr valign="top"><td>'; |
391 | 393 | $prevchar = null; |
— | — | @@ -435,10 +437,10 @@ |
436 | 438 | */ |
437 | 439 | function shortList( $articles, $articles_start_char ) { |
438 | 440 | $r = '<h3>' . htmlspecialchars( $articles_start_char[0] ) . "</h3>\n"; |
439 | | - $r .= '<ul><li>'.$articles[0].'</li>'; |
440 | | - for ($index = 1; $index < count($articles); $index++ ) |
| 441 | + $r .= '<ul><li>' . $articles[0] . '</li>'; |
| 442 | + for ( $index = 1; $index < count( $articles ); $index++ ) |
441 | 443 | { |
442 | | - if ($articles_start_char[$index] != $articles_start_char[$index - 1]) |
| 444 | + if ( $articles_start_char[$index] != $articles_start_char[$index - 1] ) |
443 | 445 | { |
444 | 446 | $r .= "</ul><h3>" . htmlspecialchars( $articles_start_char[$index] ) . "</h3>\n<ul>"; |
445 | 447 | } |
— | — | @@ -464,7 +466,8 @@ |
465 | 467 | $limitText = $wgLang->formatNum( $limit ); |
466 | 468 | |
467 | 469 | $prevLink = wfMsgExt( 'prevn', array( 'escape', 'parsemag' ), $limitText ); |
468 | | - if( $first != '' ) { |
| 470 | + |
| 471 | + if ( $first != '' ) { |
469 | 472 | $prevQuery = $query; |
470 | 473 | $prevQuery['until'] = $first; |
471 | 474 | $prevLink = $sk->linkKnown( |
— | — | @@ -474,8 +477,10 @@ |
475 | 478 | $prevQuery |
476 | 479 | ); |
477 | 480 | } |
| 481 | + |
478 | 482 | $nextLink = wfMsgExt( 'nextn', array( 'escape', 'parsemag' ), $limitText ); |
479 | | - if( $last != '' ) { |
| 483 | + |
| 484 | + if ( $last != '' ) { |
480 | 485 | $lastQuery = $query; |
481 | 486 | $lastQuery['from'] = $last; |
482 | 487 | $nextLink = $sk->linkKnown( |
— | — | @@ -516,12 +521,14 @@ |
517 | 522 | # know the right figure. |
518 | 523 | # 3) We have no idea. |
519 | 524 | $totalrescnt = count( $this->articles ) + count( $this->children ) + |
520 | | - ($this->showGallery ? $this->gallery->count() : 0); |
521 | | - if($dbcnt == $rescnt || (($totalrescnt == $this->limit || $this->from |
522 | | - || $this->until) && $dbcnt > $rescnt)){ |
| 525 | + ( $this->showGallery ? $this->gallery->count() : 0 ); |
| 526 | + |
| 527 | + if ( $dbcnt == $rescnt || ( ( $totalrescnt == $this->limit || $this->from |
| 528 | + || $this->until ) && $dbcnt > $rescnt ) ) |
| 529 | + { |
523 | 530 | # Case 1: seems sane. |
524 | 531 | $totalcnt = $dbcnt; |
525 | | - } elseif($totalrescnt < $this->limit && !$this->from && !$this->until){ |
| 532 | + } elseif ( $totalrescnt < $this->limit && !$this->from && !$this->until ) { |
526 | 533 | # Case 2: not sane, but salvageable. Use the number of results. |
527 | 534 | # Since there are fewer than 200, we can also take this opportunity |
528 | 535 | # to refresh the incorrect category table entry -- which should be |
— | — | @@ -530,10 +537,14 @@ |
531 | 538 | $this->cat->refreshCounts(); |
532 | 539 | } else { |
533 | 540 | # Case 3: hopeless. Don't give a total count at all. |
534 | | - return wfMsgExt("category-$type-count-limited", 'parse', |
| 541 | + return wfMsgExt( "category-$type-count-limited", 'parse', |
535 | 542 | $wgLang->formatNum( $rescnt ) ); |
536 | 543 | } |
537 | | - return wfMsgExt( "category-$type-count", 'parse', $wgLang->formatNum( $rescnt ), |
538 | | - $wgLang->formatNum( $totalcnt ) ); |
| 544 | + return wfMsgExt( |
| 545 | + "category-$type-count", |
| 546 | + 'parse', |
| 547 | + $wgLang->formatNum( $rescnt ), |
| 548 | + $wgLang->formatNum( $totalcnt ) |
| 549 | + ); |
539 | 550 | } |
540 | 551 | } |
Index: trunk/phase3/includes/BagOStuff.php |
— | — | @@ -54,7 +54,7 @@ |
55 | 55 | abstract public function get( $key ); |
56 | 56 | |
57 | 57 | /** |
58 | | - * Set an item. |
| 58 | + * Set an item. |
59 | 59 | * @param $key string |
60 | 60 | * @param $value mixed |
61 | 61 | * @param $exptime int Either an interval in seconds or a unix timestamp for expiry |
— | — | @@ -87,9 +87,11 @@ |
88 | 88 | /* Better performance can likely be got with custom written versions */ |
89 | 89 | public function get_multi( $keys ) { |
90 | 90 | $out = array(); |
| 91 | + |
91 | 92 | foreach ( $keys as $key ) { |
92 | 93 | $out[$key] = $this->get( $key ); |
93 | 94 | } |
| 95 | + |
94 | 96 | return $out; |
95 | 97 | } |
96 | 98 | |
— | — | @@ -140,7 +142,7 @@ |
141 | 143 | } |
142 | 144 | |
143 | 145 | public function decr( $key, $value = 1 ) { |
144 | | - return $this->incr( $key, -$value ); |
| 146 | + return $this->incr( $key, - $value ); |
145 | 147 | } |
146 | 148 | |
147 | 149 | public function debug( $text ) { |
— | — | @@ -160,7 +162,6 @@ |
161 | 163 | } |
162 | 164 | } |
163 | 165 | |
164 | | - |
165 | 166 | /** |
166 | 167 | * Functional versions! |
167 | 168 | * This is a test of the interface, mainly. It stores things in an associative |
— | — | @@ -254,10 +255,10 @@ |
255 | 256 | $this->debug( "get: key has expired, deleting" ); |
256 | 257 | try { |
257 | 258 | $db->begin(); |
258 | | - # Put the expiry time in the WHERE condition to avoid deleting a |
| 259 | + # Put the expiry time in the WHERE condition to avoid deleting a |
259 | 260 | # newly-inserted value |
260 | | - $db->delete( 'objectcache', |
261 | | - array( |
| 261 | + $db->delete( 'objectcache', |
| 262 | + array( |
262 | 263 | 'keyname' => $key, |
263 | 264 | 'exptime' => $row->exptime |
264 | 265 | ), __METHOD__ ); |
— | — | @@ -284,8 +285,8 @@ |
285 | 286 | try { |
286 | 287 | $db->begin(); |
287 | 288 | $db->delete( 'objectcache', array( 'keyname' => $key ), __METHOD__ ); |
288 | | - $db->insert( 'objectcache', |
289 | | - array( |
| 289 | + $db->insert( 'objectcache', |
| 290 | + array( |
290 | 291 | 'keyname' => $key, |
291 | 292 | 'value' => $db->encodeBlob( $this->serialize( $value ) ), |
292 | 293 | 'exptime' => $encExpiry |
— | — | @@ -458,7 +459,7 @@ |
459 | 460 | /** |
460 | 461 | * Backwards compatibility alias |
461 | 462 | */ |
462 | | -class MediaWikiBagOStuff extends SqlBagOStuff {} |
| 463 | +class MediaWikiBagOStuff extends SqlBagOStuff { } |
463 | 464 | |
464 | 465 | /** |
465 | 466 | * This is a wrapper for Turck MMCache's shared memory functions. |
— | — | @@ -533,14 +534,13 @@ |
534 | 535 | $info = apc_cache_info( 'user' ); |
535 | 536 | $list = $info['cache_list']; |
536 | 537 | $keys = array(); |
537 | | - foreach( $list as $entry ) { |
| 538 | + foreach ( $list as $entry ) { |
538 | 539 | $keys[] = $entry['info']; |
539 | 540 | } |
540 | 541 | return $keys; |
541 | 542 | } |
542 | 543 | } |
543 | 544 | |
544 | | - |
545 | 545 | /** |
546 | 546 | * This is a wrapper for eAccelerator's shared memory functions. |
547 | 547 | * |
— | — | @@ -624,13 +624,12 @@ |
625 | 625 | xcache_unset( $key ); |
626 | 626 | return true; |
627 | 627 | } |
628 | | - |
629 | 628 | } |
630 | 629 | |
631 | 630 | /** |
632 | | - * Cache that uses DBA as a backend. |
633 | | - * Slow due to the need to constantly open and close the file to avoid holding |
634 | | - * writer locks. Intended for development use only, as a memcached workalike |
| 631 | + * Cache that uses DBA as a backend. |
| 632 | + * Slow due to the need to constantly open and close the file to avoid holding |
| 633 | + * writer locks. Intended for development use only, as a memcached workalike |
635 | 634 | * for systems that don't have it. |
636 | 635 | * |
637 | 636 | * @ingroup Cache |
— | — | @@ -669,7 +668,7 @@ |
670 | 669 | return array( |
671 | 670 | unserialize( substr( $blob, 11 ) ), |
672 | 671 | intval( substr( $blob, 0, 10 ) ) |
673 | | - ); |
| 672 | + ); |
674 | 673 | } |
675 | 674 | } |
676 | 675 | |
Index: trunk/phase3/includes/Article.php |
— | — | @@ -16,32 +16,32 @@ |
17 | 17 | /**@{{ |
18 | 18 | * @private |
19 | 19 | */ |
20 | | - var $mComment = ''; //!< |
21 | | - var $mContent; //!< |
22 | | - var $mContentLoaded = false; //!< |
23 | | - var $mCounter = -1; //!< Not loaded |
24 | | - var $mCurID = -1; //!< Not loaded |
25 | | - var $mDataLoaded = false; //!< |
26 | | - var $mForUpdate = false; //!< |
27 | | - var $mGoodAdjustment = 0; //!< |
28 | | - var $mIsRedirect = false; //!< |
29 | | - var $mLatest = false; //!< |
30 | | - var $mMinorEdit; //!< |
31 | | - var $mOldId; //!< |
32 | | - var $mPreparedEdit = false; //!< Title object if set |
33 | | - var $mRedirectedFrom = null; //!< Title object if set |
34 | | - var $mRedirectTarget = null; //!< Title object if set |
35 | | - var $mRedirectUrl = false; //!< |
36 | | - var $mRevIdFetched = 0; //!< |
37 | | - var $mRevision; //!< |
38 | | - var $mTimestamp = ''; //!< |
39 | | - var $mTitle; //!< |
40 | | - var $mTotalAdjustment = 0; //!< |
41 | | - var $mTouched = '19700101000000'; //!< |
42 | | - var $mUser = -1; //!< Not loaded |
43 | | - var $mUserText = ''; //!< |
44 | | - var $mParserOptions; //!< |
45 | | - var $mParserOutput; //!< |
| 20 | + var $mComment = ''; // !< |
| 21 | + var $mContent; // !< |
| 22 | + var $mContentLoaded = false; // !< |
| 23 | + var $mCounter = -1; // !< Not loaded |
| 24 | + var $mCurID = -1; // !< Not loaded |
| 25 | + var $mDataLoaded = false; // !< |
| 26 | + var $mForUpdate = false; // !< |
| 27 | + var $mGoodAdjustment = 0; // !< |
| 28 | + var $mIsRedirect = false; // !< |
| 29 | + var $mLatest = false; // !< |
| 30 | + var $mMinorEdit; // !< |
| 31 | + var $mOldId; // !< |
| 32 | + var $mPreparedEdit = false; // !< Title object if set |
| 33 | + var $mRedirectedFrom = null; // !< Title object if set |
| 34 | + var $mRedirectTarget = null; // !< Title object if set |
| 35 | + var $mRedirectUrl = false; // !< |
| 36 | + var $mRevIdFetched = 0; // !< |
| 37 | + var $mRevision; // !< |
| 38 | + var $mTimestamp = ''; // !< |
| 39 | + var $mTitle; // !< |
| 40 | + var $mTotalAdjustment = 0; // !< |
| 41 | + var $mTouched = '19700101000000'; // !< |
| 42 | + var $mUser = -1; // !< Not loaded |
| 43 | + var $mUserText = ''; // !< |
| 44 | + var $mParserOptions; // !< |
| 45 | + var $mParserOutput; // !< |
46 | 46 | /**@}}*/ |
47 | 47 | |
48 | 48 | /** |
— | — | @@ -62,7 +62,7 @@ |
63 | 63 | $t = Title::newFromID( $id ); |
64 | 64 | # FIXME: doesn't inherit right |
65 | 65 | return $t == null ? null : new self( $t ); |
66 | | - #return $t == null ? null : new static( $t ); // PHP 5.3 |
| 66 | + # return $t == null ? null : new static( $t ); // PHP 5.3 |
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
— | — | @@ -82,19 +82,19 @@ |
83 | 83 | * @return mixed Title object, or null if this page is not a redirect |
84 | 84 | */ |
85 | 85 | public function getRedirectTarget() { |
86 | | - if( !$this->mTitle || !$this->mTitle->isRedirect() ) |
| 86 | + if ( !$this->mTitle || !$this->mTitle->isRedirect() ) |
87 | 87 | return null; |
88 | | - if( !is_null($this->mRedirectTarget) ) |
| 88 | + if ( !is_null( $this->mRedirectTarget ) ) |
89 | 89 | return $this->mRedirectTarget; |
90 | 90 | # Query the redirect table |
91 | 91 | $dbr = wfGetDB( DB_SLAVE ); |
92 | 92 | $row = $dbr->selectRow( 'redirect', |
93 | | - array('rd_namespace', 'rd_title'), |
94 | | - array('rd_from' => $this->getID() ), |
| 93 | + array( 'rd_namespace', 'rd_title' ), |
| 94 | + array( 'rd_from' => $this->getID() ), |
95 | 95 | __METHOD__ |
96 | 96 | ); |
97 | | - if( $row ) { |
98 | | - return $this->mRedirectTarget = Title::makeTitle($row->rd_namespace, $row->rd_title); |
| 97 | + if ( $row ) { |
| 98 | + return $this->mRedirectTarget = Title::makeTitle( $row->rd_namespace, $row->rd_title ); |
99 | 99 | } |
100 | 100 | # This page doesn't have an entry in the redirect table |
101 | 101 | return $this->mRedirectTarget = $this->insertRedirect(); |
— | — | @@ -108,11 +108,11 @@ |
109 | 109 | */ |
110 | 110 | public function insertRedirect() { |
111 | 111 | $retval = Title::newFromRedirect( $this->getContent() ); |
112 | | - if( !$retval ) { |
| 112 | + if ( !$retval ) { |
113 | 113 | return null; |
114 | 114 | } |
115 | 115 | $dbw = wfGetDB( DB_MASTER ); |
116 | | - $dbw->replace( 'redirect', array('rd_from'), |
| 116 | + $dbw->replace( 'redirect', array( 'rd_from' ), |
117 | 117 | array( |
118 | 118 | 'rd_from' => $this->getID(), |
119 | 119 | 'rd_namespace' => $retval->getNamespace(), |
— | — | @@ -141,9 +141,9 @@ |
142 | 142 | public function followRedirectText( $text ) { |
143 | 143 | $rt = Title::newFromRedirectRecurse( $text ); // recurse through to only get the final target |
144 | 144 | # process if title object is valid and not special:userlogout |
145 | | - if( $rt ) { |
146 | | - if( $rt->getInterwiki() != '' ) { |
147 | | - if( $rt->isLocal() ) { |
| 145 | + if ( $rt ) { |
| 146 | + if ( $rt->getInterwiki() != '' ) { |
| 147 | + if ( $rt->isLocal() ) { |
148 | 148 | // Offsite wikis need an HTTP redirect. |
149 | 149 | // |
150 | 150 | // This can be hard to reverse and may produce loops, |
— | — | @@ -152,13 +152,13 @@ |
153 | 153 | return $rt->getFullURL( 'rdfrom=' . urlencode( $source ) ); |
154 | 154 | } |
155 | 155 | } else { |
156 | | - if( $rt->getNamespace() == NS_SPECIAL ) { |
| 156 | + if ( $rt->getNamespace() == NS_SPECIAL ) { |
157 | 157 | // Gotta handle redirects to special pages differently: |
158 | 158 | // Fill the HTTP response "Location" header and ignore |
159 | 159 | // the rest of the page we're on. |
160 | 160 | // |
161 | 161 | // This can be hard to reverse, so they may be disabled. |
162 | | - if( $rt->isSpecial( 'Userlogout' ) ) { |
| 162 | + if ( $rt->isSpecial( 'Userlogout' ) ) { |
163 | 163 | // rolleyes |
164 | 164 | } else { |
165 | 165 | return $rt->getFullURL(); |
— | — | @@ -211,15 +211,15 @@ |
212 | 212 | public function getContent() { |
213 | 213 | global $wgUser, $wgContLang, $wgOut, $wgMessageCache; |
214 | 214 | wfProfileIn( __METHOD__ ); |
215 | | - if( $this->getID() === 0 ) { |
| 215 | + if ( $this->getID() === 0 ) { |
216 | 216 | # If this is a MediaWiki:x message, then load the messages |
217 | 217 | # and return the message value for x. |
218 | | - if( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
| 218 | + if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
219 | 219 | # If this is a system message, get the default text. |
220 | 220 | list( $message, $lang ) = $wgMessageCache->figureMessage( $wgContLang->lcfirst( $this->mTitle->getText() ) ); |
221 | 221 | $wgMessageCache->loadAllMessages( $lang ); |
222 | 222 | $text = wfMsgGetKey( $message, false, $lang, false ); |
223 | | - if( wfEmptyMsg( $message, $text ) ) |
| 223 | + if ( wfEmptyMsg( $message, $text ) ) |
224 | 224 | $text = ''; |
225 | 225 | } else { |
226 | 226 | $text = wfMsgExt( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon', 'parsemag' ); |
— | — | @@ -240,7 +240,7 @@ |
241 | 241 | */ |
242 | 242 | public function getRawText() { |
243 | 243 | // Check process cache for current revision |
244 | | - if( $this->mContentLoaded && $this->mOldId == 0 ) { |
| 244 | + if ( $this->mContentLoaded && $this->mOldId == 0 ) { |
245 | 245 | return $this->mContent; |
246 | 246 | } |
247 | 247 | $rev = Revision::newFromTitle( $this->mTitle ); |
— | — | @@ -292,7 +292,7 @@ |
293 | 293 | * current revision |
294 | 294 | */ |
295 | 295 | public function getOldID() { |
296 | | - if( is_null( $this->mOldId ) ) { |
| 296 | + if ( is_null( $this->mOldId ) ) { |
297 | 297 | $this->mOldId = $this->getOldIDFromRequest(); |
298 | 298 | } |
299 | 299 | return $this->mOldId; |
— | — | @@ -307,23 +307,23 @@ |
308 | 308 | global $wgRequest; |
309 | 309 | $this->mRedirectUrl = false; |
310 | 310 | $oldid = $wgRequest->getVal( 'oldid' ); |
311 | | - if( isset( $oldid ) ) { |
| 311 | + if ( isset( $oldid ) ) { |
312 | 312 | $oldid = intval( $oldid ); |
313 | | - if( $wgRequest->getVal( 'direction' ) == 'next' ) { |
| 313 | + if ( $wgRequest->getVal( 'direction' ) == 'next' ) { |
314 | 314 | $nextid = $this->mTitle->getNextRevisionID( $oldid ); |
315 | | - if( $nextid ) { |
| 315 | + if ( $nextid ) { |
316 | 316 | $oldid = $nextid; |
317 | 317 | } else { |
318 | 318 | $this->mRedirectUrl = $this->mTitle->getFullURL( 'redirect=no' ); |
319 | 319 | } |
320 | | - } elseif( $wgRequest->getVal( 'direction' ) == 'prev' ) { |
| 320 | + } elseif ( $wgRequest->getVal( 'direction' ) == 'prev' ) { |
321 | 321 | $previd = $this->mTitle->getPreviousRevisionID( $oldid ); |
322 | | - if( $previd ) { |
| 322 | + if ( $previd ) { |
323 | 323 | $oldid = $previd; |
324 | 324 | } |
325 | 325 | } |
326 | 326 | } |
327 | | - if( !$oldid ) { |
| 327 | + if ( !$oldid ) { |
328 | 328 | $oldid = 0; |
329 | 329 | } |
330 | 330 | return $oldid; |
— | — | @@ -333,7 +333,7 @@ |
334 | 334 | * Load the revision (including text) into this object |
335 | 335 | */ |
336 | 336 | function loadContent() { |
337 | | - if( $this->mContentLoaded ) return; |
| 337 | + if ( $this->mContentLoaded ) return; |
338 | 338 | wfProfileIn( __METHOD__ ); |
339 | 339 | # Query variables :P |
340 | 340 | $oldid = $this->getOldID(); |
— | — | @@ -400,13 +400,13 @@ |
401 | 401 | * @param $data Database row object or "fromdb" |
402 | 402 | */ |
403 | 403 | public function loadPageData( $data = 'fromdb' ) { |
404 | | - if( $data === 'fromdb' ) { |
| 404 | + if ( $data === 'fromdb' ) { |
405 | 405 | $dbr = wfGetDB( DB_MASTER ); |
406 | 406 | $data = $this->pageDataFromId( $dbr, $this->getId() ); |
407 | 407 | } |
408 | 408 | |
409 | 409 | $lc = LinkCache::singleton(); |
410 | | - if( $data ) { |
| 410 | + if ( $data ) { |
411 | 411 | $lc->addGoodLinkObj( $data->page_id, $this->mTitle, $data->page_len, $data->page_is_redirect ); |
412 | 412 | |
413 | 413 | $this->mTitle->mArticleID = intval( $data->page_id ); |
— | — | @@ -419,7 +419,7 @@ |
420 | 420 | $this->mIsRedirect = intval( $data->page_is_redirect ); |
421 | 421 | $this->mLatest = intval( $data->page_latest ); |
422 | 422 | } else { |
423 | | - if( is_object( $this->mTitle ) ) { |
| 423 | + if ( is_object( $this->mTitle ) ) { |
424 | 424 | $lc->addBadLinkObj( $this->mTitle ); |
425 | 425 | } |
426 | 426 | $this->mTitle->mArticleID = 0; |
— | — | @@ -435,7 +435,7 @@ |
436 | 436 | * @return string |
437 | 437 | */ |
438 | 438 | function fetchContent( $oldid = 0 ) { |
439 | | - if( $this->mContentLoaded ) { |
| 439 | + if ( $this->mContentLoaded ) { |
440 | 440 | return $this->mContent; |
441 | 441 | } |
442 | 442 | |
— | — | @@ -447,31 +447,31 @@ |
448 | 448 | $d = $oldid ? wfMsgExt( 'missingarticle-rev', array( 'escape' ), $oldid ) : ''; |
449 | 449 | $this->mContent = wfMsgNoTrans( 'missing-article', $t, $d ) ; |
450 | 450 | |
451 | | - if( $oldid ) { |
| 451 | + if ( $oldid ) { |
452 | 452 | $revision = Revision::newFromId( $oldid ); |
453 | | - if( is_null( $revision ) ) { |
454 | | - wfDebug( __METHOD__." failed to retrieve specified revision, id $oldid\n" ); |
| 453 | + if ( is_null( $revision ) ) { |
| 454 | + wfDebug( __METHOD__ . " failed to retrieve specified revision, id $oldid\n" ); |
455 | 455 | return false; |
456 | 456 | } |
457 | 457 | $data = $this->pageDataFromId( $dbr, $revision->getPage() ); |
458 | | - if( !$data ) { |
459 | | - wfDebug( __METHOD__." failed to get page data linked to revision id $oldid\n" ); |
| 458 | + if ( !$data ) { |
| 459 | + wfDebug( __METHOD__ . " failed to get page data linked to revision id $oldid\n" ); |
460 | 460 | return false; |
461 | 461 | } |
462 | 462 | $this->mTitle = Title::makeTitle( $data->page_namespace, $data->page_title ); |
463 | 463 | $this->loadPageData( $data ); |
464 | 464 | } else { |
465 | | - if( !$this->mDataLoaded ) { |
| 465 | + if ( !$this->mDataLoaded ) { |
466 | 466 | $data = $this->pageDataFromTitle( $dbr, $this->mTitle ); |
467 | | - if( !$data ) { |
468 | | - wfDebug( __METHOD__." failed to find page data for title " . $this->mTitle->getPrefixedText() . "\n" ); |
| 467 | + if ( !$data ) { |
| 468 | + wfDebug( __METHOD__ . " failed to find page data for title " . $this->mTitle->getPrefixedText() . "\n" ); |
469 | 469 | return false; |
470 | 470 | } |
471 | 471 | $this->loadPageData( $data ); |
472 | 472 | } |
473 | 473 | $revision = Revision::newFromId( $this->mLatest ); |
474 | | - if( is_null( $revision ) ) { |
475 | | - wfDebug( __METHOD__." failed to retrieve current page, rev_id {$this->mLatest}\n" ); |
| 474 | + if ( is_null( $revision ) ) { |
| 475 | + wfDebug( __METHOD__ . " failed to retrieve current page, rev_id {$this->mLatest}\n" ); |
476 | 476 | return false; |
477 | 477 | } |
478 | 478 | } |
— | — | @@ -522,8 +522,8 @@ |
523 | 523 | * @return Array: options |
524 | 524 | */ |
525 | 525 | protected function getSelectOptions( $options = '' ) { |
526 | | - if( $this->mForUpdate ) { |
527 | | - if( is_array( $options ) ) { |
| 526 | + if ( $this->mForUpdate ) { |
| 527 | + if ( is_array( $options ) ) { |
528 | 528 | $options[] = 'FOR UPDATE'; |
529 | 529 | } else { |
530 | 530 | $options = 'FOR UPDATE'; |
— | — | @@ -536,7 +536,7 @@ |
537 | 537 | * @return int Page ID |
538 | 538 | */ |
539 | 539 | public function getID() { |
540 | | - if( $this->mTitle ) { |
| 540 | + if ( $this->mTitle ) { |
541 | 541 | return $this->mTitle->getArticleID(); |
542 | 542 | } else { |
543 | 543 | return 0; |
— | — | @@ -566,9 +566,9 @@ |
567 | 567 | * @return int The view count for the page |
568 | 568 | */ |
569 | 569 | public function getCount() { |
570 | | - if( -1 == $this->mCounter ) { |
| 570 | + if ( -1 == $this->mCounter ) { |
571 | 571 | $id = $this->getID(); |
572 | | - if( $id == 0 ) { |
| 572 | + if ( $id == 0 ) { |
573 | 573 | $this->mCounter = 0; |
574 | 574 | } else { |
575 | 575 | $dbr = wfGetDB( DB_SLAVE ); |
— | — | @@ -594,7 +594,7 @@ |
595 | 595 | global $wgUseCommaCount; |
596 | 596 | |
597 | 597 | $token = $wgUseCommaCount ? ',' : '[['; |
598 | | - return $this->mTitle->isContentPage() && !$this->isRedirect($text) && in_string($token,$text); |
| 598 | + return $this->mTitle->isContentPage() && !$this->isRedirect( $text ) && in_string( $token, $text ); |
599 | 599 | } |
600 | 600 | |
601 | 601 | /** |
— | — | @@ -604,8 +604,8 @@ |
605 | 605 | * @return bool |
606 | 606 | */ |
607 | 607 | public function isRedirect( $text = false ) { |
608 | | - if( $text === false ) { |
609 | | - if( $this->mDataLoaded ) { |
| 608 | + if ( $text === false ) { |
| 609 | + if ( $this->mDataLoaded ) { |
610 | 610 | return $this->mIsRedirect; |
611 | 611 | } |
612 | 612 | // Apparently loadPageData was never called |
— | — | @@ -624,10 +624,10 @@ |
625 | 625 | */ |
626 | 626 | public function isCurrent() { |
627 | 627 | # If no oldid, this is the current version. |
628 | | - if( $this->getOldID() == 0 ) { |
| 628 | + if ( $this->getOldID() == 0 ) { |
629 | 629 | return true; |
630 | 630 | } |
631 | | - return $this->exists() && isset($this->mRevision) && $this->mRevision->isCurrent(); |
| 631 | + return $this->exists() && isset( $this->mRevision ) && $this->mRevision->isCurrent(); |
632 | 632 | } |
633 | 633 | |
634 | 634 | /** |
— | — | @@ -635,15 +635,15 @@ |
636 | 636 | * This isn't necessary for all uses, so it's only done if needed. |
637 | 637 | */ |
638 | 638 | protected function loadLastEdit() { |
639 | | - if( -1 != $this->mUser ) |
| 639 | + if ( -1 != $this->mUser ) |
640 | 640 | return; |
641 | 641 | |
642 | 642 | # New or non-existent articles have no user information |
643 | 643 | $id = $this->getID(); |
644 | | - if( 0 == $id ) return; |
| 644 | + if ( 0 == $id ) return; |
645 | 645 | |
646 | 646 | $this->mLastRevision = Revision::loadFromPageId( wfGetDB( DB_MASTER ), $id ); |
647 | | - if( !is_null( $this->mLastRevision ) ) { |
| 647 | + if ( !is_null( $this->mLastRevision ) ) { |
648 | 648 | $this->mUser = $this->mLastRevision->getUser(); |
649 | 649 | $this->mUserText = $this->mLastRevision->getUserText(); |
650 | 650 | $this->mTimestamp = $this->mLastRevision->getTimestamp(); |
— | — | @@ -655,10 +655,10 @@ |
656 | 656 | |
657 | 657 | public function getTimestamp() { |
658 | 658 | // Check if the field has been filled by ParserCache::get() |
659 | | - if( !$this->mTimestamp ) { |
| 659 | + if ( !$this->mTimestamp ) { |
660 | 660 | $this->loadLastEdit(); |
661 | 661 | } |
662 | | - return wfTimestamp(TS_MW, $this->mTimestamp); |
| 662 | + return wfTimestamp( TS_MW, $this->mTimestamp ); |
663 | 663 | } |
664 | 664 | |
665 | 665 | public function getUser() { |
— | — | @@ -691,7 +691,7 @@ |
692 | 692 | * @param $limit Integer: default 0. |
693 | 693 | * @param $offset Integer: default 0. |
694 | 694 | */ |
695 | | - public function getContributors($limit = 0, $offset = 0) { |
| 695 | + public function getContributors( $limit = 0, $offset = 0 ) { |
696 | 696 | # XXX: this is expensive; cache this info somewhere. |
697 | 697 | |
698 | 698 | $dbr = wfGetDB( DB_SLAVE ); |
— | — | @@ -749,19 +749,19 @@ |
750 | 750 | } |
751 | 751 | |
752 | 752 | # Try client and file cache |
753 | | - if( $oldid === 0 && $this->checkTouched() ) { |
| 753 | + if ( $oldid === 0 && $this->checkTouched() ) { |
754 | 754 | global $wgUseETag; |
755 | | - if( $wgUseETag ) { |
| 755 | + if ( $wgUseETag ) { |
756 | 756 | $wgOut->setETag( $parserCache->getETag( $this, $parserOptions ) ); |
757 | 757 | } |
758 | 758 | # Is is client cached? |
759 | | - if( $wgOut->checkLastModified( $this->getTouched() ) ) { |
760 | | - wfDebug( __METHOD__.": done 304\n" ); |
| 759 | + if ( $wgOut->checkLastModified( $this->getTouched() ) ) { |
| 760 | + wfDebug( __METHOD__ . ": done 304\n" ); |
761 | 761 | wfProfileOut( __METHOD__ ); |
762 | 762 | return; |
763 | 763 | # Try file cache |
764 | | - } else if( $wgUseFileCache && $this->tryFileCache() ) { |
765 | | - wfDebug( __METHOD__.": done file cache\n" ); |
| 764 | + } else if ( $wgUseFileCache && $this->tryFileCache() ) { |
| 765 | + wfDebug( __METHOD__ . ": done file cache\n" ); |
766 | 766 | # tell wgOut that output is taken care of |
767 | 767 | $wgOut->disable(); |
768 | 768 | $this->viewUpdates(); |
— | — | @@ -773,9 +773,9 @@ |
774 | 774 | $sk = $wgUser->getSkin(); |
775 | 775 | |
776 | 776 | # getOldID may want us to redirect somewhere else |
777 | | - if( $this->mRedirectUrl ) { |
| 777 | + if ( $this->mRedirectUrl ) { |
778 | 778 | $wgOut->redirect( $this->mRedirectUrl ); |
779 | | - wfDebug( __METHOD__.": redirecting due to oldid\n" ); |
| 779 | + wfDebug( __METHOD__ . ": redirecting due to oldid\n" ); |
780 | 780 | wfProfileOut( __METHOD__ ); |
781 | 781 | return; |
782 | 782 | } |
— | — | @@ -785,8 +785,8 @@ |
786 | 786 | $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); |
787 | 787 | |
788 | 788 | # If we got diff in the query, we want to see a diff page instead of the article. |
789 | | - if( !is_null( $wgRequest->getVal( 'diff' ) ) ) { |
790 | | - wfDebug( __METHOD__.": showing diff page\n" ); |
| 789 | + if ( !is_null( $wgRequest->getVal( 'diff' ) ) ) { |
| 790 | + wfDebug( __METHOD__ . ": showing diff page\n" ); |
791 | 791 | $this->showDiffPage(); |
792 | 792 | wfProfileOut( __METHOD__ ); |
793 | 793 | return; |
— | — | @@ -794,16 +794,16 @@ |
795 | 795 | |
796 | 796 | # Should the parser cache be used? |
797 | 797 | $useParserCache = $this->useParserCache( $oldid ); |
798 | | - wfDebug( 'Article::view using parser cache: ' . ($useParserCache ? 'yes' : 'no' ) . "\n" ); |
799 | | - if( $wgUser->getOption( 'stubthreshold' ) ) { |
| 798 | + wfDebug( 'Article::view using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" ); |
| 799 | + if ( $wgUser->getOption( 'stubthreshold' ) ) { |
800 | 800 | wfIncrStats( 'pcache_miss_stub' ); |
801 | 801 | } |
802 | 802 | |
803 | 803 | # For the main page, overwrite the <title> element with the con- |
804 | 804 | # tents of 'pagetitle-view-mainpage' instead of the default (if |
805 | 805 | # that's not empty). |
806 | | - if( $this->mTitle->equals( Title::newMainPage() ) |
807 | | - && ($m=wfMsgForContent( 'pagetitle-view-mainpage' )) !== '' ) |
| 806 | + if ( $this->mTitle->equals( Title::newMainPage() ) |
| 807 | + && ( $m = wfMsgForContent( 'pagetitle-view-mainpage' ) ) !== '' ) |
808 | 808 | { |
809 | 809 | $wgOut->setHTMLTitle( $m ); |
810 | 810 | } |
— | — | @@ -815,18 +815,18 @@ |
816 | 816 | # Keep going until $outputDone is set, or we run out of things to do. |
817 | 817 | $pass = 0; |
818 | 818 | $outputDone = false; |
819 | | - while( !$outputDone && ++$pass ){ |
820 | | - switch( $pass ){ |
| 819 | + while ( !$outputDone && ++$pass ) { |
| 820 | + switch( $pass ) { |
821 | 821 | case 1: |
822 | 822 | wfRunHooks( 'ArticleViewHeader', array( &$this, &$outputDone, &$useParserCache ) ); |
823 | 823 | break; |
824 | 824 | |
825 | 825 | case 2: |
826 | 826 | # Try the parser cache |
827 | | - if( $useParserCache ) { |
| 827 | + if ( $useParserCache ) { |
828 | 828 | $this->mParserOutput = $parserCache->get( $this, $parserOptions ); |
829 | 829 | if ( $this->mParserOutput !== false ) { |
830 | | - wfDebug( __METHOD__.": showing parser cache contents\n" ); |
| 830 | + wfDebug( __METHOD__ . ": showing parser cache contents\n" ); |
831 | 831 | $wgOut->addParserOutput( $this->mParserOutput ); |
832 | 832 | # Ensure that UI elements requiring revision ID have |
833 | 833 | # the correct version information. |
— | — | @@ -838,16 +838,16 @@ |
839 | 839 | |
840 | 840 | case 3: |
841 | 841 | $text = $this->getContent(); |
842 | | - if( $text === false || $this->getID() == 0 ) { |
843 | | - wfDebug( __METHOD__.": showing missing article\n" ); |
| 842 | + if ( $text === false || $this->getID() == 0 ) { |
| 843 | + wfDebug( __METHOD__ . ": showing missing article\n" ); |
844 | 844 | $this->showMissingArticle(); |
845 | 845 | wfProfileOut( __METHOD__ ); |
846 | 846 | return; |
847 | 847 | } |
848 | 848 | |
849 | 849 | # Another whitelist check in case oldid is altering the title |
850 | | - if( !$this->mTitle->userCanRead() ) { |
851 | | - wfDebug( __METHOD__.": denied on secondary read check\n" ); |
| 850 | + if ( !$this->mTitle->userCanRead() ) { |
| 851 | + wfDebug( __METHOD__ . ": denied on secondary read check\n" ); |
852 | 852 | $wgOut->loginToUse(); |
853 | 853 | $wgOut->output(); |
854 | 854 | $wgOut->disable(); |
— | — | @@ -856,10 +856,10 @@ |
857 | 857 | } |
858 | 858 | |
859 | 859 | # Are we looking at an old revision |
860 | | - if( $oldid && !is_null( $this->mRevision ) ) { |
| 860 | + if ( $oldid && !is_null( $this->mRevision ) ) { |
861 | 861 | $this->setOldSubtitle( $oldid ); |
862 | 862 | if ( !$this->showDeletedRevisionHeader() ) { |
863 | | - wfDebug( __METHOD__.": cannot view deleted revision\n" ); |
| 863 | + wfDebug( __METHOD__ . ": cannot view deleted revision\n" ); |
864 | 864 | wfProfileOut( __METHOD__ ); |
865 | 865 | return; |
866 | 866 | } |
— | — | @@ -867,7 +867,7 @@ |
868 | 868 | if ( $oldid === $this->getLatest() && $this->useParserCache( false ) ) { |
869 | 869 | $this->mParserOutput = $parserCache->get( $this, $parserOptions ); |
870 | 870 | if ( $this->mParserOutput ) { |
871 | | - wfDebug( __METHOD__.": showing parser cache for current rev permalink\n" ); |
| 871 | + wfDebug( __METHOD__ . ": showing parser cache for current rev permalink\n" ); |
872 | 872 | $wgOut->addParserOutput( $this->mParserOutput ); |
873 | 873 | $wgOut->setRevisionId( $this->mLatest ); |
874 | 874 | $this->showViewFooter(); |
— | — | @@ -883,12 +883,12 @@ |
884 | 884 | $wgOut->setRevisionId( $this->getRevIdFetched() ); |
885 | 885 | |
886 | 886 | # Pages containing custom CSS or JavaScript get special treatment |
887 | | - if( $this->mTitle->isCssOrJsPage() || $this->mTitle->isCssJsSubpage() ) { |
888 | | - wfDebug( __METHOD__.": showing CSS/JS source\n" ); |
| 887 | + if ( $this->mTitle->isCssOrJsPage() || $this->mTitle->isCssJsSubpage() ) { |
| 888 | + wfDebug( __METHOD__ . ": showing CSS/JS source\n" ); |
889 | 889 | $this->showCssOrJsPage(); |
890 | 890 | $outputDone = true; |
891 | | - } else if( $rt = Title::newFromRedirectArray( $text ) ) { |
892 | | - wfDebug( __METHOD__.": showing redirect=no page\n" ); |
| 891 | + } else if ( $rt = Title::newFromRedirectArray( $text ) ) { |
| 892 | + wfDebug( __METHOD__ . ": showing redirect=no page\n" ); |
893 | 893 | # Viewing a redirect page (e.g. with parameter redirect=no) |
894 | 894 | # Don't append the subtitle if this was an old revision |
895 | 895 | $wgOut->addHTML( $this->viewRedirect( $rt, !$wasRedirected && $this->isCurrent() ) ); |
— | — | @@ -901,7 +901,7 @@ |
902 | 902 | |
903 | 903 | case 4: |
904 | 904 | # Run the parse, protected by a pool counter |
905 | | - wfDebug( __METHOD__.": doing uncached parse\n" ); |
| 905 | + wfDebug( __METHOD__ . ": doing uncached parse\n" ); |
906 | 906 | $key = $parserCache->getKey( $this, $parserOptions ); |
907 | 907 | $poolCounter = PoolCounter::factory( 'Article::view', $key ); |
908 | 908 | $dirtyCallback = $useParserCache ? array( $this, 'tryDirtyCache' ) : false; |
— | — | @@ -945,7 +945,7 @@ |
946 | 946 | $rcid = $wgRequest->getVal( 'rcid' ); |
947 | 947 | $diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) ); |
948 | 948 | $purge = $wgRequest->getVal( 'action' ) == 'purge'; |
949 | | - $unhide = $wgRequest->getInt('unhide') == 1; |
| 949 | + $unhide = $wgRequest->getInt( 'unhide' ) == 1; |
950 | 950 | $oldid = $this->getOldID(); |
951 | 951 | |
952 | 952 | $de = new DifferenceEngine( $this->mTitle, $oldid, $diff, $rcid, $purge, $unhide ); |
— | — | @@ -955,7 +955,7 @@ |
956 | 956 | |
957 | 957 | // Needed to get the page's current revision |
958 | 958 | $this->loadPageData(); |
959 | | - if( $diff == 0 || $diff == $this->mLatest ) { |
| 959 | + if ( $diff == 0 || $diff == $this->mLatest ) { |
960 | 960 | # Run view updates for current revision only |
961 | 961 | $this->viewUpdates(); |
962 | 962 | } |
— | — | @@ -972,7 +972,7 @@ |
973 | 973 | global $wgOut; |
974 | 974 | $wgOut->addHTML( wfMsgExt( 'clearyourcache', 'parse' ) ); |
975 | 975 | // Give hooks a chance to customise the output |
976 | | - if( wfRunHooks( 'ShowRawCssJs', array( $this->mContent, $this->mTitle, $wgOut ) ) ) { |
| 976 | + if ( wfRunHooks( 'ShowRawCssJs', array( $this->mContent, $this->mTitle, $wgOut ) ) ) { |
977 | 977 | // Wrap the whole lot in a <pre> and don't parse |
978 | 978 | $m = array(); |
979 | 979 | preg_match( '!\.(css|js)$!u', $this->mTitle->getText(), $m ); |
— | — | @@ -1000,32 +1000,32 @@ |
1001 | 1001 | * @return Array the policy that should be set |
1002 | 1002 | * TODO: actions other than 'view' |
1003 | 1003 | */ |
1004 | | - public function getRobotPolicy( $action ){ |
| 1004 | + public function getRobotPolicy( $action ) { |
1005 | 1005 | |
1006 | 1006 | global $wgOut, $wgArticleRobotPolicies, $wgNamespaceRobotPolicies; |
1007 | 1007 | global $wgDefaultRobotPolicy, $wgRequest; |
1008 | 1008 | |
1009 | 1009 | $ns = $this->mTitle->getNamespace(); |
1010 | | - if( $ns == NS_USER || $ns == NS_USER_TALK ) { |
| 1010 | + if ( $ns == NS_USER || $ns == NS_USER_TALK ) { |
1011 | 1011 | # Don't index user and user talk pages for blocked users (bug 11443) |
1012 | | - if( !$this->mTitle->isSubpage() ) { |
| 1012 | + if ( !$this->mTitle->isSubpage() ) { |
1013 | 1013 | $block = new Block(); |
1014 | | - if( $block->load( $this->mTitle->getText() ) ) { |
| 1014 | + if ( $block->load( $this->mTitle->getText() ) ) { |
1015 | 1015 | return array( 'index' => 'noindex', |
1016 | 1016 | 'follow' => 'nofollow' ); |
1017 | 1017 | } |
1018 | 1018 | } |
1019 | 1019 | } |
1020 | 1020 | |
1021 | | - if( $this->getID() === 0 || $this->getOldID() ) { |
| 1021 | + if ( $this->getID() === 0 || $this->getOldID() ) { |
1022 | 1022 | # Non-articles (special pages etc), and old revisions |
1023 | 1023 | return array( 'index' => 'noindex', |
1024 | 1024 | 'follow' => 'nofollow' ); |
1025 | | - } elseif( $wgOut->isPrintable() ) { |
| 1025 | + } elseif ( $wgOut->isPrintable() ) { |
1026 | 1026 | # Discourage indexing of printable versions, but encourage following |
1027 | 1027 | return array( 'index' => 'noindex', |
1028 | 1028 | 'follow' => 'follow' ); |
1029 | | - } elseif( $wgRequest->getInt('curid') ) { |
| 1029 | + } elseif ( $wgRequest->getInt( 'curid' ) ) { |
1030 | 1030 | # For ?curid=x urls, disallow indexing |
1031 | 1031 | return array( 'index' => 'noindex', |
1032 | 1032 | 'follow' => 'follow' ); |
— | — | @@ -1034,19 +1034,19 @@ |
1035 | 1035 | # Otherwise, construct the policy based on the various config variables. |
1036 | 1036 | $policy = self::formatRobotPolicy( $wgDefaultRobotPolicy ); |
1037 | 1037 | |
1038 | | - if( isset( $wgNamespaceRobotPolicies[$ns] ) ){ |
| 1038 | + if ( isset( $wgNamespaceRobotPolicies[$ns] ) ) { |
1039 | 1039 | # Honour customised robot policies for this namespace |
1040 | 1040 | $policy = array_merge( $policy, |
1041 | 1041 | self::formatRobotPolicy( $wgNamespaceRobotPolicies[$ns] ) ); |
1042 | 1042 | } |
1043 | | - if( $this->mTitle->canUseNoindex() && is_object( $this->mParserOutput ) && $this->mParserOutput->getIndexPolicy() ){ |
| 1043 | + if ( $this->mTitle->canUseNoindex() && is_object( $this->mParserOutput ) && $this->mParserOutput->getIndexPolicy() ) { |
1044 | 1044 | # __INDEX__ and __NOINDEX__ magic words, if allowed. Incorporates |
1045 | 1045 | # a final sanity check that we have really got the parser output. |
1046 | 1046 | $policy = array_merge( $policy, |
1047 | 1047 | array( 'index' => $this->mParserOutput->getIndexPolicy() ) ); |
1048 | 1048 | } |
1049 | 1049 | |
1050 | | - if( isset( $wgArticleRobotPolicies[$this->mTitle->getPrefixedText()] ) ){ |
| 1050 | + if ( isset( $wgArticleRobotPolicies[$this->mTitle->getPrefixedText()] ) ) { |
1051 | 1051 | # (bug 14900) site config can override user-defined __INDEX__ or __NOINDEX__ |
1052 | 1052 | $policy = array_merge( $policy, |
1053 | 1053 | self::formatRobotPolicy( $wgArticleRobotPolicies[$this->mTitle->getPrefixedText()] ) ); |
— | — | @@ -1063,10 +1063,10 @@ |
1064 | 1064 | * to already-converted arrays, converts String. |
1065 | 1065 | * @return associative Array: 'index' => <indexpolicy>, 'follow' => <followpolicy> |
1066 | 1066 | */ |
1067 | | - public static function formatRobotPolicy( $policy ){ |
1068 | | - if( is_array( $policy ) ){ |
| 1067 | + public static function formatRobotPolicy( $policy ) { |
| 1068 | + if ( is_array( $policy ) ) { |
1069 | 1069 | return $policy; |
1070 | | - } elseif( !$policy ){ |
| 1070 | + } elseif ( !$policy ) { |
1071 | 1071 | return array(); |
1072 | 1072 | } |
1073 | 1073 | |
— | — | @@ -1074,10 +1074,10 @@ |
1075 | 1075 | $policy = array_map( 'trim', $policy ); |
1076 | 1076 | |
1077 | 1077 | $arr = array(); |
1078 | | - foreach( $policy as $var ){ |
1079 | | - if( in_array( $var, array('index','noindex') ) ){ |
| 1078 | + foreach ( $policy as $var ) { |
| 1079 | + if ( in_array( $var, array( 'index', 'noindex' ) ) ) { |
1080 | 1080 | $arr['index'] = $var; |
1081 | | - } elseif( in_array( $var, array('follow','nofollow') ) ){ |
| 1081 | + } elseif ( in_array( $var, array( 'follow', 'nofollow' ) ) ) { |
1082 | 1082 | $arr['follow'] = $var; |
1083 | 1083 | } |
1084 | 1084 | } |
— | — | @@ -1094,10 +1094,10 @@ |
1095 | 1095 | |
1096 | 1096 | $rdfrom = $wgRequest->getVal( 'rdfrom' ); |
1097 | 1097 | $sk = $wgUser->getSkin(); |
1098 | | - if( isset( $this->mRedirectedFrom ) ) { |
| 1098 | + if ( isset( $this->mRedirectedFrom ) ) { |
1099 | 1099 | // This is an internally redirected page view. |
1100 | 1100 | // We'll need a backlink to the source page for navigation. |
1101 | | - if( wfRunHooks( 'ArticleViewRedirect', array( &$this ) ) ) { |
| 1101 | + if ( wfRunHooks( 'ArticleViewRedirect', array( &$this ) ) ) { |
1102 | 1102 | $redir = $sk->link( |
1103 | 1103 | $this->mRedirectedFrom, |
1104 | 1104 | null, |
— | — | @@ -1109,7 +1109,7 @@ |
1110 | 1110 | $wgOut->setSubtitle( $s ); |
1111 | 1111 | |
1112 | 1112 | // Set the fragment if one was specified in the redirect |
1113 | | - if( strval( $this->mTitle->getFragment() ) != '' ) { |
| 1113 | + if ( strval( $this->mTitle->getFragment() ) != '' ) { |
1114 | 1114 | $fragment = Xml::escapeJsString( $this->mTitle->getFragmentForURL() ); |
1115 | 1115 | $wgOut->addInlineScript( "redirectToFragment(\"$fragment\");" ); |
1116 | 1116 | } |
— | — | @@ -1120,10 +1120,10 @@ |
1121 | 1121 | ); |
1122 | 1122 | return true; |
1123 | 1123 | } |
1124 | | - } elseif( $rdfrom ) { |
| 1124 | + } elseif ( $rdfrom ) { |
1125 | 1125 | // This is an externally redirected view, from some other wiki. |
1126 | 1126 | // If it was reported from a trusted site, supply a backlink. |
1127 | | - if( $wgRedirectSources && preg_match( $wgRedirectSources, $rdfrom ) ) { |
| 1127 | + if ( $wgRedirectSources && preg_match( $wgRedirectSources, $rdfrom ) ) { |
1128 | 1128 | $redir = $sk->makeExternalLink( $rdfrom, $rdfrom ); |
1129 | 1129 | $s = wfMsgExt( 'redirectedfrom', array( 'parseinline', 'replaceafter' ), $redir ); |
1130 | 1130 | $wgOut->setSubtitle( $s ); |
— | — | @@ -1139,7 +1139,7 @@ |
1140 | 1140 | */ |
1141 | 1141 | public function showNamespaceHeader() { |
1142 | 1142 | global $wgOut; |
1143 | | - if( $this->mTitle->isTalkPage() ) { |
| 1143 | + if ( $this->mTitle->isTalkPage() ) { |
1144 | 1144 | $msg = wfMsgNoTrans( 'talkpageheader' ); |
1145 | 1145 | if ( $msg !== '-' && !wfEmptyMsg( 'talkpageheader', $msg ) ) { |
1146 | 1146 | $wgOut->wrapWikiMsg( "<div class=\"mw-talkpageheader\">\n$1</div>", array( 'talkpageheader' ) ); |
— | — | @@ -1153,8 +1153,8 @@ |
1154 | 1154 | public function showViewFooter() { |
1155 | 1155 | global $wgOut, $wgUseTrackbacks, $wgRequest; |
1156 | 1156 | # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page |
1157 | | - if( $this->mTitle->getNamespace() == NS_USER_TALK && IP::isValid( $this->mTitle->getText() ) ) { |
1158 | | - $wgOut->addWikiMsg('anontalkpagetext'); |
| 1157 | + if ( $this->mTitle->getNamespace() == NS_USER_TALK && IP::isValid( $this->mTitle->getText() ) ) { |
| 1158 | + $wgOut->addWikiMsg( 'anontalkpagetext' ); |
1159 | 1159 | } |
1160 | 1160 | |
1161 | 1161 | # If we have been passed an &rcid= parameter, we want to give the user a |
— | — | @@ -1162,7 +1162,7 @@ |
1163 | 1163 | $this->showPatrolFooter(); |
1164 | 1164 | |
1165 | 1165 | # Trackbacks |
1166 | | - if( $wgUseTrackbacks ) { |
| 1166 | + if ( $wgUseTrackbacks ) { |
1167 | 1167 | $this->addTrackbacks(); |
1168 | 1168 | } |
1169 | 1169 | } |
— | — | @@ -1176,7 +1176,7 @@ |
1177 | 1177 | global $wgOut, $wgRequest, $wgUser; |
1178 | 1178 | $rcid = $wgRequest->getVal( 'rcid' ); |
1179 | 1179 | |
1180 | | - if( !$rcid || !$this->mTitle->exists() || !$this->mTitle->quickUserCan( 'patrol' ) ) { |
| 1180 | + if ( !$rcid || !$this->mTitle->exists() || !$this->mTitle->quickUserCan( 'patrol' ) ) { |
1181 | 1181 | return; |
1182 | 1182 | } |
1183 | 1183 | |
— | — | @@ -1217,7 +1217,7 @@ |
1218 | 1218 | if ( $id == 0 && !$ip ) { # User does not exist |
1219 | 1219 | $wgOut->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1</div>", |
1220 | 1220 | array( 'userpage-userdoesnotexist-view', $rootPart ) ); |
1221 | | - } else if (User::newFromId($id)->isBlocked()) { # Show log extract if the user is currently blocked |
| 1221 | + } else if ( User::newFromId( $id )->isBlocked() ) { # Show log extract if the user is currently blocked |
1222 | 1222 | LogEventsList::showLogExtract( |
1223 | 1223 | $wgOut, |
1224 | 1224 | 'block', |
— | — | @@ -1245,7 +1245,7 @@ |
1246 | 1246 | |
1247 | 1247 | # Show error message |
1248 | 1248 | $oldid = $this->getOldID(); |
1249 | | - if( $oldid ) { |
| 1249 | + if ( $oldid ) { |
1250 | 1250 | $text = wfMsgNoTrans( 'missing-article', |
1251 | 1251 | $this->mTitle->getPrefixedText(), |
1252 | 1252 | wfMsgNoTrans( 'missingarticle-rev', $oldid ) ); |
— | — | @@ -1257,13 +1257,13 @@ |
1258 | 1258 | $editErrors = $this->mTitle->getUserPermissionsErrors( 'edit', $wgUser ); |
1259 | 1259 | $errors = array_merge( $createErrors, $editErrors ); |
1260 | 1260 | |
1261 | | - if ( !count($errors) ) |
| 1261 | + if ( !count( $errors ) ) |
1262 | 1262 | $text = wfMsgNoTrans( 'noarticletext' ); |
1263 | 1263 | else |
1264 | 1264 | $text = wfMsgNoTrans( 'noarticletext-nopermission' ); |
1265 | 1265 | } |
1266 | 1266 | $text = "<div class='noarticletext'>\n$text\n</div>"; |
1267 | | - if( !$this->hasViewableContent() ) { |
| 1267 | + if ( !$this->hasViewableContent() ) { |
1268 | 1268 | // If there's no backing content, send a 404 Not Found |
1269 | 1269 | // for better machine handling of broken links. |
1270 | 1270 | $wgRequest->response()->header( "HTTP/1.x 404 Not Found" ); |
— | — | @@ -1278,24 +1278,24 @@ |
1279 | 1279 | */ |
1280 | 1280 | public function showDeletedRevisionHeader() { |
1281 | 1281 | global $wgOut, $wgRequest; |
1282 | | - if( !$this->mRevision->isDeleted( Revision::DELETED_TEXT ) ) { |
| 1282 | + if ( !$this->mRevision->isDeleted( Revision::DELETED_TEXT ) ) { |
1283 | 1283 | // Not deleted |
1284 | 1284 | return true; |
1285 | 1285 | } |
1286 | 1286 | // If the user is not allowed to see it... |
1287 | | - if( !$this->mRevision->userCan(Revision::DELETED_TEXT) ) { |
| 1287 | + if ( !$this->mRevision->userCan( Revision::DELETED_TEXT ) ) { |
1288 | 1288 | $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1</div>\n", |
1289 | 1289 | 'rev-deleted-text-permission' ); |
1290 | 1290 | return false; |
1291 | 1291 | // If the user needs to confirm that they want to see it... |
1292 | | - } else if( $wgRequest->getInt('unhide') != 1 ) { |
| 1292 | + } else if ( $wgRequest->getInt( 'unhide' ) != 1 ) { |
1293 | 1293 | # Give explanation and add a link to view the revision... |
1294 | 1294 | $oldid = intval( $this->getOldID() ); |
1295 | 1295 | $link = $this->mTitle->getFullUrl( "oldid={$oldid}&unhide=1" ); |
1296 | 1296 | $msg = $this->mRevision->isDeleted( Revision::DELETED_RESTRICTED ) ? |
1297 | 1297 | 'rev-suppressed-text-unhide' : 'rev-deleted-text-unhide'; |
1298 | 1298 | $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1</div>\n", |
1299 | | - array($msg,$link) ); |
| 1299 | + array( $msg, $link ) ); |
1300 | 1300 | return false; |
1301 | 1301 | // We are allowed to see... |
1302 | 1302 | } else { |
— | — | @@ -1349,7 +1349,7 @@ |
1350 | 1350 | $options->setIsPrintable( $wgOut->isPrintable() ); |
1351 | 1351 | $output = $parserCache->getDirty( $this, $options ); |
1352 | 1352 | if ( $output ) { |
1353 | | - wfDebug( __METHOD__.": sending dirty output\n" ); |
| 1353 | + wfDebug( __METHOD__ . ": sending dirty output\n" ); |
1354 | 1354 | wfDebugLog( 'dirty', "dirty output " . $parserCache->getKey( $this, $options ) . "\n" ); |
1355 | 1355 | $wgOut->setSquidMaxage( 0 ); |
1356 | 1356 | $this->mParserOutput = $output; |
— | — | @@ -1358,7 +1358,7 @@ |
1359 | 1359 | return true; |
1360 | 1360 | } else { |
1361 | 1361 | wfDebugLog( 'dirty', "dirty missing\n" ); |
1362 | | - wfDebug( __METHOD__.": no dirty cache\n" ); |
| 1362 | + wfDebug( __METHOD__ . ": no dirty cache\n" ); |
1363 | 1363 | return false; |
1364 | 1364 | } |
1365 | 1365 | } |
— | — | @@ -1388,7 +1388,7 @@ |
1389 | 1389 | public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) { |
1390 | 1390 | global $wgOut, $wgContLang, $wgStylePath, $wgUser; |
1391 | 1391 | # Display redirect |
1392 | | - if( !is_array( $target ) ) { |
| 1392 | + if ( !is_array( $target ) ) { |
1393 | 1393 | $target = array( $target ); |
1394 | 1394 | } |
1395 | 1395 | $imageDir = $wgContLang->getDir(); |
— | — | @@ -1396,13 +1396,13 @@ |
1397 | 1397 | $imageUrl2 = $wgStylePath . '/common/images/nextredirect' . $imageDir . '.png'; |
1398 | 1398 | $alt2 = $wgContLang->isRTL() ? '←' : '→'; // should -> and <- be used instead of entities? |
1399 | 1399 | |
1400 | | - if( $appendSubtitle ) { |
| 1400 | + if ( $appendSubtitle ) { |
1401 | 1401 | $wgOut->appendSubtitle( wfMsgHtml( 'redirectpagesub' ) ); |
1402 | 1402 | } |
1403 | 1403 | $sk = $wgUser->getSkin(); |
1404 | 1404 | // the loop prepends the arrow image before the link, so the first case needs to be outside |
1405 | 1405 | $title = array_shift( $target ); |
1406 | | - if( $forceKnown ) { |
| 1406 | + if ( $forceKnown ) { |
1407 | 1407 | $link = $sk->link( |
1408 | 1408 | $title, |
1409 | 1409 | htmlspecialchars( $title->getFullText() ), |
— | — | @@ -1414,9 +1414,9 @@ |
1415 | 1415 | $link = $sk->link( $title, htmlspecialchars( $title->getFullText() ) ); |
1416 | 1416 | } |
1417 | 1417 | // automatically append redirect=no to each link, since most of them are redirect pages themselves |
1418 | | - foreach( $target as $rt ) { |
1419 | | - if( $forceKnown ) { |
1420 | | - $link .= '<img src="'.$imageUrl2.'" alt="'.$alt2.' " />' |
| 1418 | + foreach ( $target as $rt ) { |
| 1419 | + if ( $forceKnown ) { |
| 1420 | + $link .= '<img src="' . $imageUrl2 . '" alt="' . $alt2 . ' " />' |
1421 | 1421 | . $sk->link( |
1422 | 1422 | $rt, |
1423 | 1423 | htmlspecialchars( $rt->getFullText() ), |
— | — | @@ -1425,12 +1425,12 @@ |
1426 | 1426 | array( 'known', 'noclasses' ) |
1427 | 1427 | ); |
1428 | 1428 | } else { |
1429 | | - $link .= '<img src="'.$imageUrl2.'" alt="'.$alt2.' " />' |
| 1429 | + $link .= '<img src="' . $imageUrl2 . '" alt="' . $alt2 . ' " />' |
1430 | 1430 | . $sk->link( $rt, htmlspecialchars( $rt->getFullText() ) ); |
1431 | 1431 | } |
1432 | 1432 | } |
1433 | | - return '<img src="'.$imageUrl.'" alt="#REDIRECT " />' . |
1434 | | - '<span class="redirectText">'.$link.'</span>'; |
| 1433 | + return '<img src="' . $imageUrl . '" alt="#REDIRECT " />' . |
| 1434 | + '<span class="redirectText">' . $link . '</span>'; |
1435 | 1435 | |
1436 | 1436 | } |
1437 | 1437 | |
— | — | @@ -1438,26 +1438,26 @@ |
1439 | 1439 | global $wgOut, $wgUser; |
1440 | 1440 | $dbr = wfGetDB( DB_SLAVE ); |
1441 | 1441 | $tbs = $dbr->select( 'trackbacks', |
1442 | | - array('tb_id', 'tb_title', 'tb_url', 'tb_ex', 'tb_name'), |
1443 | | - array('tb_page' => $this->getID() ) |
| 1442 | + array( 'tb_id', 'tb_title', 'tb_url', 'tb_ex', 'tb_name' ), |
| 1443 | + array( 'tb_page' => $this->getID() ) |
1444 | 1444 | ); |
1445 | | - if( !$dbr->numRows($tbs) ) return; |
| 1445 | + if ( !$dbr->numRows( $tbs ) ) return; |
1446 | 1446 | |
1447 | 1447 | $tbtext = ""; |
1448 | | - while( $o = $dbr->fetchObject($tbs) ) { |
| 1448 | + while ( $o = $dbr->fetchObject( $tbs ) ) { |
1449 | 1449 | $rmvtxt = ""; |
1450 | | - if( $wgUser->isAllowed( 'trackback' ) ) { |
1451 | | - $delurl = $this->mTitle->getFullURL("action=deletetrackback&tbid=" . |
| 1450 | + if ( $wgUser->isAllowed( 'trackback' ) ) { |
| 1451 | + $delurl = $this->mTitle->getFullURL( "action=deletetrackback&tbid=" . |
1452 | 1452 | $o->tb_id . "&token=" . urlencode( $wgUser->editToken() ) ); |
1453 | 1453 | $rmvtxt = wfMsg( 'trackbackremove', htmlspecialchars( $delurl ) ); |
1454 | 1454 | } |
1455 | 1455 | $tbtext .= "\n"; |
1456 | | - $tbtext .= wfMsg(strlen($o->tb_ex) ? 'trackbackexcerpt' : 'trackback', |
| 1456 | + $tbtext .= wfMsg( strlen( $o->tb_ex ) ? 'trackbackexcerpt' : 'trackback', |
1457 | 1457 | $o->tb_title, |
1458 | 1458 | $o->tb_url, |
1459 | 1459 | $o->tb_ex, |
1460 | 1460 | $o->tb_name, |
1461 | | - $rmvtxt); |
| 1461 | + $rmvtxt ); |
1462 | 1462 | } |
1463 | 1463 | $wgOut->wrapWikiMsg( "<div id='mw_trackbacks'>$1</div>\n", array( 'trackbackbox', $tbtext ) ); |
1464 | 1464 | $this->mTitle->invalidateCache(); |
— | — | @@ -1465,19 +1465,19 @@ |
1466 | 1466 | |
1467 | 1467 | public function deletetrackback() { |
1468 | 1468 | global $wgUser, $wgRequest, $wgOut; |
1469 | | - if( !$wgUser->matchEditToken($wgRequest->getVal('token')) ) { |
| 1469 | + if ( !$wgUser->matchEditToken( $wgRequest->getVal( 'token' ) ) ) { |
1470 | 1470 | $wgOut->addWikiMsg( 'sessionfailure' ); |
1471 | 1471 | return; |
1472 | 1472 | } |
1473 | 1473 | |
1474 | 1474 | $permission_errors = $this->mTitle->getUserPermissionsErrors( 'delete', $wgUser ); |
1475 | | - if( count($permission_errors) ) { |
| 1475 | + if ( count( $permission_errors ) ) { |
1476 | 1476 | $wgOut->showPermissionsErrorPage( $permission_errors ); |
1477 | 1477 | return; |
1478 | 1478 | } |
1479 | 1479 | |
1480 | 1480 | $db = wfGetDB( DB_MASTER ); |
1481 | | - $db->delete( 'trackbacks', array('tb_id' => $wgRequest->getInt('tbid')) ); |
| 1481 | + $db->delete( 'trackbacks', array( 'tb_id' => $wgRequest->getInt( 'tbid' ) ) ); |
1482 | 1482 | |
1483 | 1483 | $wgOut->addWikiMsg( 'trackbackdeleteok' ); |
1484 | 1484 | $this->mTitle->invalidateCache(); |
— | — | @@ -1485,7 +1485,7 @@ |
1486 | 1486 | |
1487 | 1487 | public function render() { |
1488 | 1488 | global $wgOut; |
1489 | | - $wgOut->setArticleBodyOnly(true); |
| 1489 | + $wgOut->setArticleBodyOnly( true ); |
1490 | 1490 | $this->view(); |
1491 | 1491 | } |
1492 | 1492 | |
— | — | @@ -1494,19 +1494,19 @@ |
1495 | 1495 | */ |
1496 | 1496 | public function purge() { |
1497 | 1497 | global $wgUser, $wgRequest, $wgOut; |
1498 | | - if( $wgUser->isAllowed( 'purge' ) || $wgRequest->wasPosted() ) { |
1499 | | - if( wfRunHooks( 'ArticlePurge', array( &$this ) ) ) { |
| 1498 | + if ( $wgUser->isAllowed( 'purge' ) || $wgRequest->wasPosted() ) { |
| 1499 | + if ( wfRunHooks( 'ArticlePurge', array( &$this ) ) ) { |
1500 | 1500 | $this->doPurge(); |
1501 | 1501 | $this->view(); |
1502 | 1502 | } |
1503 | 1503 | } else { |
1504 | 1504 | $action = htmlspecialchars( $wgRequest->getRequestURL() ); |
1505 | | - $button = wfMsgExt( 'confirm_purge_button', array('escapenoentities') ); |
| 1505 | + $button = wfMsgExt( 'confirm_purge_button', array( 'escapenoentities' ) ); |
1506 | 1506 | $form = "<form method=\"post\" action=\"$action\">\n" . |
1507 | 1507 | "<input type=\"submit\" name=\"submit\" value=\"$button\" />\n" . |
1508 | 1508 | "</form>\n"; |
1509 | | - $top = wfMsgExt( 'confirm-purge-top', array('parse') ); |
1510 | | - $bottom = wfMsgExt( 'confirm-purge-bottom', array('parse') ); |
| 1509 | + $top = wfMsgExt( 'confirm-purge-top', array( 'parse' ) ); |
| 1510 | + $bottom = wfMsgExt( 'confirm-purge-bottom', array( 'parse' ) ); |
1511 | 1511 | $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); |
1512 | 1512 | $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
1513 | 1513 | $wgOut->addHTML( $top . $form . $bottom ); |
— | — | @@ -1521,7 +1521,7 @@ |
1522 | 1522 | // Invalidate the cache |
1523 | 1523 | $this->mTitle->invalidateCache(); |
1524 | 1524 | |
1525 | | - if( $wgUseSquid ) { |
| 1525 | + if ( $wgUseSquid ) { |
1526 | 1526 | // Commit the transaction before the purge is sent |
1527 | 1527 | $dbw = wfGetDB( DB_MASTER ); |
1528 | 1528 | $dbw->commit(); |
— | — | @@ -1530,9 +1530,9 @@ |
1531 | 1531 | $update = SquidUpdate::newSimplePurge( $this->mTitle ); |
1532 | 1532 | $update->doUpdate(); |
1533 | 1533 | } |
1534 | | - if( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
| 1534 | + if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
1535 | 1535 | global $wgMessageCache; |
1536 | | - if( $this->getID() == 0 ) { |
| 1536 | + if ( $this->getID() == 0 ) { |
1537 | 1537 | $text = false; |
1538 | 1538 | } else { |
1539 | 1539 | $text = $this->getRawText(); |
— | — | @@ -1571,7 +1571,7 @@ |
1572 | 1572 | ), __METHOD__, 'IGNORE' ); |
1573 | 1573 | |
1574 | 1574 | $affected = $dbw->affectedRows(); |
1575 | | - if( $affected ) { |
| 1575 | + if ( $affected ) { |
1576 | 1576 | $newid = $dbw->insertId(); |
1577 | 1577 | $this->mTitle->resetArticleId( $newid ); |
1578 | 1578 | } |
— | — | @@ -1601,7 +1601,7 @@ |
1602 | 1602 | $rt = Title::newFromRedirect( $text ); |
1603 | 1603 | |
1604 | 1604 | $conditions = array( 'page_id' => $this->getId() ); |
1605 | | - if( !is_null( $lastRevision ) ) { |
| 1605 | + if ( !is_null( $lastRevision ) ) { |
1606 | 1606 | # An extra check against threads stepping on each other |
1607 | 1607 | $conditions['page_latest'] = $lastRevision; |
1608 | 1608 | } |
— | — | @@ -1610,7 +1610,7 @@ |
1611 | 1611 | array( /* SET */ |
1612 | 1612 | 'page_latest' => $revision->getId(), |
1613 | 1613 | 'page_touched' => $dbw->timestamp(), |
1614 | | - 'page_is_new' => ($lastRevision === 0) ? 1 : 0, |
| 1614 | + 'page_is_new' => ( $lastRevision === 0 ) ? 1 : 0, |
1615 | 1615 | 'page_is_redirect' => $rt !== null ? 1 : 0, |
1616 | 1616 | 'page_len' => strlen( $text ), |
1617 | 1617 | ), |
— | — | @@ -1618,7 +1618,7 @@ |
1619 | 1619 | __METHOD__ ); |
1620 | 1620 | |
1621 | 1621 | $result = $dbw->affectedRows() != 0; |
1622 | | - if( $result ) { |
| 1622 | + if ( $result ) { |
1623 | 1623 | $this->updateRedirectOn( $dbw, $rt, $lastRevIsRedirect ); |
1624 | 1624 | } |
1625 | 1625 | |
— | — | @@ -1641,10 +1641,10 @@ |
1642 | 1642 | // Always update redirects (target link might have changed) |
1643 | 1643 | // Update/Insert if we don't know if the last revision was a redirect or not |
1644 | 1644 | // Delete if changing from redirect to non-redirect |
1645 | | - $isRedirect = !is_null($redirectTitle); |
1646 | | - if($isRedirect || is_null($lastRevIsRedirect) || $lastRevIsRedirect !== $isRedirect) { |
| 1645 | + $isRedirect = !is_null( $redirectTitle ); |
| 1646 | + if ( $isRedirect || is_null( $lastRevIsRedirect ) || $lastRevIsRedirect !== $isRedirect ) { |
1647 | 1647 | wfProfileIn( __METHOD__ ); |
1648 | | - if( $isRedirect ) { |
| 1648 | + if ( $isRedirect ) { |
1649 | 1649 | // This title is a redirect, Add/Update row in the redirect table |
1650 | 1650 | $set = array( /* SET */ |
1651 | 1651 | 'rd_namespace' => $redirectTitle->getNamespace(), |
— | — | @@ -1655,9 +1655,9 @@ |
1656 | 1656 | } else { |
1657 | 1657 | // This is not a redirect, remove row from redirect table |
1658 | 1658 | $where = array( 'rd_from' => $this->getId() ); |
1659 | | - $dbw->delete( 'redirect', $where, __METHOD__); |
| 1659 | + $dbw->delete( 'redirect', $where, __METHOD__ ); |
1660 | 1660 | } |
1661 | | - if( $this->getTitle()->getNamespace() == NS_FILE ) { |
| 1661 | + if ( $this->getTitle()->getNamespace() == NS_FILE ) { |
1662 | 1662 | RepoGroup::singleton()->getLocalRepo()->invalidateImageRedirect( $this->getTitle() ); |
1663 | 1663 | } |
1664 | 1664 | wfProfileOut( __METHOD__ ); |
— | — | @@ -1682,8 +1682,8 @@ |
1683 | 1683 | 'page_id' => $this->getId(), |
1684 | 1684 | 'page_latest=rev_id' ), |
1685 | 1685 | __METHOD__ ); |
1686 | | - if( $row ) { |
1687 | | - if( wfTimestamp(TS_MW, $row->rev_timestamp) >= $revision->getTimestamp() ) { |
| 1686 | + if ( $row ) { |
| 1687 | + if ( wfTimestamp( TS_MW, $row->rev_timestamp ) >= $revision->getTimestamp() ) { |
1688 | 1688 | wfProfileOut( __METHOD__ ); |
1689 | 1689 | return false; |
1690 | 1690 | } |
— | — | @@ -1705,25 +1705,25 @@ |
1706 | 1706 | */ |
1707 | 1707 | public function replaceSection( $section, $text, $summary = '', $edittime = null ) { |
1708 | 1708 | wfProfileIn( __METHOD__ ); |
1709 | | - if( strval( $section ) == '' ) { |
| 1709 | + if ( strval( $section ) == '' ) { |
1710 | 1710 | // Whole-page edit; let the whole text through |
1711 | 1711 | } else { |
1712 | | - if( is_null($edittime) ) { |
| 1712 | + if ( is_null( $edittime ) ) { |
1713 | 1713 | $rev = Revision::newFromTitle( $this->mTitle ); |
1714 | 1714 | } else { |
1715 | 1715 | $dbw = wfGetDB( DB_MASTER ); |
1716 | 1716 | $rev = Revision::loadFromTimestamp( $dbw, $this->mTitle, $edittime ); |
1717 | 1717 | } |
1718 | | - if( !$rev ) { |
| 1718 | + if ( !$rev ) { |
1719 | 1719 | wfDebug( "Article::replaceSection asked for bogus section (page: " . |
1720 | 1720 | $this->getId() . "; section: $section; edittime: $edittime)\n" ); |
1721 | 1721 | return null; |
1722 | 1722 | } |
1723 | 1723 | $oldtext = $rev->getText(); |
1724 | 1724 | |
1725 | | - if( $section == 'new' ) { |
| 1725 | + if ( $section == 'new' ) { |
1726 | 1726 | # Inserting a new section |
1727 | | - $subject = $summary ? wfMsgForContent('newsectionheaderdefaultlevel',$summary) . "\n\n" : ''; |
| 1727 | + $subject = $summary ? wfMsgForContent( 'newsectionheaderdefaultlevel', $summary ) . "\n\n" : ''; |
1728 | 1728 | $text = strlen( trim( $oldtext ) ) > 0 |
1729 | 1729 | ? "{$oldtext}\n\n{$subject}{$text}" |
1730 | 1730 | : "{$subject}{$text}"; |
— | — | @@ -1741,28 +1741,28 @@ |
1742 | 1742 | * This function is not deprecated until somebody fixes the core not to use |
1743 | 1743 | * it. Nevertheless, use Article::doEdit() instead. |
1744 | 1744 | */ |
1745 | | - function insertNewArticle( $text, $summary, $isminor, $watchthis, $suppressRC=false, $comment=false, $bot=false ) { |
| 1745 | + function insertNewArticle( $text, $summary, $isminor, $watchthis, $suppressRC = false, $comment = false, $bot = false ) { |
1746 | 1746 | $flags = EDIT_NEW | EDIT_DEFER_UPDATES | EDIT_AUTOSUMMARY | |
1747 | 1747 | ( $isminor ? EDIT_MINOR : 0 ) | |
1748 | 1748 | ( $suppressRC ? EDIT_SUPPRESS_RC : 0 ) | |
1749 | 1749 | ( $bot ? EDIT_FORCE_BOT : 0 ); |
1750 | 1750 | |
1751 | 1751 | # If this is a comment, add the summary as headline |
1752 | | - if( $comment && $summary != "" ) { |
1753 | | - $text = wfMsgForContent('newsectionheaderdefaultlevel',$summary) . "\n\n".$text; |
| 1752 | + if ( $comment && $summary != "" ) { |
| 1753 | + $text = wfMsgForContent( 'newsectionheaderdefaultlevel', $summary ) . "\n\n" . $text; |
1754 | 1754 | } |
1755 | 1755 | |
1756 | 1756 | $this->doEdit( $text, $summary, $flags ); |
1757 | 1757 | |
1758 | 1758 | $dbw = wfGetDB( DB_MASTER ); |
1759 | | - if($watchthis) { |
1760 | | - if(!$this->mTitle->userIsWatching()) { |
| 1759 | + if ( $watchthis ) { |
| 1760 | + if ( !$this->mTitle->userIsWatching() ) { |
1761 | 1761 | $dbw->begin(); |
1762 | 1762 | $this->doWatch(); |
1763 | 1763 | $dbw->commit(); |
1764 | 1764 | } |
1765 | 1765 | } else { |
1766 | | - if( $this->mTitle->userIsWatching() ) { |
| 1766 | + if ( $this->mTitle->userIsWatching() ) { |
1767 | 1767 | $dbw->begin(); |
1768 | 1768 | $this->doUnwatch(); |
1769 | 1769 | $dbw->commit(); |
— | — | @@ -1780,19 +1780,19 @@ |
1781 | 1781 | ( $forceBot ? EDIT_FORCE_BOT : 0 ); |
1782 | 1782 | |
1783 | 1783 | $status = $this->doEdit( $text, $summary, $flags ); |
1784 | | - if( !$status->isOK() ) { |
| 1784 | + if ( !$status->isOK() ) { |
1785 | 1785 | return false; |
1786 | 1786 | } |
1787 | 1787 | |
1788 | 1788 | $dbw = wfGetDB( DB_MASTER ); |
1789 | | - if( $watchthis ) { |
1790 | | - if(!$this->mTitle->userIsWatching()) { |
| 1789 | + if ( $watchthis ) { |
| 1790 | + if ( !$this->mTitle->userIsWatching() ) { |
1791 | 1791 | $dbw->begin(); |
1792 | 1792 | $this->doWatch(); |
1793 | 1793 | $dbw->commit(); |
1794 | 1794 | } |
1795 | 1795 | } else { |
1796 | | - if( $this->mTitle->userIsWatching() ) { |
| 1796 | + if ( $this->mTitle->userIsWatching() ) { |
1797 | 1797 | $dbw->begin(); |
1798 | 1798 | $this->doUnwatch(); |
1799 | 1799 | $dbw->commit(); |
— | — | @@ -1860,47 +1860,47 @@ |
1861 | 1861 | global $wgUser, $wgDBtransactions, $wgUseAutomaticEditSummaries; |
1862 | 1862 | |
1863 | 1863 | # Low-level sanity check |
1864 | | - if( $this->mTitle->getText() == '' ) { |
| 1864 | + if ( $this->mTitle->getText() == '' ) { |
1865 | 1865 | throw new MWException( 'Something is trying to edit an article with an empty title' ); |
1866 | 1866 | } |
1867 | 1867 | |
1868 | 1868 | wfProfileIn( __METHOD__ ); |
1869 | 1869 | |
1870 | | - $user = is_null($user) ? $wgUser : $user; |
| 1870 | + $user = is_null( $user ) ? $wgUser : $user; |
1871 | 1871 | $status = Status::newGood( array() ); |
1872 | 1872 | |
1873 | 1873 | # Load $this->mTitle->getArticleID() and $this->mLatest if it's not already |
1874 | 1874 | $this->loadPageData(); |
1875 | 1875 | |
1876 | | - if( !($flags & EDIT_NEW) && !($flags & EDIT_UPDATE) ) { |
| 1876 | + if ( !( $flags & EDIT_NEW ) && !( $flags & EDIT_UPDATE ) ) { |
1877 | 1877 | $aid = $this->mTitle->getArticleID(); |
1878 | | - if( $aid ) { |
| 1878 | + if ( $aid ) { |
1879 | 1879 | $flags |= EDIT_UPDATE; |
1880 | 1880 | } else { |
1881 | 1881 | $flags |= EDIT_NEW; |
1882 | 1882 | } |
1883 | 1883 | } |
1884 | 1884 | |
1885 | | - if( !wfRunHooks( 'ArticleSave', array( &$this, &$user, &$text, &$summary, |
| 1885 | + if ( !wfRunHooks( 'ArticleSave', array( &$this, &$user, &$text, &$summary, |
1886 | 1886 | $flags & EDIT_MINOR, null, null, &$flags, &$status ) ) ) |
1887 | 1887 | { |
1888 | 1888 | wfDebug( __METHOD__ . ": ArticleSave hook aborted save!\n" ); |
1889 | 1889 | wfProfileOut( __METHOD__ ); |
1890 | | - if( $status->isOK() ) { |
1891 | | - $status->fatal( 'edit-hook-aborted'); |
| 1890 | + if ( $status->isOK() ) { |
| 1891 | + $status->fatal( 'edit-hook-aborted' ); |
1892 | 1892 | } |
1893 | 1893 | return $status; |
1894 | 1894 | } |
1895 | 1895 | |
1896 | 1896 | # Silently ignore EDIT_MINOR if not allowed |
1897 | | - $isminor = ( $flags & EDIT_MINOR ) && $user->isAllowed('minoredit'); |
| 1897 | + $isminor = ( $flags & EDIT_MINOR ) && $user->isAllowed( 'minoredit' ); |
1898 | 1898 | $bot = $flags & EDIT_FORCE_BOT; |
1899 | 1899 | |
1900 | 1900 | $oldtext = $this->getRawText(); // current revision |
1901 | 1901 | $oldsize = strlen( $oldtext ); |
1902 | 1902 | |
1903 | 1903 | # Provide autosummaries if one is not provided and autosummaries are enabled. |
1904 | | - if( $wgUseAutomaticEditSummaries && $flags & EDIT_AUTOSUMMARY && $summary == '' ) { |
| 1904 | + if ( $wgUseAutomaticEditSummaries && $flags & EDIT_AUTOSUMMARY && $summary == '' ) { |
1905 | 1905 | $summary = $this->getAutosummary( $oldtext, $text, $flags ); |
1906 | 1906 | } |
1907 | 1907 | |
— | — | @@ -1910,13 +1910,13 @@ |
1911 | 1911 | |
1912 | 1912 | $dbw = wfGetDB( DB_MASTER ); |
1913 | 1913 | $now = wfTimestampNow(); |
1914 | | - $this->mTimestamp=$now; |
| 1914 | + $this->mTimestamp = $now; |
1915 | 1915 | |
1916 | | - if( $flags & EDIT_UPDATE ) { |
| 1916 | + if ( $flags & EDIT_UPDATE ) { |
1917 | 1917 | # Update article, but only if changed. |
1918 | 1918 | $status->value['new'] = false; |
1919 | 1919 | # Make sure the revision is either completely inserted or not inserted at all |
1920 | | - if( !$wgDBtransactions ) { |
| 1920 | + if ( !$wgDBtransactions ) { |
1921 | 1921 | $userAbort = ignore_user_abort( true ); |
1922 | 1922 | } |
1923 | 1923 | |
— | — | @@ -1924,14 +1924,14 @@ |
1925 | 1925 | |
1926 | 1926 | $changed = ( strcmp( $text, $oldtext ) != 0 ); |
1927 | 1927 | |
1928 | | - if( $changed ) { |
| 1928 | + if ( $changed ) { |
1929 | 1929 | $this->mGoodAdjustment = (int)$this->isCountable( $text ) |
1930 | 1930 | - (int)$this->isCountable( $oldtext ); |
1931 | 1931 | $this->mTotalAdjustment = 0; |
1932 | 1932 | |
1933 | | - if( !$this->mLatest ) { |
| 1933 | + if ( !$this->mLatest ) { |
1934 | 1934 | # Article gone missing |
1935 | | - wfDebug( __METHOD__.": EDIT_UPDATE specified but article doesn't exist\n" ); |
| 1935 | + wfDebug( __METHOD__ . ": EDIT_UPDATE specified but article doesn't exist\n" ); |
1936 | 1936 | $status->fatal( 'edit-gone-missing' ); |
1937 | 1937 | wfProfileOut( __METHOD__ ); |
1938 | 1938 | return $status; |
— | — | @@ -1959,29 +1959,29 @@ |
1960 | 1960 | # creates a window where concurrent edits can cause an ignored edit conflict. |
1961 | 1961 | $ok = $this->updateRevisionOn( $dbw, $revision, $this->mLatest ); |
1962 | 1962 | |
1963 | | - if( !$ok ) { |
| 1963 | + if ( !$ok ) { |
1964 | 1964 | /* Belated edit conflict! Run away!! */ |
1965 | 1965 | $status->fatal( 'edit-conflict' ); |
1966 | 1966 | # Delete the invalid revision if the DB is not transactional |
1967 | | - if( !$wgDBtransactions ) { |
| 1967 | + if ( !$wgDBtransactions ) { |
1968 | 1968 | $dbw->delete( 'revision', array( 'rev_id' => $revisionId ), __METHOD__ ); |
1969 | 1969 | } |
1970 | 1970 | $revisionId = 0; |
1971 | 1971 | $dbw->rollback(); |
1972 | 1972 | } else { |
1973 | 1973 | global $wgUseRCPatrol; |
1974 | | - wfRunHooks( 'NewRevisionFromEditComplete', array($this, $revision, $baseRevId, $user) ); |
| 1974 | + wfRunHooks( 'NewRevisionFromEditComplete', array( $this, $revision, $baseRevId, $user ) ); |
1975 | 1975 | # Update recentchanges |
1976 | | - if( !( $flags & EDIT_SUPPRESS_RC ) ) { |
| 1976 | + if ( !( $flags & EDIT_SUPPRESS_RC ) ) { |
1977 | 1977 | # Mark as patrolled if the user can do so |
1978 | | - $patrolled = $wgUseRCPatrol && $this->mTitle->userCan('autopatrol'); |
| 1978 | + $patrolled = $wgUseRCPatrol && $this->mTitle->userCan( 'autopatrol' ); |
1979 | 1979 | # Add RC row to the DB |
1980 | 1980 | $rc = RecentChange::notifyEdit( $now, $this->mTitle, $isminor, $user, $summary, |
1981 | 1981 | $this->mLatest, $this->getTimestamp(), $bot, '', $oldsize, $newsize, |
1982 | 1982 | $revisionId, $patrolled |
1983 | 1983 | ); |
1984 | 1984 | # Log auto-patrolled edits |
1985 | | - if( $patrolled ) { |
| 1985 | + if ( $patrolled ) { |
1986 | 1986 | PatrolLog::record( $rc, true ); |
1987 | 1987 | } |
1988 | 1988 | } |
— | — | @@ -1998,11 +1998,11 @@ |
1999 | 1999 | $this->mTitle->invalidateCache(); |
2000 | 2000 | } |
2001 | 2001 | |
2002 | | - if( !$wgDBtransactions ) { |
| 2002 | + if ( !$wgDBtransactions ) { |
2003 | 2003 | ignore_user_abort( $userAbort ); |
2004 | 2004 | } |
2005 | 2005 | // Now that ignore_user_abort is restored, we can respond to fatal errors |
2006 | | - if( !$status->isOK() ) { |
| 2006 | + if ( !$status->isOK() ) { |
2007 | 2007 | wfProfileOut( __METHOD__ ); |
2008 | 2008 | return $status; |
2009 | 2009 | } |
— | — | @@ -2028,7 +2028,7 @@ |
2029 | 2029 | # This will return false if the article already exists |
2030 | 2030 | $newid = $this->insertOn( $dbw ); |
2031 | 2031 | |
2032 | | - if( $newid === false ) { |
| 2032 | + if ( $newid === false ) { |
2033 | 2033 | $dbw->rollback(); |
2034 | 2034 | $status->fatal( 'edit-already-exists' ); |
2035 | 2035 | wfProfileOut( __METHOD__ ); |
— | — | @@ -2051,17 +2051,17 @@ |
2052 | 2052 | # Update the page record with revision data |
2053 | 2053 | $this->updateRevisionOn( $dbw, $revision, 0 ); |
2054 | 2054 | |
2055 | | - wfRunHooks( 'NewRevisionFromEditComplete', array($this, $revision, false, $user) ); |
| 2055 | + wfRunHooks( 'NewRevisionFromEditComplete', array( $this, $revision, false, $user ) ); |
2056 | 2056 | # Update recentchanges |
2057 | | - if( !( $flags & EDIT_SUPPRESS_RC ) ) { |
| 2057 | + if ( !( $flags & EDIT_SUPPRESS_RC ) ) { |
2058 | 2058 | global $wgUseRCPatrol, $wgUseNPPatrol; |
2059 | 2059 | # Mark as patrolled if the user can do so |
2060 | | - $patrolled = ($wgUseRCPatrol || $wgUseNPPatrol) && $this->mTitle->userCan('autopatrol'); |
| 2060 | + $patrolled = ( $wgUseRCPatrol || $wgUseNPPatrol ) && $this->mTitle->userCan( 'autopatrol' ); |
2061 | 2061 | # Add RC row to the DB |
2062 | 2062 | $rc = RecentChange::notifyNew( $now, $this->mTitle, $isminor, $user, $summary, $bot, |
2063 | | - '', strlen($text), $revisionId, $patrolled ); |
| 2063 | + '', strlen( $text ), $revisionId, $patrolled ); |
2064 | 2064 | # Log auto-patrolled edits |
2065 | | - if( $patrolled ) { |
| 2065 | + if ( $patrolled ) { |
2066 | 2066 | PatrolLog::record( $rc, true ); |
2067 | 2067 | } |
2068 | 2068 | } |
— | — | @@ -2079,7 +2079,7 @@ |
2080 | 2080 | } |
2081 | 2081 | |
2082 | 2082 | # Do updates right now unless deferral was requested |
2083 | | - if( !( $flags & EDIT_DEFER_UPDATES ) ) { |
| 2083 | + if ( !( $flags & EDIT_DEFER_UPDATES ) ) { |
2084 | 2084 | wfDoUpdates(); |
2085 | 2085 | } |
2086 | 2086 | |
— | — | @@ -2111,9 +2111,9 @@ |
2112 | 2112 | */ |
2113 | 2113 | public function doRedirect( $noRedir = false, $sectionAnchor = '', $extraQuery = '' ) { |
2114 | 2114 | global $wgOut; |
2115 | | - if( $noRedir ) { |
| 2115 | + if ( $noRedir ) { |
2116 | 2116 | $query = 'redirect=no'; |
2117 | | - if( $extraQuery ) |
| 2117 | + if ( $extraQuery ) |
2118 | 2118 | $query .= "&$query"; |
2119 | 2119 | } else { |
2120 | 2120 | $query = $extraQuery; |
— | — | @@ -2129,38 +2129,38 @@ |
2130 | 2130 | $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
2131 | 2131 | |
2132 | 2132 | # If we haven't been given an rc_id value, we can't do anything |
2133 | | - $rcid = (int) $wgRequest->getVal('rcid'); |
2134 | | - $rc = RecentChange::newFromId($rcid); |
2135 | | - if( is_null($rc) ) { |
| 2133 | + $rcid = (int) $wgRequest->getVal( 'rcid' ); |
| 2134 | + $rc = RecentChange::newFromId( $rcid ); |
| 2135 | + if ( is_null( $rc ) ) { |
2136 | 2136 | $wgOut->showErrorPage( 'markedaspatrollederror', 'markedaspatrollederrortext' ); |
2137 | 2137 | return; |
2138 | 2138 | } |
2139 | 2139 | |
2140 | | - #It would be nice to see where the user had actually come from, but for now just guess |
| 2140 | + # It would be nice to see where the user had actually come from, but for now just guess |
2141 | 2141 | $returnto = $rc->getAttribute( 'rc_type' ) == RC_NEW ? 'Newpages' : 'Recentchanges'; |
2142 | 2142 | $return = SpecialPage::getTitleFor( $returnto ); |
2143 | 2143 | |
2144 | 2144 | $dbw = wfGetDB( DB_MASTER ); |
2145 | 2145 | $errors = $rc->doMarkPatrolled(); |
2146 | 2146 | |
2147 | | - if( in_array(array('rcpatroldisabled'), $errors) ) { |
| 2147 | + if ( in_array( array( 'rcpatroldisabled' ), $errors ) ) { |
2148 | 2148 | $wgOut->showErrorPage( 'rcpatroldisabled', 'rcpatroldisabledtext' ); |
2149 | 2149 | return; |
2150 | 2150 | } |
2151 | 2151 | |
2152 | | - if( in_array(array('hookaborted'), $errors) ) { |
| 2152 | + if ( in_array( array( 'hookaborted' ), $errors ) ) { |
2153 | 2153 | // The hook itself has handled any output |
2154 | 2154 | return; |
2155 | 2155 | } |
2156 | 2156 | |
2157 | | - if( in_array(array('markedaspatrollederror-noautopatrol'), $errors) ) { |
| 2157 | + if ( in_array( array( 'markedaspatrollederror-noautopatrol' ), $errors ) ) { |
2158 | 2158 | $wgOut->setPageTitle( wfMsg( 'markedaspatrollederror' ) ); |
2159 | 2159 | $wgOut->addWikiMsg( 'markedaspatrollederror-noautopatrol' ); |
2160 | 2160 | $wgOut->returnToMain( false, $return ); |
2161 | 2161 | return; |
2162 | 2162 | } |
2163 | 2163 | |
2164 | | - if( !empty($errors) ) { |
| 2164 | + if ( !empty( $errors ) ) { |
2165 | 2165 | $wgOut->showPermissionsErrorPage( $errors ); |
2166 | 2166 | return; |
2167 | 2167 | } |
— | — | @@ -2176,15 +2176,15 @@ |
2177 | 2177 | */ |
2178 | 2178 | public function watch() { |
2179 | 2179 | global $wgUser, $wgOut; |
2180 | | - if( $wgUser->isAnon() ) { |
| 2180 | + if ( $wgUser->isAnon() ) { |
2181 | 2181 | $wgOut->showErrorPage( 'watchnologin', 'watchnologintext' ); |
2182 | 2182 | return; |
2183 | 2183 | } |
2184 | | - if( wfReadOnly() ) { |
| 2184 | + if ( wfReadOnly() ) { |
2185 | 2185 | $wgOut->readOnlyPage(); |
2186 | 2186 | return; |
2187 | 2187 | } |
2188 | | - if( $this->doWatch() ) { |
| 2188 | + if ( $this->doWatch() ) { |
2189 | 2189 | $wgOut->setPagetitle( wfMsg( 'addedwatch' ) ); |
2190 | 2190 | $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
2191 | 2191 | $wgOut->addWikiMsg( 'addedwatchtext', $this->mTitle->getPrefixedText() ); |
— | — | @@ -2198,12 +2198,12 @@ |
2199 | 2199 | */ |
2200 | 2200 | public function doWatch() { |
2201 | 2201 | global $wgUser; |
2202 | | - if( $wgUser->isAnon() ) { |
| 2202 | + if ( $wgUser->isAnon() ) { |
2203 | 2203 | return false; |
2204 | 2204 | } |
2205 | | - if( wfRunHooks('WatchArticle', array(&$wgUser, &$this)) ) { |
| 2205 | + if ( wfRunHooks( 'WatchArticle', array( &$wgUser, &$this ) ) ) { |
2206 | 2206 | $wgUser->addWatch( $this->mTitle ); |
2207 | | - return wfRunHooks('WatchArticleComplete', array(&$wgUser, &$this)); |
| 2207 | + return wfRunHooks( 'WatchArticleComplete', array( &$wgUser, &$this ) ); |
2208 | 2208 | } |
2209 | 2209 | return false; |
2210 | 2210 | } |
— | — | @@ -2213,15 +2213,15 @@ |
2214 | 2214 | */ |
2215 | 2215 | public function unwatch() { |
2216 | 2216 | global $wgUser, $wgOut; |
2217 | | - if( $wgUser->isAnon() ) { |
| 2217 | + if ( $wgUser->isAnon() ) { |
2218 | 2218 | $wgOut->showErrorPage( 'watchnologin', 'watchnologintext' ); |
2219 | 2219 | return; |
2220 | 2220 | } |
2221 | | - if( wfReadOnly() ) { |
| 2221 | + if ( wfReadOnly() ) { |
2222 | 2222 | $wgOut->readOnlyPage(); |
2223 | 2223 | return; |
2224 | 2224 | } |
2225 | | - if( $this->doUnwatch() ) { |
| 2225 | + if ( $this->doUnwatch() ) { |
2226 | 2226 | $wgOut->setPagetitle( wfMsg( 'removedwatch' ) ); |
2227 | 2227 | $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
2228 | 2228 | $wgOut->addWikiMsg( 'removedwatchtext', $this->mTitle->getPrefixedText() ); |
— | — | @@ -2235,12 +2235,12 @@ |
2236 | 2236 | */ |
2237 | 2237 | public function doUnwatch() { |
2238 | 2238 | global $wgUser; |
2239 | | - if( $wgUser->isAnon() ) { |
| 2239 | + if ( $wgUser->isAnon() ) { |
2240 | 2240 | return false; |
2241 | 2241 | } |
2242 | | - if( wfRunHooks('UnwatchArticle', array(&$wgUser, &$this)) ) { |
| 2242 | + if ( wfRunHooks( 'UnwatchArticle', array( &$wgUser, &$this ) ) ) { |
2243 | 2243 | $wgUser->removeWatch( $this->mTitle ); |
2244 | | - return wfRunHooks('UnwatchArticleComplete', array(&$wgUser, &$this)); |
| 2244 | + return wfRunHooks( 'UnwatchArticleComplete', array( &$wgUser, &$this ) ); |
2245 | 2245 | } |
2246 | 2246 | return false; |
2247 | 2247 | } |
— | — | @@ -2290,7 +2290,7 @@ |
2291 | 2291 | return false; |
2292 | 2292 | } |
2293 | 2293 | |
2294 | | - if( !$cascade ) { |
| 2294 | + if ( !$cascade ) { |
2295 | 2295 | $cascade = false; |
2296 | 2296 | } |
2297 | 2297 | |
— | — | @@ -2302,17 +2302,17 @@ |
2303 | 2303 | $current = array(); |
2304 | 2304 | $updated = Article::flattenRestrictions( $limit ); |
2305 | 2305 | $changed = false; |
2306 | | - foreach( $restrictionTypes as $action ) { |
2307 | | - if( isset( $expiry[$action] ) ) { |
| 2306 | + foreach ( $restrictionTypes as $action ) { |
| 2307 | + if ( isset( $expiry[$action] ) ) { |
2308 | 2308 | # Get current restrictions on $action |
2309 | 2309 | $aLimits = $this->mTitle->getRestrictions( $action ); |
2310 | 2310 | $current[$action] = implode( '', $aLimits ); |
2311 | 2311 | # Are any actual restrictions being dealt with here? |
2312 | | - $aRChanged = count($aLimits) || !empty($limit[$action]); |
| 2312 | + $aRChanged = count( $aLimits ) || !empty( $limit[$action] ); |
2313 | 2313 | # If something changed, we need to log it. Checking $aRChanged |
2314 | 2314 | # assures that "unprotecting" a page that is not protected does |
2315 | 2315 | # not log just because the expiry was "changed". |
2316 | | - if( $aRChanged && $this->mTitle->mRestrictionsExpiry[$action] != $expiry[$action] ) { |
| 2316 | + if ( $aRChanged && $this->mTitle->mRestrictionsExpiry[$action] != $expiry[$action] ) { |
2317 | 2317 | $changed = true; |
2318 | 2318 | } |
2319 | 2319 | } |
— | — | @@ -2320,19 +2320,19 @@ |
2321 | 2321 | |
2322 | 2322 | $current = Article::flattenRestrictions( $current ); |
2323 | 2323 | |
2324 | | - $changed = ($changed || $current != $updated ); |
2325 | | - $changed = $changed || ($updated && $this->mTitle->areRestrictionsCascading() != $cascade); |
| 2324 | + $changed = ( $changed || $current != $updated ); |
| 2325 | + $changed = $changed || ( $updated && $this->mTitle->areRestrictionsCascading() != $cascade ); |
2326 | 2326 | $protect = ( $updated != '' ); |
2327 | 2327 | |
2328 | 2328 | # If nothing's changed, do nothing |
2329 | | - if( $changed ) { |
2330 | | - if( wfRunHooks( 'ArticleProtect', array( &$this, &$wgUser, $limit, $reason ) ) ) { |
| 2329 | + if ( $changed ) { |
| 2330 | + if ( wfRunHooks( 'ArticleProtect', array( &$this, &$wgUser, $limit, $reason ) ) ) { |
2331 | 2331 | |
2332 | 2332 | $dbw = wfGetDB( DB_MASTER ); |
2333 | 2333 | |
2334 | 2334 | # Prepare a null revision to be added to the history |
2335 | 2335 | $modified = $current != '' && $protect; |
2336 | | - if( $protect ) { |
| 2336 | + if ( $protect ) { |
2337 | 2337 | $comment_type = $modified ? 'modifiedarticleprotection' : 'protectedarticle'; |
2338 | 2338 | } else { |
2339 | 2339 | $comment_type = 'unprotectedarticle'; |
— | — | @@ -2343,27 +2343,27 @@ |
2344 | 2344 | # Otherwise, people who cannot normally protect can "protect" pages via transclusion |
2345 | 2345 | $editrestriction = isset( $limit['edit'] ) ? array( $limit['edit'] ) : $this->mTitle->getRestrictions( 'edit' ); |
2346 | 2346 | # The schema allows multiple restrictions |
2347 | | - if(!in_array('protect', $editrestriction) && !in_array('sysop', $editrestriction)) |
| 2347 | + if ( !in_array( 'protect', $editrestriction ) && !in_array( 'sysop', $editrestriction ) ) |
2348 | 2348 | $cascade = false; |
2349 | 2349 | $cascade_description = ''; |
2350 | | - if( $cascade ) { |
2351 | | - $cascade_description = ' ['.wfMsgForContent('protect-summary-cascade').']'; |
| 2350 | + if ( $cascade ) { |
| 2351 | + $cascade_description = ' [' . wfMsgForContent( 'protect-summary-cascade' ) . ']'; |
2352 | 2352 | } |
2353 | 2353 | |
2354 | | - if( $reason ) |
| 2354 | + if ( $reason ) |
2355 | 2355 | $comment .= ": $reason"; |
2356 | 2356 | |
2357 | 2357 | $editComment = $comment; |
2358 | 2358 | $encodedExpiry = array(); |
2359 | 2359 | $protect_description = ''; |
2360 | | - foreach( $limit as $action => $restrictions ) { |
2361 | | - if ( !isset($expiry[$action]) ) |
| 2360 | + foreach ( $limit as $action => $restrictions ) { |
| 2361 | + if ( !isset( $expiry[$action] ) ) |
2362 | 2362 | $expiry[$action] = 'infinite'; |
2363 | 2363 | |
2364 | | - $encodedExpiry[$action] = Block::encodeExpiry($expiry[$action], $dbw ); |
2365 | | - if( $restrictions != '' ) { |
| 2364 | + $encodedExpiry[$action] = Block::encodeExpiry( $expiry[$action], $dbw ); |
| 2365 | + if ( $restrictions != '' ) { |
2366 | 2366 | $protect_description .= "[$action=$restrictions] ("; |
2367 | | - if( $encodedExpiry[$action] != 'infinity' ) { |
| 2367 | + if ( $encodedExpiry[$action] != 'infinity' ) { |
2368 | 2368 | $protect_description .= wfMsgForContent( 'protect-expiring', |
2369 | 2369 | $wgContLang->timeanddate( $expiry[$action], false, false ) , |
2370 | 2370 | $wgContLang->date( $expiry[$action], false, false ) , |
— | — | @@ -2374,20 +2374,20 @@ |
2375 | 2375 | $protect_description .= ') '; |
2376 | 2376 | } |
2377 | 2377 | } |
2378 | | - $protect_description = trim($protect_description); |
| 2378 | + $protect_description = trim( $protect_description ); |
2379 | 2379 | |
2380 | | - if( $protect_description && $protect ) |
| 2380 | + if ( $protect_description && $protect ) |
2381 | 2381 | $editComment .= " ($protect_description)"; |
2382 | | - if( $cascade ) |
| 2382 | + if ( $cascade ) |
2383 | 2383 | $editComment .= "$cascade_description"; |
2384 | 2384 | # Update restrictions table |
2385 | | - foreach( $limit as $action => $restrictions ) { |
2386 | | - if($restrictions != '' ) { |
2387 | | - $dbw->replace( 'page_restrictions', array(array('pr_page', 'pr_type')), |
| 2385 | + foreach ( $limit as $action => $restrictions ) { |
| 2386 | + if ( $restrictions != '' ) { |
| 2387 | + $dbw->replace( 'page_restrictions', array( array( 'pr_page', 'pr_type' ) ), |
2388 | 2388 | array( 'pr_page' => $id, |
2389 | 2389 | 'pr_type' => $action, |
2390 | 2390 | 'pr_level' => $restrictions, |
2391 | | - 'pr_cascade' => ($cascade && $action == 'edit') ? 1 : 0, |
| 2391 | + 'pr_cascade' => ( $cascade && $action == 'edit' ) ? 1 : 0, |
2392 | 2392 | 'pr_expiry' => $encodedExpiry[$action] ), __METHOD__ ); |
2393 | 2393 | } else { |
2394 | 2394 | $dbw->delete( 'page_restrictions', array( 'pr_page' => $id, |
— | — | @@ -2411,14 +2411,14 @@ |
2412 | 2412 | ), 'Article::protect' |
2413 | 2413 | ); |
2414 | 2414 | |
2415 | | - wfRunHooks( 'NewRevisionFromEditComplete', array($this, $nullRevision, $latest, $wgUser) ); |
| 2415 | + wfRunHooks( 'NewRevisionFromEditComplete', array( $this, $nullRevision, $latest, $wgUser ) ); |
2416 | 2416 | wfRunHooks( 'ArticleProtectComplete', array( &$this, &$wgUser, $limit, $reason ) ); |
2417 | 2417 | |
2418 | 2418 | # Update the protection log |
2419 | 2419 | $log = new LogPage( 'protect' ); |
2420 | | - if( $protect ) { |
2421 | | - $params = array($protect_description,$cascade ? 'cascade' : ''); |
2422 | | - $log->addEntry( $modified ? 'modify' : 'protect', $this->mTitle, trim( $reason), $params ); |
| 2420 | + if ( $protect ) { |
| 2421 | + $params = array( $protect_description, $cascade ? 'cascade' : '' ); |
| 2422 | + $log->addEntry( $modified ? 'modify' : 'protect', $this->mTitle, trim( $reason ), $params ); |
2423 | 2423 | } else { |
2424 | 2424 | $log->addEntry( 'unprotect', $this->mTitle, $reason ); |
2425 | 2425 | } |
— | — | @@ -2436,13 +2436,13 @@ |
2437 | 2437 | * @return String |
2438 | 2438 | */ |
2439 | 2439 | protected static function flattenRestrictions( $limit ) { |
2440 | | - if( !is_array( $limit ) ) { |
| 2440 | + if ( !is_array( $limit ) ) { |
2441 | 2441 | throw new MWException( 'Article::flattenRestrictions given non-array restriction set' ); |
2442 | 2442 | } |
2443 | 2443 | $bits = array(); |
2444 | 2444 | ksort( $limit ); |
2445 | | - foreach( $limit as $action => $restrictions ) { |
2446 | | - if( $restrictions != '' ) { |
| 2445 | + foreach ( $limit as $action => $restrictions ) { |
| 2446 | + if ( $restrictions != '' ) { |
2447 | 2447 | $bits[] = "$action=$restrictions"; |
2448 | 2448 | } |
2449 | 2449 | } |
— | — | @@ -2458,7 +2458,7 @@ |
2459 | 2459 | $dbw = wfGetDB( DB_MASTER ); |
2460 | 2460 | // Get the last revision |
2461 | 2461 | $rev = Revision::newFromTitle( $this->mTitle ); |
2462 | | - if( is_null( $rev ) ) |
| 2462 | + if ( is_null( $rev ) ) |
2463 | 2463 | return false; |
2464 | 2464 | |
2465 | 2465 | // Get the article's contents |
— | — | @@ -2466,9 +2466,9 @@ |
2467 | 2467 | $blank = false; |
2468 | 2468 | // If the page is blank, use the text from the previous revision, |
2469 | 2469 | // which can only be blank if there's a move/import/protect dummy revision involved |
2470 | | - if( $contents == '' ) { |
| 2470 | + if ( $contents == '' ) { |
2471 | 2471 | $prev = $rev->getPrevious(); |
2472 | | - if( $prev ) { |
| 2472 | + if ( $prev ) { |
2473 | 2473 | $contents = $prev->getText(); |
2474 | 2474 | $blank = true; |
2475 | 2475 | } |
— | — | @@ -2477,11 +2477,11 @@ |
2478 | 2478 | // Find out if there was only one contributor |
2479 | 2479 | // Only scan the last 20 revisions |
2480 | 2480 | $res = $dbw->select( 'revision', 'rev_user_text', |
2481 | | - array( 'rev_page' => $this->getID(), $dbw->bitAnd('rev_deleted', Revision::DELETED_USER) . ' = 0' ), |
| 2481 | + array( 'rev_page' => $this->getID(), $dbw->bitAnd( 'rev_deleted', Revision::DELETED_USER ) . ' = 0' ), |
2482 | 2482 | __METHOD__, |
2483 | 2483 | array( 'LIMIT' => 20 ) |
2484 | 2484 | ); |
2485 | | - if( $res === false ) |
| 2485 | + if ( $res === false ) |
2486 | 2486 | // This page has no revisions, which is very weird |
2487 | 2487 | return false; |
2488 | 2488 | |
— | — | @@ -2489,8 +2489,8 @@ |
2490 | 2490 | $row = $dbw->fetchObject( $res ); |
2491 | 2491 | $onlyAuthor = $row->rev_user_text; |
2492 | 2492 | // Try to find a second contributor |
2493 | | - foreach( $res as $row ) { |
2494 | | - if( $row->rev_user_text != $onlyAuthor ) { |
| 2493 | + foreach ( $res as $row ) { |
| 2494 | + if ( $row->rev_user_text != $onlyAuthor ) { |
2495 | 2495 | $onlyAuthor = false; |
2496 | 2496 | break; |
2497 | 2497 | } |
— | — | @@ -2498,18 +2498,18 @@ |
2499 | 2499 | $dbw->freeResult( $res ); |
2500 | 2500 | |
2501 | 2501 | // Generate the summary with a '$1' placeholder |
2502 | | - if( $blank ) { |
| 2502 | + if ( $blank ) { |
2503 | 2503 | // The current revision is blank and the one before is also |
2504 | 2504 | // blank. It's just not our lucky day |
2505 | 2505 | $reason = wfMsgForContent( 'exbeforeblank', '$1' ); |
2506 | 2506 | } else { |
2507 | | - if( $onlyAuthor ) |
| 2507 | + if ( $onlyAuthor ) |
2508 | 2508 | $reason = wfMsgForContent( 'excontentauthor', '$1', $onlyAuthor ); |
2509 | 2509 | else |
2510 | 2510 | $reason = wfMsgForContent( 'excontent', '$1' ); |
2511 | 2511 | } |
2512 | 2512 | |
2513 | | - if( $reason == '-' ) { |
| 2513 | + if ( $reason == '-' ) { |
2514 | 2514 | // Allow these UI messages to be blanked out cleanly |
2515 | 2515 | return ''; |
2516 | 2516 | } |
— | — | @@ -2518,7 +2518,7 @@ |
2519 | 2519 | $contents = preg_replace( "/[\n\r]/", ' ', $contents ); |
2520 | 2520 | // Calculate the maximum amount of chars to get |
2521 | 2521 | // Max content length = max comment length - length of the comment (excl. $1) - '...' |
2522 | | - $maxLength = 255 - (strlen( $reason ) - 2) - 3; |
| 2522 | + $maxLength = 255 - ( strlen( $reason ) - 2 ) - 3; |
2523 | 2523 | $contents = $wgContLang->truncate( $contents, $maxLength ); |
2524 | 2524 | // Remove possible unfinished links |
2525 | 2525 | $contents = preg_replace( '/\[\[([^\]]*)\]?$/', '$1', $contents ); |
— | — | @@ -2542,10 +2542,10 @@ |
2543 | 2543 | |
2544 | 2544 | $reason = $this->DeleteReasonList; |
2545 | 2545 | |
2546 | | - if( $reason != 'other' && $this->DeleteReason != '' ) { |
| 2546 | + if ( $reason != 'other' && $this->DeleteReason != '' ) { |
2547 | 2547 | // Entry from drop down menu + additional comment |
2548 | 2548 | $reason .= wfMsgForContent( 'colon-separator' ) . $this->DeleteReason; |
2549 | | - } elseif( $reason == 'other' ) { |
| 2549 | + } elseif ( $reason == 'other' ) { |
2550 | 2550 | $reason = $this->DeleteReason; |
2551 | 2551 | } |
2552 | 2552 | # Flag to hide all contents of the archived revisions |
— | — | @@ -2554,7 +2554,7 @@ |
2555 | 2555 | # This code desperately needs to be totally rewritten |
2556 | 2556 | |
2557 | 2557 | # Read-only check... |
2558 | | - if( wfReadOnly() ) { |
| 2558 | + if ( wfReadOnly() ) { |
2559 | 2559 | $wgOut->readOnlyPage(); |
2560 | 2560 | return; |
2561 | 2561 | } |
— | — | @@ -2562,7 +2562,7 @@ |
2563 | 2563 | # Check permissions |
2564 | 2564 | $permission_errors = $this->mTitle->getUserPermissionsErrors( 'delete', $wgUser ); |
2565 | 2565 | |
2566 | | - if( count( $permission_errors ) > 0 ) { |
| 2566 | + if ( count( $permission_errors ) > 0 ) { |
2567 | 2567 | $wgOut->showPermissionsErrorPage( $permission_errors ); |
2568 | 2568 | return; |
2569 | 2569 | } |
— | — | @@ -2573,7 +2573,7 @@ |
2574 | 2574 | $dbw = wfGetDB( DB_MASTER ); |
2575 | 2575 | $conds = $this->mTitle->pageCond(); |
2576 | 2576 | $latest = $dbw->selectField( 'page', 'page_latest', $conds, __METHOD__ ); |
2577 | | - if( $latest === false ) { |
| 2577 | + if ( $latest === false ) { |
2578 | 2578 | $wgOut->showFatalError( |
2579 | 2579 | Html::rawElement( |
2580 | 2580 | 'div', |
— | — | @@ -2592,18 +2592,18 @@ |
2593 | 2593 | |
2594 | 2594 | # Hack for big sites |
2595 | 2595 | $bigHistory = $this->isBigDeletion(); |
2596 | | - if( $bigHistory && !$this->mTitle->userCan( 'bigdelete' ) ) { |
| 2596 | + if ( $bigHistory && !$this->mTitle->userCan( 'bigdelete' ) ) { |
2597 | 2597 | global $wgLang, $wgDeleteRevisionsLimit; |
2598 | 2598 | $wgOut->wrapWikiMsg( "<div class='error'>\n$1</div>\n", |
2599 | 2599 | array( 'delete-toobig', $wgLang->formatNum( $wgDeleteRevisionsLimit ) ) ); |
2600 | 2600 | return; |
2601 | 2601 | } |
2602 | 2602 | |
2603 | | - if( $confirm ) { |
| 2603 | + if ( $confirm ) { |
2604 | 2604 | $this->doDelete( $reason, $suppress ); |
2605 | | - if( $wgRequest->getCheck( 'wpWatch' ) && $wgUser->isLoggedIn() ) { |
| 2605 | + if ( $wgRequest->getCheck( 'wpWatch' ) && $wgUser->isLoggedIn() ) { |
2606 | 2606 | $this->doWatch(); |
2607 | | - } elseif( $this->mTitle->userIsWatching() ) { |
| 2607 | + } elseif ( $this->mTitle->userIsWatching() ) { |
2608 | 2608 | $this->doUnwatch(); |
2609 | 2609 | } |
2610 | 2610 | return; |
— | — | @@ -2611,10 +2611,10 @@ |
2612 | 2612 | |
2613 | 2613 | // Generate deletion reason |
2614 | 2614 | $hasHistory = false; |
2615 | | - if( !$reason ) $reason = $this->generateReason($hasHistory); |
| 2615 | + if ( !$reason ) $reason = $this->generateReason( $hasHistory ); |
2616 | 2616 | |
2617 | 2617 | // If the page has a history, insert a warning |
2618 | | - if( $hasHistory && !$confirm ) { |
| 2618 | + if ( $hasHistory && !$confirm ) { |
2619 | 2619 | global $wgLang; |
2620 | 2620 | $skin = $wgUser->getSkin(); |
2621 | 2621 | $revisions = $this->estimateRevisionCount(); |
— | — | @@ -2623,7 +2623,7 @@ |
2624 | 2624 | wfMsgHtml( 'word-separator' ) . $skin->historyLink() . |
2625 | 2625 | '</strong>' |
2626 | 2626 | ); |
2627 | | - if( $bigHistory ) { |
| 2627 | + if ( $bigHistory ) { |
2628 | 2628 | global $wgDeleteRevisionsLimit; |
2629 | 2629 | $wgOut->wrapWikiMsg( "<div class='error'>\n$1</div>\n", |
2630 | 2630 | array( 'delete-warning-toobig', $wgLang->formatNum( $wgDeleteRevisionsLimit ) ) ); |
— | — | @@ -2638,7 +2638,7 @@ |
2639 | 2639 | */ |
2640 | 2640 | public function isBigDeletion() { |
2641 | 2641 | global $wgDeleteRevisionsLimit; |
2642 | | - if( $wgDeleteRevisionsLimit ) { |
| 2642 | + if ( $wgDeleteRevisionsLimit ) { |
2643 | 2643 | $revCount = $this->estimateRevisionCount(); |
2644 | 2644 | return $revCount > $wgDeleteRevisionsLimit; |
2645 | 2645 | } |
— | — | @@ -2651,7 +2651,7 @@ |
2652 | 2652 | public function estimateRevisionCount() { |
2653 | 2653 | $dbr = wfGetDB( DB_SLAVE ); |
2654 | 2654 | // For an exact count... |
2655 | | - //return $dbr->selectField( 'revision', 'COUNT(*)', |
| 2655 | + // return $dbr->selectField( 'revision', 'COUNT(*)', |
2656 | 2656 | // array( 'rev_page' => $this->getId() ), __METHOD__ ); |
2657 | 2657 | return $dbr->estimateRowCount( 'revision', '*', |
2658 | 2658 | array( 'rev_page' => $this->getId() ), __METHOD__ ); |
— | — | @@ -2681,12 +2681,12 @@ |
2682 | 2682 | 'LIMIT' => $num |
2683 | 2683 | ) ) |
2684 | 2684 | ); |
2685 | | - if( !$res ) { |
| 2685 | + if ( !$res ) { |
2686 | 2686 | wfProfileOut( __METHOD__ ); |
2687 | 2687 | return array(); |
2688 | 2688 | } |
2689 | 2689 | $row = $db->fetchObject( $res ); |
2690 | | - if( $continue == 2 && $revLatest && $row->rev_id != $revLatest ) { |
| 2690 | + if ( $continue == 2 && $revLatest && $row->rev_id != $revLatest ) { |
2691 | 2691 | $db = wfGetDB( DB_MASTER ); |
2692 | 2692 | $continue--; |
2693 | 2693 | } else { |
— | — | @@ -2724,7 +2724,7 @@ |
2725 | 2725 | |
2726 | 2726 | wfRunHooks( 'ArticleConfirmDelete', array( $this, $wgOut, &$reason ) ); |
2727 | 2727 | |
2728 | | - if( $wgUser->isAllowed( 'suppressrevision' ) ) { |
| 2728 | + if ( $wgUser->isAllowed( 'suppressrevision' ) ) { |
2729 | 2729 | $suppress = "<tr id=\"wpDeleteSuppressRow\" name=\"wpDeleteSuppressRow\"> |
2730 | 2730 | <td></td> |
2731 | 2731 | <td class='mw-input'><strong>" . |
— | — | @@ -2767,7 +2767,7 @@ |
2768 | 2768 | "</td> |
2769 | 2769 | </tr>"; |
2770 | 2770 | # Dissalow watching is user is not logged in |
2771 | | - if( $wgUser->isLoggedIn() ) { |
| 2771 | + if ( $wgUser->isLoggedIn() ) { |
2772 | 2772 | $form .= " |
2773 | 2773 | <tr> |
2774 | 2774 | <td></td> |
— | — | @@ -2791,7 +2791,7 @@ |
2792 | 2792 | Xml::hidden( 'wpEditToken', $wgUser->editToken() ) . |
2793 | 2793 | Xml::closeElement( 'form' ); |
2794 | 2794 | |
2795 | | - if( $wgUser->isAllowed( 'editinterface' ) ) { |
| 2795 | + if ( $wgUser->isAllowed( 'editinterface' ) ) { |
2796 | 2796 | $skin = $wgUser->getSkin(); |
2797 | 2797 | $title = Title::makeTitle( NS_MEDIAWIKI, 'Deletereason-dropdown' ); |
2798 | 2798 | $link = $skin->link( |
— | — | @@ -2820,8 +2820,8 @@ |
2821 | 2821 | $id = $this->mTitle->getArticleID( GAID_FOR_UPDATE ); |
2822 | 2822 | |
2823 | 2823 | $error = ''; |
2824 | | - if( wfRunHooks('ArticleDelete', array(&$this, &$wgUser, &$reason, &$error)) ) { |
2825 | | - if( $this->doDeleteArticle( $reason, $suppress, $id ) ) { |
| 2824 | + if ( wfRunHooks( 'ArticleDelete', array( &$this, &$wgUser, &$reason, &$error ) ) ) { |
| 2825 | + if ( $this->doDeleteArticle( $reason, $suppress, $id ) ) { |
2826 | 2826 | $deleted = $this->mTitle->getPrefixedText(); |
2827 | 2827 | |
2828 | 2828 | $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) ); |
— | — | @@ -2831,10 +2831,10 @@ |
2832 | 2832 | |
2833 | 2833 | $wgOut->addWikiMsg( 'deletedtext', $deleted, $loglink ); |
2834 | 2834 | $wgOut->returnToMain( false ); |
2835 | | - wfRunHooks('ArticleDeleteComplete', array(&$this, &$wgUser, $reason, $id)); |
| 2835 | + wfRunHooks( 'ArticleDeleteComplete', array( &$this, &$wgUser, $reason, $id ) ); |
2836 | 2836 | } |
2837 | 2837 | } else { |
2838 | | - if( $error == '' ) { |
| 2838 | + if ( $error == '' ) { |
2839 | 2839 | $wgOut->showFatalError( |
2840 | 2840 | Html::rawElement( |
2841 | 2841 | 'div', |
— | — | @@ -2863,22 +2863,22 @@ |
2864 | 2864 | global $wgUseSquid, $wgDeferredUpdateList; |
2865 | 2865 | global $wgUseTrackbacks; |
2866 | 2866 | |
2867 | | - wfDebug( __METHOD__."\n" ); |
| 2867 | + wfDebug( __METHOD__ . "\n" ); |
2868 | 2868 | |
2869 | 2869 | $dbw = wfGetDB( DB_MASTER ); |
2870 | 2870 | $ns = $this->mTitle->getNamespace(); |
2871 | 2871 | $t = $this->mTitle->getDBkey(); |
2872 | 2872 | $id = $id ? $id : $this->mTitle->getArticleID( GAID_FOR_UPDATE ); |
2873 | 2873 | |
2874 | | - if( $t == '' || $id == 0 ) { |
| 2874 | + if ( $t == '' || $id == 0 ) { |
2875 | 2875 | return false; |
2876 | 2876 | } |
2877 | 2877 | |
2878 | | - $u = new SiteStatsUpdate( 0, 1, -(int)$this->isCountable( $this->getRawText() ), -1 ); |
| 2878 | + $u = new SiteStatsUpdate( 0, 1, - (int)$this->isCountable( $this->getRawText() ), -1 ); |
2879 | 2879 | array_push( $wgDeferredUpdateList, $u ); |
2880 | 2880 | |
2881 | 2881 | // Bitfields to further suppress the content |
2882 | | - if( $suppress ) { |
| 2882 | + if ( $suppress ) { |
2883 | 2883 | $bitfield = 0; |
2884 | 2884 | // This should be 15... |
2885 | 2885 | $bitfield |= Revision::DELETED_TEXT; |
— | — | @@ -2926,9 +2926,9 @@ |
2927 | 2927 | $dbw->delete( 'page_restrictions', array ( 'pr_page' => $id ), __METHOD__ ); |
2928 | 2928 | |
2929 | 2929 | # Now that it's safely backed up, delete it |
2930 | | - $dbw->delete( 'page', array( 'page_id' => $id ), __METHOD__); |
| 2930 | + $dbw->delete( 'page', array( 'page_id' => $id ), __METHOD__ ); |
2931 | 2931 | $ok = ( $dbw->affectedRows() > 0 ); // getArticleId() uses slave, could be laggy |
2932 | | - if( !$ok ) { |
| 2932 | + if ( !$ok ) { |
2933 | 2933 | $dbw->rollback(); |
2934 | 2934 | return false; |
2935 | 2935 | } |
— | — | @@ -2936,16 +2936,16 @@ |
2937 | 2937 | # Fix category table counts |
2938 | 2938 | $cats = array(); |
2939 | 2939 | $res = $dbw->select( 'categorylinks', 'cl_to', array( 'cl_from' => $id ), __METHOD__ ); |
2940 | | - foreach( $res as $row ) { |
2941 | | - $cats []= $row->cl_to; |
| 2940 | + foreach ( $res as $row ) { |
| 2941 | + $cats [] = $row->cl_to; |
2942 | 2942 | } |
2943 | 2943 | $this->updateCategoryCounts( array(), $cats ); |
2944 | 2944 | |
2945 | 2945 | # If using cascading deletes, we can skip some explicit deletes |
2946 | | - if( !$dbw->cascadingDeletes() ) { |
| 2946 | + if ( !$dbw->cascadingDeletes() ) { |
2947 | 2947 | $dbw->delete( 'revision', array( 'rev_page' => $id ), __METHOD__ ); |
2948 | 2948 | |
2949 | | - if($wgUseTrackbacks) |
| 2949 | + if ( $wgUseTrackbacks ) |
2950 | 2950 | $dbw->delete( 'trackbacks', array( 'tb_page' => $id ), __METHOD__ ); |
2951 | 2951 | |
2952 | 2952 | # Delete outgoing links |
— | — | @@ -2959,15 +2959,15 @@ |
2960 | 2960 | } |
2961 | 2961 | |
2962 | 2962 | # If using cleanup triggers, we can skip some manual deletes |
2963 | | - if( !$dbw->cleanupTriggers() ) { |
| 2963 | + if ( !$dbw->cleanupTriggers() ) { |
2964 | 2964 | # Clean up recentchanges entries... |
2965 | 2965 | $dbw->delete( 'recentchanges', |
2966 | | - array( 'rc_type != '.RC_LOG, |
| 2966 | + array( 'rc_type != ' . RC_LOG, |
2967 | 2967 | 'rc_namespace' => $this->mTitle->getNamespace(), |
2968 | 2968 | 'rc_title' => $this->mTitle->getDBkey() ), |
2969 | 2969 | __METHOD__ ); |
2970 | 2970 | $dbw->delete( 'recentchanges', |
2971 | | - array( 'rc_type != '.RC_LOG, 'rc_cur_id' => $id ), |
| 2971 | + array( 'rc_type != ' . RC_LOG, 'rc_cur_id' => $id ), |
2972 | 2972 | __METHOD__ ); |
2973 | 2973 | } |
2974 | 2974 | |
— | — | @@ -3019,17 +3019,17 @@ |
3020 | 3020 | $rollbackErrors = $this->mTitle->getUserPermissionsErrors( 'rollback', $wgUser ); |
3021 | 3021 | $errors = array_merge( $editErrors, wfArrayDiff2( $rollbackErrors, $editErrors ) ); |
3022 | 3022 | |
3023 | | - if( !$wgUser->matchEditToken( $token, array( $this->mTitle->getPrefixedText(), $fromP ) ) ) |
| 3023 | + if ( !$wgUser->matchEditToken( $token, array( $this->mTitle->getPrefixedText(), $fromP ) ) ) |
3024 | 3024 | $errors[] = array( 'sessionfailure' ); |
3025 | 3025 | |
3026 | | - if( $wgUser->pingLimiter( 'rollback' ) || $wgUser->pingLimiter() ) { |
| 3026 | + if ( $wgUser->pingLimiter( 'rollback' ) || $wgUser->pingLimiter() ) { |
3027 | 3027 | $errors[] = array( 'actionthrottledtext' ); |
3028 | 3028 | } |
3029 | 3029 | # If there were errors, bail out now |
3030 | | - if( !empty( $errors ) ) |
| 3030 | + if ( !empty( $errors ) ) |
3031 | 3031 | return $errors; |
3032 | 3032 | |
3033 | | - return $this->commitRollback($fromP, $summary, $bot, $resultDetails); |
| 3033 | + return $this->commitRollback( $fromP, $summary, $bot, $resultDetails ); |
3034 | 3034 | } |
3035 | 3035 | |
3036 | 3036 | /** |
— | — | @@ -3041,31 +3041,31 @@ |
3042 | 3042 | * ly if you want to use custom permissions checks. If you don't, use |
3043 | 3043 | * doRollback() instead. |
3044 | 3044 | */ |
3045 | | - public function commitRollback($fromP, $summary, $bot, &$resultDetails) { |
| 3045 | + public function commitRollback( $fromP, $summary, $bot, &$resultDetails ) { |
3046 | 3046 | global $wgUseRCPatrol, $wgUser, $wgLang; |
3047 | 3047 | $dbw = wfGetDB( DB_MASTER ); |
3048 | 3048 | |
3049 | | - if( wfReadOnly() ) { |
| 3049 | + if ( wfReadOnly() ) { |
3050 | 3050 | return array( array( 'readonlytext' ) ); |
3051 | 3051 | } |
3052 | 3052 | |
3053 | 3053 | # Get the last editor |
3054 | 3054 | $current = Revision::newFromTitle( $this->mTitle ); |
3055 | | - if( is_null( $current ) ) { |
| 3055 | + if ( is_null( $current ) ) { |
3056 | 3056 | # Something wrong... no page? |
3057 | | - return array(array('notanarticle')); |
| 3057 | + return array( array( 'notanarticle' ) ); |
3058 | 3058 | } |
3059 | 3059 | |
3060 | 3060 | $from = str_replace( '_', ' ', $fromP ); |
3061 | 3061 | # User name given should match up with the top revision. |
3062 | 3062 | # If the user was deleted then $from should be empty. |
3063 | | - if( $from != $current->getUserText() ) { |
| 3063 | + if ( $from != $current->getUserText() ) { |
3064 | 3064 | $resultDetails = array( 'current' => $current ); |
3065 | | - return array(array('alreadyrolled', |
3066 | | - htmlspecialchars($this->mTitle->getPrefixedText()), |
3067 | | - htmlspecialchars($fromP), |
3068 | | - htmlspecialchars($current->getUserText()) |
3069 | | - )); |
| 3065 | + return array( array( 'alreadyrolled', |
| 3066 | + htmlspecialchars( $this->mTitle->getPrefixedText() ), |
| 3067 | + htmlspecialchars( $fromP ), |
| 3068 | + htmlspecialchars( $current->getUserText() ) |
| 3069 | + ) ); |
3070 | 3070 | } |
3071 | 3071 | |
3072 | 3072 | # Get the last edit not by this guy... |
— | — | @@ -3080,25 +3080,25 @@ |
3081 | 3081 | array( 'USE INDEX' => 'page_timestamp', |
3082 | 3082 | 'ORDER BY' => 'rev_timestamp DESC' ) |
3083 | 3083 | ); |
3084 | | - if( $s === false ) { |
| 3084 | + if ( $s === false ) { |
3085 | 3085 | # No one else ever edited this page |
3086 | | - return array(array('cantrollback')); |
3087 | | - } else if( $s->rev_deleted & REVISION::DELETED_TEXT || $s->rev_deleted & REVISION::DELETED_USER ) { |
| 3086 | + return array( array( 'cantrollback' ) ); |
| 3087 | + } else if ( $s->rev_deleted & REVISION::DELETED_TEXT || $s->rev_deleted & REVISION::DELETED_USER ) { |
3088 | 3088 | # Only admins can see this text |
3089 | | - return array(array('notvisiblerev')); |
| 3089 | + return array( array( 'notvisiblerev' ) ); |
3090 | 3090 | } |
3091 | 3091 | |
3092 | 3092 | $set = array(); |
3093 | | - if( $bot && $wgUser->isAllowed('markbotedits') ) { |
| 3093 | + if ( $bot && $wgUser->isAllowed( 'markbotedits' ) ) { |
3094 | 3094 | # Mark all reverted edits as bot |
3095 | 3095 | $set['rc_bot'] = 1; |
3096 | 3096 | } |
3097 | | - if( $wgUseRCPatrol ) { |
| 3097 | + if ( $wgUseRCPatrol ) { |
3098 | 3098 | # Mark all reverted edits as patrolled |
3099 | 3099 | $set['rc_patrolled'] = 1; |
3100 | 3100 | } |
3101 | 3101 | |
3102 | | - if( count($set) ) { |
| 3102 | + if ( count( $set ) ) { |
3103 | 3103 | $dbw->update( 'recentchanges', $set, |
3104 | 3104 | array( /* WHERE */ |
3105 | 3105 | 'rc_cur_id' => $current->getPage(), |
— | — | @@ -3110,8 +3110,8 @@ |
3111 | 3111 | |
3112 | 3112 | # Generate the edit summary if necessary |
3113 | 3113 | $target = Revision::newFromId( $s->rev_id ); |
3114 | | - if( empty( $summary ) ) { |
3115 | | - if( $from == '' ) { // no public user name |
| 3114 | + if ( empty( $summary ) ) { |
| 3115 | + if ( $from == '' ) { // no public user name |
3116 | 3116 | $summary = wfMsgForContent( 'revertpage-nouser' ); |
3117 | 3117 | } else { |
3118 | 3118 | $summary = wfMsgForContent( 'revertpage' ); |
— | — | @@ -3121,22 +3121,22 @@ |
3122 | 3122 | # Allow the custom summary to use the same args as the default message |
3123 | 3123 | $args = array( |
3124 | 3124 | $target->getUserText(), $from, $s->rev_id, |
3125 | | - $wgLang->timeanddate(wfTimestamp(TS_MW, $s->rev_timestamp), true), |
3126 | | - $current->getId(), $wgLang->timeanddate($current->getTimestamp()) |
| 3125 | + $wgLang->timeanddate( wfTimestamp( TS_MW, $s->rev_timestamp ), true ), |
| 3126 | + $current->getId(), $wgLang->timeanddate( $current->getTimestamp() ) |
3127 | 3127 | ); |
3128 | 3128 | $summary = wfMsgReplaceArgs( $summary, $args ); |
3129 | 3129 | |
3130 | 3130 | # Save |
3131 | 3131 | $flags = EDIT_UPDATE; |
3132 | 3132 | |
3133 | | - if( $wgUser->isAllowed('minoredit') ) |
| 3133 | + if ( $wgUser->isAllowed( 'minoredit' ) ) |
3134 | 3134 | $flags |= EDIT_MINOR; |
3135 | 3135 | |
3136 | | - if( $bot && ($wgUser->isAllowed('markbotedits') || $wgUser->isAllowed('bot')) ) |
| 3136 | + if ( $bot && ( $wgUser->isAllowed( 'markbotedits' ) || $wgUser->isAllowed( 'bot' ) ) ) |
3137 | 3137 | $flags |= EDIT_FORCE_BOT; |
3138 | 3138 | # Actually store the edit |
3139 | 3139 | $status = $this->doEdit( $target->getText(), $summary, $flags, $target->getId() ); |
3140 | | - if( !empty( $status->value['revision'] ) ) { |
| 3140 | + if ( !empty( $status->value['revision'] ) ) { |
3141 | 3141 | $revId = $status->value['revision']->getId(); |
3142 | 3142 | } else { |
3143 | 3143 | $revId = false; |
— | — | @@ -3168,18 +3168,18 @@ |
3169 | 3169 | $details |
3170 | 3170 | ); |
3171 | 3171 | |
3172 | | - if( in_array( array( 'actionthrottledtext' ), $result ) ) { |
| 3172 | + if ( in_array( array( 'actionthrottledtext' ), $result ) ) { |
3173 | 3173 | $wgOut->rateLimited(); |
3174 | 3174 | return; |
3175 | 3175 | } |
3176 | | - if( isset( $result[0][0] ) && ( $result[0][0] == 'alreadyrolled' || $result[0][0] == 'cantrollback' ) ) { |
| 3176 | + if ( isset( $result[0][0] ) && ( $result[0][0] == 'alreadyrolled' || $result[0][0] == 'cantrollback' ) ) { |
3177 | 3177 | $wgOut->setPageTitle( wfMsg( 'rollbackfailed' ) ); |
3178 | 3178 | $errArray = $result[0]; |
3179 | 3179 | $errMsg = array_shift( $errArray ); |
3180 | 3180 | $wgOut->addWikiMsgArray( $errMsg, $errArray ); |
3181 | | - if( isset( $details['current'] ) ){ |
| 3181 | + if ( isset( $details['current'] ) ) { |
3182 | 3182 | $current = $details['current']; |
3183 | | - if( $current->getComment() != '' ) { |
| 3183 | + if ( $current->getComment() != '' ) { |
3184 | 3184 | $wgOut->addWikiMsgArray( 'editcomment', array( |
3185 | 3185 | $wgUser->getSkin()->formatComment( $current->getComment() ) ), array( 'replaceafter' ) ); |
3186 | 3186 | } |
— | — | @@ -3189,19 +3189,19 @@ |
3190 | 3190 | # Display permissions errors before read-only message -- there's no |
3191 | 3191 | # point in misleading the user into thinking the inability to rollback |
3192 | 3192 | # is only temporary. |
3193 | | - if( !empty( $result ) && $result !== array( array( 'readonlytext' ) ) ) { |
| 3193 | + if ( !empty( $result ) && $result !== array( array( 'readonlytext' ) ) ) { |
3194 | 3194 | # array_diff is completely broken for arrays of arrays, sigh. Re- |
3195 | 3195 | # move any 'readonlytext' error manually. |
3196 | 3196 | $out = array(); |
3197 | | - foreach( $result as $error ) { |
3198 | | - if( $error != array( 'readonlytext' ) ) { |
3199 | | - $out []= $error; |
| 3197 | + foreach ( $result as $error ) { |
| 3198 | + if ( $error != array( 'readonlytext' ) ) { |
| 3199 | + $out [] = $error; |
3200 | 3200 | } |
3201 | 3201 | } |
3202 | 3202 | $wgOut->showPermissionsErrorPage( $out ); |
3203 | 3203 | return; |
3204 | 3204 | } |
3205 | | - if( $result == array( array( 'readonlytext' ) ) ) { |
| 3205 | + if ( $result == array( array( 'readonlytext' ) ) ) { |
3206 | 3206 | $wgOut->readOnlyPage(); |
3207 | 3207 | return; |
3208 | 3208 | } |
— | — | @@ -3222,7 +3222,7 @@ |
3223 | 3223 | $wgOut->addHTML( wfMsgExt( 'rollback-success', array( 'parse', 'replaceafter' ), $old, $new ) ); |
3224 | 3224 | $wgOut->returnToMain( false, $this->mTitle ); |
3225 | 3225 | |
3226 | | - if( !$wgRequest->getBool( 'hidediff', false ) && !$wgUser->getBoolOption( 'norollbackdiff', false ) ) { |
| 3226 | + if ( !$wgRequest->getBool( 'hidediff', false ) && !$wgUser->getBoolOption( 'norollbackdiff', false ) ) { |
3227 | 3227 | $de = new DifferenceEngine( $this->mTitle, $current->getId(), $newId, false, true ); |
3228 | 3228 | $de->showDiff( '', '' ); |
3229 | 3229 | } |
— | — | @@ -3238,7 +3238,7 @@ |
3239 | 3239 | return; |
3240 | 3240 | } |
3241 | 3241 | # Don't update page view counters on views from bot users (bug 14044) |
3242 | | - if( !$wgDisableCounters && !$wgUser->isAllowed('bot') && $this->getID() ) { |
| 3242 | + if ( !$wgDisableCounters && !$wgUser->isAllowed( 'bot' ) && $this->getID() ) { |
3243 | 3243 | Article::incViewCount( $this->getID() ); |
3244 | 3244 | $u = new SiteStatsUpdate( 1, 0, 0 ); |
3245 | 3245 | array_push( $wgDeferredUpdateList, $u ); |
— | — | @@ -3251,8 +3251,8 @@ |
3252 | 3252 | * Prepare text which is about to be saved. |
3253 | 3253 | * Returns a stdclass with source, pst and output members |
3254 | 3254 | */ |
3255 | | - public function prepareTextForEdit( $text, $revid=null ) { |
3256 | | - if( $this->mPreparedEdit && $this->mPreparedEdit->newText == $text && $this->mPreparedEdit->revid == $revid) { |
| 3255 | + public function prepareTextForEdit( $text, $revid = null ) { |
| 3256 | + if ( $this->mPreparedEdit && $this->mPreparedEdit->newText == $text && $this->mPreparedEdit->revid == $revid ) { |
3257 | 3257 | // Already prepared |
3258 | 3258 | return $this->mPreparedEdit; |
3259 | 3259 | } |
— | — | @@ -3289,7 +3289,7 @@ |
3290 | 3290 | |
3291 | 3291 | # Parse the text |
3292 | 3292 | # Be careful not to double-PST: $text is usually already PST-ed once |
3293 | | - if( !$this->mPreparedEdit || $this->mPreparedEdit->output->getFlag( 'vary-revision' ) ) { |
| 3293 | + if ( !$this->mPreparedEdit || $this->mPreparedEdit->output->getFlag( 'vary-revision' ) ) { |
3294 | 3294 | wfDebug( __METHOD__ . ": No prepared edit or vary-revision is set...\n" ); |
3295 | 3295 | $editInfo = $this->prepareTextForEdit( $text, $newid ); |
3296 | 3296 | } else { |
— | — | @@ -3298,7 +3298,7 @@ |
3299 | 3299 | } |
3300 | 3300 | |
3301 | 3301 | # Save it to the parser cache |
3302 | | - if( $wgEnableParserCache ) { |
| 3302 | + if ( $wgEnableParserCache ) { |
3303 | 3303 | $popts = $this->getParserOptions(); |
3304 | 3304 | $parserCache = ParserCache::singleton(); |
3305 | 3305 | $parserCache->save( $editInfo->output, $this, $popts ); |
— | — | @@ -3310,8 +3310,8 @@ |
3311 | 3311 | |
3312 | 3312 | wfRunHooks( 'ArticleEditUpdates', array( &$this, &$editInfo, $changed ) ); |
3313 | 3313 | |
3314 | | - if( wfRunHooks( 'ArticleEditUpdatesDeleteFromRecentchanges', array( &$this ) ) ) { |
3315 | | - if( 0 == mt_rand( 0, 99 ) ) { |
| 3314 | + if ( wfRunHooks( 'ArticleEditUpdatesDeleteFromRecentchanges', array( &$this ) ) ) { |
| 3315 | + if ( 0 == mt_rand( 0, 99 ) ) { |
3316 | 3316 | // Flush old entries from the `recentchanges` table; we do this on |
3317 | 3317 | // random requests so as to avoid an increase in writes for no good reason |
3318 | 3318 | global $wgRCMaxAge; |
— | — | @@ -3327,7 +3327,7 @@ |
3328 | 3328 | $title = $this->mTitle->getPrefixedDBkey(); |
3329 | 3329 | $shortTitle = $this->mTitle->getDBkey(); |
3330 | 3330 | |
3331 | | - if( 0 == $id ) { |
| 3331 | + if ( 0 == $id ) { |
3332 | 3332 | wfProfileOut( __METHOD__ ); |
3333 | 3333 | return; |
3334 | 3334 | } |
— | — | @@ -3341,24 +3341,24 @@ |
3342 | 3342 | # Don't do this if $changed = false otherwise some idiot can null-edit a |
3343 | 3343 | # load of user talk pages and piss people off, nor if it's a minor edit |
3344 | 3344 | # by a properly-flagged bot. |
3345 | | - if( $this->mTitle->getNamespace() == NS_USER_TALK && $shortTitle != $wgUser->getTitleKey() && $changed |
| 3345 | + if ( $this->mTitle->getNamespace() == NS_USER_TALK && $shortTitle != $wgUser->getTitleKey() && $changed |
3346 | 3346 | && !( $minoredit && $wgUser->isAllowed( 'nominornewtalk' ) ) ) { |
3347 | | - if( wfRunHooks('ArticleEditUpdateNewTalk', array( &$this ) ) ) { |
| 3347 | + if ( wfRunHooks( 'ArticleEditUpdateNewTalk', array( &$this ) ) ) { |
3348 | 3348 | $other = User::newFromName( $shortTitle, false ); |
3349 | | - if( !$other ) { |
3350 | | - wfDebug( __METHOD__.": invalid username\n" ); |
3351 | | - } elseif( User::isIP( $shortTitle ) ) { |
| 3349 | + if ( !$other ) { |
| 3350 | + wfDebug( __METHOD__ . ": invalid username\n" ); |
| 3351 | + } elseif ( User::isIP( $shortTitle ) ) { |
3352 | 3352 | // An anonymous user |
3353 | 3353 | $other->setNewtalk( true ); |
3354 | | - } elseif( $other->isLoggedIn() ) { |
| 3354 | + } elseif ( $other->isLoggedIn() ) { |
3355 | 3355 | $other->setNewtalk( true ); |
3356 | 3356 | } else { |
3357 | | - wfDebug( __METHOD__. ": don't need to notify a nonexistent user\n" ); |
| 3357 | + wfDebug( __METHOD__ . ": don't need to notify a nonexistent user\n" ); |
3358 | 3358 | } |
3359 | 3359 | } |
3360 | 3360 | } |
3361 | 3361 | |
3362 | | - if( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
| 3362 | + if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
3363 | 3363 | $wgMessageCache->replace( $shortTitle, $text ); |
3364 | 3364 | } |
3365 | 3365 | |
— | — | @@ -3392,15 +3392,15 @@ |
3393 | 3393 | public function setOldSubtitle( $oldid = 0 ) { |
3394 | 3394 | global $wgLang, $wgOut, $wgUser, $wgRequest; |
3395 | 3395 | |
3396 | | - if( !wfRunHooks( 'DisplayOldSubtitle', array( &$this, &$oldid ) ) ) { |
| 3396 | + if ( !wfRunHooks( 'DisplayOldSubtitle', array( &$this, &$oldid ) ) ) { |
3397 | 3397 | return; |
3398 | 3398 | } |
3399 | 3399 | |
3400 | | - $unhide = $wgRequest->getInt('unhide') == 1 && |
3401 | | - $wgUser->matchEditToken( $wgRequest->getVal('token'), $oldid ); |
| 3400 | + $unhide = $wgRequest->getInt( 'unhide' ) == 1 && |
| 3401 | + $wgUser->matchEditToken( $wgRequest->getVal( 'token' ), $oldid ); |
3402 | 3402 | # Cascade unhide param in links for easy deletion browsing |
3403 | 3403 | $extraParams = array(); |
3404 | | - if( $wgRequest->getVal('unhide') ) { |
| 3404 | + if ( $wgRequest->getVal( 'unhide' ) ) { |
3405 | 3405 | $extraParams['unhide'] = 1; |
3406 | 3406 | } |
3407 | 3407 | $revision = Revision::newFromId( $oldid ); |
— | — | @@ -3484,8 +3484,8 @@ |
3485 | 3485 | $cdel = ''; |
3486 | 3486 | // User can delete revisions or view deleted revisions... |
3487 | 3487 | $canHide = $wgUser->isAllowed( 'deleterevision' ); |
3488 | | - if( $canHide || ($revision->getVisibility() && $wgUser->isAllowed('deletedhistory')) ) { |
3489 | | - if( !$revision->userCan( Revision::DELETED_RESTRICTED ) ) { |
| 3488 | + if ( $canHide || ( $revision->getVisibility() && $wgUser->isAllowed( 'deletedhistory' ) ) ) { |
| 3489 | + if ( !$revision->userCan( Revision::DELETED_RESTRICTED ) ) { |
3490 | 3490 | $cdel = $sk->revDeleteLinkDisabled( $canHide ); // rev was hidden from Sysops |
3491 | 3491 | } else { |
3492 | 3492 | $query = array( |
— | — | @@ -3493,7 +3493,7 @@ |
3494 | 3494 | 'target' => $this->mTitle->getPrefixedDbkey(), |
3495 | 3495 | 'ids' => $oldid |
3496 | 3496 | ); |
3497 | | - $cdel = $sk->revDeleteLink( $query, $revision->isDeleted(File::DELETED_RESTRICTED), $canHide ); |
| 3497 | + $cdel = $sk->revDeleteLink( $query, $revision->isDeleted( File::DELETED_RESTRICTED ), $canHide ); |
3498 | 3498 | } |
3499 | 3499 | $cdel .= ' '; |
3500 | 3500 | } |
— | — | @@ -3543,20 +3543,20 @@ |
3544 | 3544 | */ |
3545 | 3545 | protected function tryFileCache() { |
3546 | 3546 | static $called = false; |
3547 | | - if( $called ) { |
| 3547 | + if ( $called ) { |
3548 | 3548 | wfDebug( "Article::tryFileCache(): called twice!?\n" ); |
3549 | 3549 | return false; |
3550 | 3550 | } |
3551 | 3551 | $called = true; |
3552 | | - if( $this->isFileCacheable() ) { |
| 3552 | + if ( $this->isFileCacheable() ) { |
3553 | 3553 | $cache = new HTMLFileCache( $this->mTitle ); |
3554 | | - if( $cache->isFileCacheGood( $this->mTouched ) ) { |
| 3554 | + if ( $cache->isFileCacheGood( $this->mTouched ) ) { |
3555 | 3555 | wfDebug( "Article::tryFileCache(): about to load file\n" ); |
3556 | 3556 | $cache->loadFromFileCache(); |
3557 | 3557 | return true; |
3558 | 3558 | } else { |
3559 | 3559 | wfDebug( "Article::tryFileCache(): starting buffer\n" ); |
3560 | | - ob_start( array(&$cache, 'saveToFileCache' ) ); |
| 3560 | + ob_start( array( &$cache, 'saveToFileCache' ) ); |
3561 | 3561 | } |
3562 | 3562 | } else { |
3563 | 3563 | wfDebug( "Article::tryFileCache(): not cacheable\n" ); |
— | — | @@ -3570,10 +3570,10 @@ |
3571 | 3571 | */ |
3572 | 3572 | public function isFileCacheable() { |
3573 | 3573 | $cacheable = false; |
3574 | | - if( HTMLFileCache::useFileCache() ) { |
| 3574 | + if ( HTMLFileCache::useFileCache() ) { |
3575 | 3575 | $cacheable = $this->getID() && !$this->mRedirectedFrom; |
3576 | 3576 | // Extension may have reason to disable file caching on some pages. |
3577 | | - if( $cacheable ) { |
| 3577 | + if ( $cacheable ) { |
3578 | 3578 | $cacheable = wfRunHooks( 'IsFileCacheable', array( &$this ) ); |
3579 | 3579 | } |
3580 | 3580 | } |
— | — | @@ -3585,7 +3585,7 @@ |
3586 | 3586 | * |
3587 | 3587 | */ |
3588 | 3588 | public function checkTouched() { |
3589 | | - if( !$this->mDataLoaded ) { |
| 3589 | + if ( !$this->mDataLoaded ) { |
3590 | 3590 | $this->loadPageData(); |
3591 | 3591 | } |
3592 | 3592 | return !$this->mIsRedirect; |
— | — | @@ -3596,7 +3596,7 @@ |
3597 | 3597 | */ |
3598 | 3598 | public function getTouched() { |
3599 | 3599 | # Ensure that page data has been loaded |
3600 | | - if( !$this->mDataLoaded ) { |
| 3600 | + if ( !$this->mDataLoaded ) { |
3601 | 3601 | $this->loadPageData(); |
3602 | 3602 | } |
3603 | 3603 | return $this->mTouched; |
— | — | @@ -3606,7 +3606,7 @@ |
3607 | 3607 | * Get the page_latest field |
3608 | 3608 | */ |
3609 | 3609 | public function getLatest() { |
3610 | | - if( !$this->mDataLoaded ) { |
| 3610 | + if ( !$this->mDataLoaded ) { |
3611 | 3611 | $this->loadPageData(); |
3612 | 3612 | } |
3613 | 3613 | return (int)$this->mLatest; |
— | — | @@ -3634,7 +3634,7 @@ |
3635 | 3635 | $revision->insertOn( $dbw ); |
3636 | 3636 | $this->updateRevisionOn( $dbw, $revision ); |
3637 | 3637 | |
3638 | | - wfRunHooks( 'NewRevisionFromEditComplete', array($this, $revision, false, $wgUser) ); |
| 3638 | + wfRunHooks( 'NewRevisionFromEditComplete', array( $this, $revision, false, $wgUser ) ); |
3639 | 3639 | |
3640 | 3640 | wfProfileOut( __METHOD__ ); |
3641 | 3641 | } |
— | — | @@ -3653,7 +3653,7 @@ |
3654 | 3654 | $hitcounterTable = $dbw->tableName( 'hitcounter' ); |
3655 | 3655 | $acchitsTable = $dbw->tableName( 'acchits' ); |
3656 | 3656 | |
3657 | | - if( $wgHitcounterUpdateFreq <= 1 ) { |
| 3657 | + if ( $wgHitcounterUpdateFreq <= 1 ) { |
3658 | 3658 | $dbw->query( "UPDATE $pageTable SET page_counter = page_counter + 1 WHERE page_id = $id" ); |
3659 | 3659 | return; |
3660 | 3660 | } |
— | — | @@ -3663,34 +3663,34 @@ |
3664 | 3664 | |
3665 | 3665 | $dbw->query( "INSERT INTO $hitcounterTable (hc_id) VALUES ({$id})" ); |
3666 | 3666 | |
3667 | | - $checkfreq = intval( $wgHitcounterUpdateFreq/25 + 1 ); |
3668 | | - if( (rand() % $checkfreq != 0) or ($dbw->lastErrno() != 0) ){ |
| 3667 | + $checkfreq = intval( $wgHitcounterUpdateFreq / 25 + 1 ); |
| 3668 | + if ( ( rand() % $checkfreq != 0 ) or ( $dbw->lastErrno() != 0 ) ) { |
3669 | 3669 | # Most of the time (or on SQL errors), skip row count check |
3670 | 3670 | $dbw->ignoreErrors( $oldignore ); |
3671 | 3671 | return; |
3672 | 3672 | } |
3673 | 3673 | |
3674 | | - $res = $dbw->query("SELECT COUNT(*) as n FROM $hitcounterTable"); |
| 3674 | + $res = $dbw->query( "SELECT COUNT(*) as n FROM $hitcounterTable" ); |
3675 | 3675 | $row = $dbw->fetchObject( $res ); |
3676 | 3676 | $rown = intval( $row->n ); |
3677 | | - if( $rown >= $wgHitcounterUpdateFreq ){ |
| 3677 | + if ( $rown >= $wgHitcounterUpdateFreq ) { |
3678 | 3678 | wfProfileIn( 'Article::incViewCount-collect' ); |
3679 | 3679 | $old_user_abort = ignore_user_abort( true ); |
3680 | 3680 | |
3681 | 3681 | $dbType = $dbw->getType(); |
3682 | 3682 | $dbw->lockTables( array(), array( 'hitcounter' ), __METHOD__, false ); |
3683 | 3683 | $tabletype = $dbType == 'mysql' ? "ENGINE=HEAP " : ''; |
3684 | | - $dbw->query( "CREATE TEMPORARY TABLE $acchitsTable $tabletype AS ". |
3685 | | - "SELECT hc_id,COUNT(*) AS hc_n FROM $hitcounterTable ". |
| 3684 | + $dbw->query( "CREATE TEMPORARY TABLE $acchitsTable $tabletype AS " . |
| 3685 | + "SELECT hc_id,COUNT(*) AS hc_n FROM $hitcounterTable " . |
3686 | 3686 | 'GROUP BY hc_id', __METHOD__ ); |
3687 | 3687 | $dbw->delete( 'hitcounter', '*', __METHOD__ ); |
3688 | 3688 | $dbw->unlockTables( __METHOD__ ); |
3689 | | - if( $dbType == 'mysql' ) { |
3690 | | - $dbw->query( "UPDATE $pageTable,$acchitsTable SET page_counter=page_counter + hc_n ". |
| 3689 | + if ( $dbType == 'mysql' ) { |
| 3690 | + $dbw->query( "UPDATE $pageTable,$acchitsTable SET page_counter=page_counter + hc_n " . |
3691 | 3691 | 'WHERE page_id = hc_id', __METHOD__ ); |
3692 | 3692 | } |
3693 | 3693 | else { |
3694 | | - $dbw->query( "UPDATE $pageTable SET page_counter=page_counter + hc_n ". |
| 3694 | + $dbw->query( "UPDATE $pageTable SET page_counter=page_counter + hc_n " . |
3695 | 3695 | "FROM $acchitsTable WHERE page_id = hc_id", __METHOD__ ); |
3696 | 3696 | } |
3697 | 3697 | $dbw->query( "DROP TABLE $acchitsTable", __METHOD__ ); |
— | — | @@ -3714,7 +3714,7 @@ |
3715 | 3715 | */ |
3716 | 3716 | public static function onArticleCreate( $title ) { |
3717 | 3717 | # Update existence markers on article/talk tabs... |
3718 | | - if( $title->isTalkPage() ) { |
| 3718 | + if ( $title->isTalkPage() ) { |
3719 | 3719 | $other = $title->getSubjectPage(); |
3720 | 3720 | } else { |
3721 | 3721 | $other = $title->getTalkPage(); |
— | — | @@ -3730,7 +3730,7 @@ |
3731 | 3731 | public static function onArticleDelete( $title ) { |
3732 | 3732 | global $wgMessageCache; |
3733 | 3733 | # Update existence markers on article/talk tabs... |
3734 | | - if( $title->isTalkPage() ) { |
| 3734 | + if ( $title->isTalkPage() ) { |
3735 | 3735 | $other = $title->getSubjectPage(); |
3736 | 3736 | } else { |
3737 | 3737 | $other = $title->getTalkPage(); |
— | — | @@ -3745,16 +3745,16 @@ |
3746 | 3746 | HTMLFileCache::clearFileCache( $title ); |
3747 | 3747 | |
3748 | 3748 | # Messages |
3749 | | - if( $title->getNamespace() == NS_MEDIAWIKI ) { |
| 3749 | + if ( $title->getNamespace() == NS_MEDIAWIKI ) { |
3750 | 3750 | $wgMessageCache->replace( $title->getDBkey(), false ); |
3751 | 3751 | } |
3752 | 3752 | # Images |
3753 | | - if( $title->getNamespace() == NS_FILE ) { |
| 3753 | + if ( $title->getNamespace() == NS_FILE ) { |
3754 | 3754 | $update = new HTMLCacheUpdate( $title, 'imagelinks' ); |
3755 | 3755 | $update->doUpdate(); |
3756 | 3756 | } |
3757 | 3757 | # User talk pages |
3758 | | - if( $title->getNamespace() == NS_USER_TALK ) { |
| 3758 | + if ( $title->getNamespace() == NS_USER_TALK ) { |
3759 | 3759 | $user = User::newFromName( $title->getText(), false ); |
3760 | 3760 | $user->setNewtalk( false ); |
3761 | 3761 | } |
— | — | @@ -3799,7 +3799,7 @@ |
3800 | 3800 | public function info() { |
3801 | 3801 | global $wgLang, $wgOut, $wgAllowPageInfo, $wgUser; |
3802 | 3802 | |
3803 | | - if( !$wgAllowPageInfo ) { |
| 3803 | + if ( !$wgAllowPageInfo ) { |
3804 | 3804 | $wgOut->showErrorPage( 'nosuchaction', 'nosuchactiontext' ); |
3805 | 3805 | return; |
3806 | 3806 | } |
— | — | @@ -3810,9 +3810,9 @@ |
3811 | 3811 | $wgOut->setPageTitleActionText( wfMsg( 'info_short' ) ); |
3812 | 3812 | $wgOut->setSubtitle( wfMsgHtml( 'infosubtitle' ) ); |
3813 | 3813 | |
3814 | | - if( !$this->mTitle->exists() ) { |
| 3814 | + if ( !$this->mTitle->exists() ) { |
3815 | 3815 | $wgOut->addHTML( '<div class="noarticletext">' ); |
3816 | | - if( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
| 3816 | + if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
3817 | 3817 | // This doesn't quite make sense; the user is asking for |
3818 | 3818 | // information about the _page_, not the message... -- RC |
3819 | 3819 | $wgOut->addHTML( htmlspecialchars( wfMsgWeirdKey( $this->mTitle->getText() ) ) ); |
— | — | @@ -3838,14 +3838,14 @@ |
3839 | 3839 | $pageInfo = $this->pageCountInfo( $page ); |
3840 | 3840 | $talkInfo = $this->pageCountInfo( $page->getTalkPage() ); |
3841 | 3841 | |
3842 | | - $wgOut->addHTML( "<ul><li>" . wfMsg("numwatchers", $wgLang->formatNum( $numwatchers ) ) . '</li>' ); |
3843 | | - $wgOut->addHTML( "<li>" . wfMsg('numedits', $wgLang->formatNum( $pageInfo['edits'] ) ) . '</li>'); |
3844 | | - if( $talkInfo ) { |
3845 | | - $wgOut->addHTML( '<li>' . wfMsg("numtalkedits", $wgLang->formatNum( $talkInfo['edits'] ) ) . '</li>'); |
| 3842 | + $wgOut->addHTML( "<ul><li>" . wfMsg( "numwatchers", $wgLang->formatNum( $numwatchers ) ) . '</li>' ); |
| 3843 | + $wgOut->addHTML( "<li>" . wfMsg( 'numedits', $wgLang->formatNum( $pageInfo['edits'] ) ) . '</li>' ); |
| 3844 | + if ( $talkInfo ) { |
| 3845 | + $wgOut->addHTML( '<li>' . wfMsg( "numtalkedits", $wgLang->formatNum( $talkInfo['edits'] ) ) . '</li>' ); |
3846 | 3846 | } |
3847 | | - $wgOut->addHTML( '<li>' . wfMsg("numauthors", $wgLang->formatNum( $pageInfo['authors'] ) ) . '</li>' ); |
3848 | | - if( $talkInfo ) { |
3849 | | - $wgOut->addHTML( '<li>' . wfMsg('numtalkauthors', $wgLang->formatNum( $talkInfo['authors'] ) ) . '</li>' ); |
| 3847 | + $wgOut->addHTML( '<li>' . wfMsg( "numauthors", $wgLang->formatNum( $pageInfo['authors'] ) ) . '</li>' ); |
| 3848 | + if ( $talkInfo ) { |
| 3849 | + $wgOut->addHTML( '<li>' . wfMsg( 'numtalkauthors', $wgLang->formatNum( $talkInfo['authors'] ) ) . '</li>' ); |
3850 | 3850 | } |
3851 | 3851 | $wgOut->addHTML( '</ul>' ); |
3852 | 3852 | } |
— | — | @@ -3860,7 +3860,7 @@ |
3861 | 3861 | */ |
3862 | 3862 | public function pageCountInfo( $title ) { |
3863 | 3863 | $id = $title->getArticleId(); |
3864 | | - if( $id == 0 ) { |
| 3864 | + if ( $id == 0 ) { |
3865 | 3865 | return false; |
3866 | 3866 | } |
3867 | 3867 | $dbr = wfGetDB( DB_SLAVE ); |
— | — | @@ -3891,7 +3891,7 @@ |
3892 | 3892 | public function getUsedTemplates() { |
3893 | 3893 | $result = array(); |
3894 | 3894 | $id = $this->mTitle->getArticleID(); |
3895 | | - if( $id == 0 ) { |
| 3895 | + if ( $id == 0 ) { |
3896 | 3896 | return array(); |
3897 | 3897 | } |
3898 | 3898 | $dbr = wfGetDB( DB_SLAVE ); |
— | — | @@ -3899,8 +3899,8 @@ |
3900 | 3900 | array( 'tl_namespace', 'tl_title' ), |
3901 | 3901 | array( 'tl_from' => $id ), |
3902 | 3902 | __METHOD__ ); |
3903 | | - if( $res !== false ) { |
3904 | | - foreach( $res as $row ) { |
| 3903 | + if ( $res !== false ) { |
| 3904 | + foreach ( $res as $row ) { |
3905 | 3905 | $result[] = Title::makeTitle( $row->tl_namespace, $row->tl_title ); |
3906 | 3906 | } |
3907 | 3907 | } |
— | — | @@ -3917,17 +3917,17 @@ |
3918 | 3918 | public function getHiddenCategories() { |
3919 | 3919 | $result = array(); |
3920 | 3920 | $id = $this->mTitle->getArticleID(); |
3921 | | - if( $id == 0 ) { |
| 3921 | + if ( $id == 0 ) { |
3922 | 3922 | return array(); |
3923 | 3923 | } |
3924 | 3924 | $dbr = wfGetDB( DB_SLAVE ); |
3925 | 3925 | $res = $dbr->select( array( 'categorylinks', 'page_props', 'page' ), |
3926 | 3926 | array( 'cl_to' ), |
3927 | 3927 | array( 'cl_from' => $id, 'pp_page=page_id', 'pp_propname' => 'hiddencat', |
3928 | | - 'page_namespace' => NS_CATEGORY, 'page_title=cl_to'), |
| 3928 | + 'page_namespace' => NS_CATEGORY, 'page_title=cl_to' ), |
3929 | 3929 | __METHOD__ ); |
3930 | | - if( $res !== false ) { |
3931 | | - foreach( $res as $row ) { |
| 3930 | + if ( $res !== false ) { |
| 3931 | + foreach ( $res as $row ) { |
3932 | 3932 | $result[] = Title::makeTitle( NS_CATEGORY, $row->cl_to ); |
3933 | 3933 | } |
3934 | 3934 | } |
— | — | @@ -3948,24 +3948,24 @@ |
3949 | 3949 | # Redirect autosummaries |
3950 | 3950 | $ot = Title::newFromRedirect( $oldtext ); |
3951 | 3951 | $rt = Title::newFromRedirect( $newtext ); |
3952 | | - if( is_object( $rt ) && ( !is_object( $ot ) || !$rt->equals( $ot ) || $ot->getFragment() != $rt->getFragment() ) ) { |
| 3952 | + if ( is_object( $rt ) && ( !is_object( $ot ) || !$rt->equals( $ot ) || $ot->getFragment() != $rt->getFragment() ) ) { |
3953 | 3953 | return wfMsgForContent( 'autoredircomment', $rt->getFullText() ); |
3954 | 3954 | } |
3955 | 3955 | |
3956 | 3956 | # New page autosummaries |
3957 | | - if( $flags & EDIT_NEW && strlen( $newtext ) ) { |
| 3957 | + if ( $flags & EDIT_NEW && strlen( $newtext ) ) { |
3958 | 3958 | # If they're making a new article, give its text, truncated, in the summary. |
3959 | 3959 | global $wgContLang; |
3960 | 3960 | $truncatedtext = $wgContLang->truncate( |
3961 | | - str_replace("\n", ' ', $newtext), |
| 3961 | + str_replace( "\n", ' ', $newtext ), |
3962 | 3962 | max( 0, 200 - strlen( wfMsgForContent( 'autosumm-new' ) ) ) ); |
3963 | 3963 | return wfMsgForContent( 'autosumm-new', $truncatedtext ); |
3964 | 3964 | } |
3965 | 3965 | |
3966 | 3966 | # Blanking autosummaries |
3967 | | - if( $oldtext != '' && $newtext == '' ) { |
| 3967 | + if ( $oldtext != '' && $newtext == '' ) { |
3968 | 3968 | return wfMsgForContent( 'autosumm-blank' ); |
3969 | | - } elseif( strlen( $oldtext ) > 10 * strlen( $newtext ) && strlen( $newtext ) < 500) { |
| 3969 | + } elseif ( strlen( $oldtext ) > 10 * strlen( $newtext ) && strlen( $newtext ) < 500 ) { |
3970 | 3970 | # Removing more than 90% of the article |
3971 | 3971 | global $wgContLang; |
3972 | 3972 | $truncatedtext = $wgContLang->truncate( |
— | — | @@ -4006,25 +4006,25 @@ |
4007 | 4007 | $parserOptions = $this->getParserOptions(); |
4008 | 4008 | } |
4009 | 4009 | |
4010 | | - $time = -wfTime(); |
| 4010 | + $time = - wfTime(); |
4011 | 4011 | $this->mParserOutput = $wgParser->parse( $text, $this->mTitle, |
4012 | 4012 | $parserOptions, true, true, $this->getRevIdFetched() ); |
4013 | 4013 | $time += wfTime(); |
4014 | 4014 | |
4015 | 4015 | # Timing hack |
4016 | | - if( $time > 3 ) { |
| 4016 | + if ( $time > 3 ) { |
4017 | 4017 | wfDebugLog( 'slow-parse', sprintf( "%-5.2f %s", $time, |
4018 | | - $this->mTitle->getPrefixedDBkey())); |
| 4018 | + $this->mTitle->getPrefixedDBkey() ) ); |
4019 | 4019 | } |
4020 | 4020 | |
4021 | | - if( $wgEnableParserCache && $cache && $this && $this->mParserOutput->getCacheTime() != -1 ) { |
| 4021 | + if ( $wgEnableParserCache && $cache && $this && $this->mParserOutput->getCacheTime() != -1 ) { |
4022 | 4022 | $parserCache = ParserCache::singleton(); |
4023 | 4023 | $parserCache->save( $this->mParserOutput, $this, $parserOptions ); |
4024 | 4024 | } |
4025 | 4025 | // Make sure file cache is not used on uncacheable content. |
4026 | 4026 | // Output that has magic words in it can still use the parser cache |
4027 | 4027 | // (if enabled), though it will generally expire sooner. |
4028 | | - if( $this->mParserOutput->getCacheTime() == -1 || $this->mParserOutput->containsOldMagic() ) { |
| 4028 | + if ( $this->mParserOutput->getCacheTime() == -1 || $this->mParserOutput->containsOldMagic() ) { |
4029 | 4029 | $wgUseFileCache = false; |
4030 | 4030 | } |
4031 | 4031 | $this->doCascadeProtectionUpdates( $this->mParserOutput ); |
— | — | @@ -4045,7 +4045,7 @@ |
4046 | 4046 | } |
4047 | 4047 | |
4048 | 4048 | protected function doCascadeProtectionUpdates( $parserOutput ) { |
4049 | | - if( !$this->isCurrent() || wfReadOnly() || !$this->mTitle->areRestrictionsCascading() ) { |
| 4049 | + if ( !$this->isCurrent() || wfReadOnly() || !$this->mTitle->areRestrictionsCascading() ) { |
4050 | 4050 | return; |
4051 | 4051 | } |
4052 | 4052 | |
— | — | @@ -4068,7 +4068,7 @@ |
4069 | 4069 | __METHOD__ ); |
4070 | 4070 | |
4071 | 4071 | global $wgContLang; |
4072 | | - foreach( $res as $row ) { |
| 4072 | + foreach ( $res as $row ) { |
4073 | 4073 | $tlTemplates["{$row->tl_namespace}:{$row->tl_title}"] = true; |
4074 | 4074 | } |
4075 | 4075 | |
— | — | @@ -4084,7 +4084,7 @@ |
4085 | 4085 | # Note that we simulate array_diff_key in PHP <5.0.x |
4086 | 4086 | $templates_diff = array_diff_key( $poTemplates, $tlTemplates ); |
4087 | 4087 | |
4088 | | - if( count( $templates_diff ) > 0 ) { |
| 4088 | + if ( count( $templates_diff ) > 0 ) { |
4089 | 4089 | # Whee, link updates time. |
4090 | 4090 | $u = new LinksUpdate( $this->mTitle, $parserOutput, false ); |
4091 | 4091 | $u->doUpdate(); |
— | — | @@ -4110,12 +4110,12 @@ |
4111 | 4111 | # |
4112 | 4112 | # Sometimes I wish we had INSERT ... ON DUPLICATE KEY UPDATE. |
4113 | 4113 | $insertCats = array_merge( $added, $deleted ); |
4114 | | - if( !$insertCats ) { |
| 4114 | + if ( !$insertCats ) { |
4115 | 4115 | # Okay, nothing to do |
4116 | 4116 | return; |
4117 | 4117 | } |
4118 | 4118 | $insertRows = array(); |
4119 | | - foreach( $insertCats as $cat ) { |
| 4119 | + foreach ( $insertCats as $cat ) { |
4120 | 4120 | $insertRows[] = array( |
4121 | 4121 | 'cat_id' => $dbw->nextSequenceValue( 'category_cat_id_seq' ), |
4122 | 4122 | 'cat_title' => $cat |
— | — | @@ -4125,15 +4125,15 @@ |
4126 | 4126 | |
4127 | 4127 | $addFields = array( 'cat_pages = cat_pages + 1' ); |
4128 | 4128 | $removeFields = array( 'cat_pages = cat_pages - 1' ); |
4129 | | - if( $ns == NS_CATEGORY ) { |
| 4129 | + if ( $ns == NS_CATEGORY ) { |
4130 | 4130 | $addFields[] = 'cat_subcats = cat_subcats + 1'; |
4131 | 4131 | $removeFields[] = 'cat_subcats = cat_subcats - 1'; |
4132 | | - } elseif( $ns == NS_FILE ) { |
| 4132 | + } elseif ( $ns == NS_FILE ) { |
4133 | 4133 | $addFields[] = 'cat_files = cat_files + 1'; |
4134 | 4134 | $removeFields[] = 'cat_files = cat_files - 1'; |
4135 | 4135 | } |
4136 | 4136 | |
4137 | | - if( $added ) { |
| 4137 | + if ( $added ) { |
4138 | 4138 | $dbw->update( |
4139 | 4139 | 'category', |
4140 | 4140 | $addFields, |
— | — | @@ -4141,7 +4141,7 @@ |
4142 | 4142 | __METHOD__ |
4143 | 4143 | ); |
4144 | 4144 | } |
4145 | | - if( $deleted ) { |
| 4145 | + if ( $deleted ) { |
4146 | 4146 | $dbw->update( |
4147 | 4147 | 'category', |
4148 | 4148 | $removeFields, |
— | — | @@ -4164,7 +4164,7 @@ |
4165 | 4165 | $this->exists() && |
4166 | 4166 | $oldid === null; |
4167 | 4167 | |
4168 | | - wfDebug( __METHOD__.': using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" ); |
| 4168 | + wfDebug( __METHOD__ . ': using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" ); |
4169 | 4169 | if ( $wgUser->getOption( 'stubthreshold' ) ) { |
4170 | 4170 | wfIncrStats( 'pcache_miss_stub' ); |
4171 | 4171 | } |
Index: trunk/phase3/includes/AjaxDispatcher.php |
— | — | @@ -7,7 +7,7 @@ |
8 | 8 | * Handle ajax requests and send them to the proper handler. |
9 | 9 | */ |
10 | 10 | |
11 | | -if( !(defined( 'MEDIAWIKI' ) && $wgUseAjax ) ) { |
| 11 | +if ( !( defined( 'MEDIAWIKI' ) && $wgUseAjax ) ) { |
12 | 12 | die( 1 ); |
13 | 13 | } |
14 | 14 | |
— | — | @@ -33,11 +33,11 @@ |
34 | 34 | |
35 | 35 | $this->mode = ""; |
36 | 36 | |
37 | | - if (! empty($_GET["rs"])) { |
| 37 | + if ( ! empty( $_GET["rs"] ) ) { |
38 | 38 | $this->mode = "get"; |
39 | 39 | } |
40 | 40 | |
41 | | - if (!empty($_POST["rs"])) { |
| 41 | + if ( !empty( $_POST["rs"] ) ) { |
42 | 42 | $this->mode = "post"; |
43 | 43 | } |
44 | 44 | |
— | — | @@ -45,7 +45,7 @@ |
46 | 46 | |
47 | 47 | case 'get': |
48 | 48 | $this->func_name = isset( $_GET["rs"] ) ? $_GET["rs"] : ''; |
49 | | - if (! empty($_GET["rsargs"])) { |
| 49 | + if ( ! empty( $_GET["rsargs"] ) ) { |
50 | 50 | $this->args = $_GET["rsargs"]; |
51 | 51 | } else { |
52 | 52 | $this->args = array(); |
— | — | @@ -54,7 +54,7 @@ |
55 | 55 | |
56 | 56 | case 'post': |
57 | 57 | $this->func_name = isset( $_POST["rs"] ) ? $_POST["rs"] : ''; |
58 | | - if (! empty($_POST["rsargs"])) { |
| 58 | + if ( ! empty( $_POST["rsargs"] ) ) { |
59 | 59 | $this->args = $_POST["rsargs"]; |
60 | 60 | } else { |
61 | 61 | $this->args = array(); |
— | — | @@ -65,7 +65,7 @@ |
66 | 66 | wfProfileOut( __METHOD__ ); |
67 | 67 | return; |
68 | 68 | # Or we could throw an exception: |
69 | | - #throw new MWException( __METHOD__ . ' called without any data (mode empty).' ); |
| 69 | + # throw new MWException( __METHOD__ . ' called without any data (mode empty).' ); |
70 | 70 | |
71 | 71 | } |
72 | 72 | |
— | — | @@ -83,9 +83,10 @@ |
84 | 84 | if ( empty( $this->mode ) ) { |
85 | 85 | return; |
86 | 86 | } |
| 87 | + |
87 | 88 | wfProfileIn( __METHOD__ ); |
88 | 89 | |
89 | | - if (! in_array( $this->func_name, $wgAjaxExportList ) ) { |
| 90 | + if ( ! in_array( $this->func_name, $wgAjaxExportList ) ) { |
90 | 91 | wfDebug( __METHOD__ . ' Bad Request for unknown function ' . $this->func_name . "\n" ); |
91 | 92 | |
92 | 93 | wfHttpError( 400, 'Bad Request', |
— | — | @@ -99,11 +100,11 @@ |
100 | 101 | $func = $this->func_name; |
101 | 102 | } |
102 | 103 | try { |
103 | | - $result = call_user_func_array($func, $this->args); |
| 104 | + $result = call_user_func_array( $func, $this->args ); |
104 | 105 | |
105 | 106 | if ( $result === false || $result === null ) { |
106 | | - wfDebug( __METHOD__ . ' ERROR while dispatching ' |
107 | | - . $this->func_name . "(" . var_export( $this->args, true ) . "): " |
| 107 | + wfDebug( __METHOD__ . ' ERROR while dispatching ' |
| 108 | + . $this->func_name . "(" . var_export( $this->args, true ) . "): " |
108 | 109 | . "no data returned\n" ); |
109 | 110 | |
110 | 111 | wfHttpError( 500, 'Internal Error', |
— | — | @@ -111,7 +112,7 @@ |
112 | 113 | } |
113 | 114 | else { |
114 | 115 | if ( is_string( $result ) ) { |
115 | | - $result= new AjaxResponse( $result ); |
| 116 | + $result = new AjaxResponse( $result ); |
116 | 117 | } |
117 | 118 | |
118 | 119 | $result->sendHeaders(); |
— | — | @@ -120,12 +121,12 @@ |
121 | 122 | wfDebug( __METHOD__ . ' dispatch complete for ' . $this->func_name . "\n" ); |
122 | 123 | } |
123 | 124 | |
124 | | - } catch (Exception $e) { |
125 | | - wfDebug( __METHOD__ . ' ERROR while dispatching ' |
126 | | - . $this->func_name . "(" . var_export( $this->args, true ) . "): " |
127 | | - . get_class($e) . ": " . $e->getMessage() . "\n" ); |
| 125 | + } catch ( Exception $e ) { |
| 126 | + wfDebug( __METHOD__ . ' ERROR while dispatching ' |
| 127 | + . $this->func_name . "(" . var_export( $this->args, true ) . "): " |
| 128 | + . get_class( $e ) . ": " . $e->getMessage() . "\n" ); |
128 | 129 | |
129 | | - if (!headers_sent()) { |
| 130 | + if ( !headers_sent() ) { |
130 | 131 | wfHttpError( 500, 'Internal Error', |
131 | 132 | $e->getMessage() ); |
132 | 133 | } else { |
Index: trunk/phase3/includes/CacheDependency.php |
— | — | @@ -1,5 +1,4 @@ |
2 | 2 | <?php |
3 | | - |
4 | 3 | /** |
5 | 4 | * This class stores an arbitrary value along with its dependencies. |
6 | 5 | * Users should typically only use DependencyWrapper::getFromCache(), rather |
— | — | @@ -108,7 +107,7 @@ |
109 | 108 | /** |
110 | 109 | * Hook to perform any expensive pre-serialize loading of dependency values. |
111 | 110 | */ |
112 | | - function loadDependencyValues() {} |
| 111 | + function loadDependencyValues() { } |
113 | 112 | } |
114 | 113 | |
115 | 114 | /** |
— | — | @@ -213,6 +212,7 @@ |
214 | 213 | |
215 | 214 | function isExpired() { |
216 | 215 | $touched = $this->getTitle()->getTouched(); |
| 216 | + |
217 | 217 | if ( $this->touched === false ) { |
218 | 218 | if ( $touched === false ) { |
219 | 219 | # Still missing |
— | — | @@ -251,6 +251,7 @@ |
252 | 252 | function calculateTimestamps() { |
253 | 253 | # Initialise values to false |
254 | 254 | $timestamps = array(); |
| 255 | + |
255 | 256 | foreach ( $this->getLinkBatch()->data as $ns => $dbks ) { |
256 | 257 | if ( count( $dbks ) > 0 ) { |
257 | 258 | $timestamps[$ns] = array(); |
— | — | @@ -264,9 +265,13 @@ |
265 | 266 | if ( count( $timestamps ) ) { |
266 | 267 | $dbr = wfGetDB( DB_SLAVE ); |
267 | 268 | $where = $this->getLinkBatch()->constructSet( 'page', $dbr ); |
268 | | - $res = $dbr->select( 'page', |
| 269 | + $res = $dbr->select( |
| 270 | + 'page', |
269 | 271 | array( 'page_namespace', 'page_title', 'page_touched' ), |
270 | | - $where, __METHOD__ ); |
| 272 | + $where, |
| 273 | + __METHOD__ |
| 274 | + ); |
| 275 | + |
271 | 276 | while ( $row = $dbr->fetchObject( $res ) ) { |
272 | 277 | $timestamps[$row->page_namespace][$row->page_title] = $row->page_touched; |
273 | 278 | } |
— | — | @@ -283,7 +288,7 @@ |
284 | 289 | } |
285 | 290 | |
286 | 291 | function getLinkBatch() { |
287 | | - if ( !isset( $this->linkBatch ) ){ |
| 292 | + if ( !isset( $this->linkBatch ) ) { |
288 | 293 | $this->linkBatch = new LinkBatch; |
289 | 294 | $this->linkBatch->setArray( $this->timestamps ); |
290 | 295 | } |
— | — | @@ -295,6 +300,7 @@ |
296 | 301 | foreach ( $this->timestamps as $ns => $dbks ) { |
297 | 302 | foreach ( $dbks as $dbk => $oldTimestamp ) { |
298 | 303 | $newTimestamp = $newTimestamps[$ns][$dbk]; |
| 304 | + |
299 | 305 | if ( $oldTimestamp === false ) { |
300 | 306 | if ( $newTimestamp === false ) { |
301 | 307 | # Still missing |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -1,5 +1,4 @@ |
2 | 2 | <?php |
3 | | - |
4 | 3 | /* This defines autoloading handler for whole MediaWiki framework */ |
5 | 4 | |
6 | 5 | # Locations of core classes |
Index: trunk/phase3/includes/BacklinkCache.php |
— | — | @@ -1,10 +1,9 @@ |
2 | 2 | <?php |
3 | | - |
4 | 3 | /** |
5 | 4 | * Class for fetching backlink lists, approximate backlink counts and partitions. |
6 | 5 | * Instances of this class should typically be fetched with $title->getBacklinkCache(). |
7 | 6 | * |
8 | | - * Ideally you should only get your backlinks from here when you think there is some |
| 7 | + * Ideally you should only get your backlinks from here when you think there is some |
9 | 8 | * advantage in caching them. Otherwise it's just a waste of memory. |
10 | 9 | */ |
11 | 10 | class BacklinkCache { |
— | — | @@ -56,9 +55,10 @@ |
57 | 56 | wfProfileIn( __METHOD__ ); |
58 | 57 | |
59 | 58 | $fromField = $this->getPrefix( $table ) . '_from'; |
| 59 | + |
60 | 60 | if ( $startId || $endId ) { |
61 | 61 | // Partial range, not cached |
62 | | - wfDebug( __METHOD__.": from DB (uncacheable range)\n" ); |
| 62 | + wfDebug( __METHOD__ . ": from DB (uncacheable range)\n" ); |
63 | 63 | $conds = $this->getConditions( $table ); |
64 | 64 | // Use the from field in the condition rather than the joined page_id, |
65 | 65 | // because databases are stupid and don't necessarily propagate indexes. |
— | — | @@ -68,9 +68,9 @@ |
69 | 69 | if ( $endId ) { |
70 | 70 | $conds[] = "$fromField <= " . intval( $endId ); |
71 | 71 | } |
72 | | - $res = $this->getDB()->select( |
| 72 | + $res = $this->getDB()->select( |
73 | 73 | array( $table, 'page' ), |
74 | | - array( 'page_namespace', 'page_title', 'page_id'), |
| 74 | + array( 'page_namespace', 'page_title', 'page_id' ), |
75 | 75 | $conds, |
76 | 76 | __METHOD__, |
77 | 77 | array( |
— | — | @@ -83,8 +83,8 @@ |
84 | 84 | } |
85 | 85 | |
86 | 86 | if ( !isset( $this->fullResultCache[$table] ) ) { |
87 | | - wfDebug( __METHOD__.": from DB\n" ); |
88 | | - $res = $this->getDB()->select( |
| 87 | + wfDebug( __METHOD__ . ": from DB\n" ); |
| 88 | + $res = $this->getDB()->select( |
89 | 89 | array( $table, 'page' ), |
90 | 90 | array( 'page_namespace', 'page_title', 'page_id' ), |
91 | 91 | $this->getConditions( $table ), |
— | — | @@ -111,6 +111,7 @@ |
112 | 112 | 'templatelinks' => 'tl', |
113 | 113 | 'redirect' => 'rd', |
114 | 114 | ); |
| 115 | + |
115 | 116 | if ( isset( $prefixes[$table] ) ) { |
116 | 117 | return $prefixes[$table]; |
117 | 118 | } else { |
— | — | @@ -123,6 +124,7 @@ |
124 | 125 | */ |
125 | 126 | protected function getConditions( $table ) { |
126 | 127 | $prefix = $this->getPrefix( $table ); |
| 128 | + |
127 | 129 | switch ( $table ) { |
128 | 130 | case 'pagelinks': |
129 | 131 | case 'templatelinks': |
— | — | @@ -134,13 +136,13 @@ |
135 | 137 | ); |
136 | 138 | break; |
137 | 139 | case 'imagelinks': |
138 | | - $conds = array( |
| 140 | + $conds = array( |
139 | 141 | 'il_to' => $this->title->getDBkey(), |
140 | 142 | 'page_id=il_from' |
141 | 143 | ); |
142 | 144 | break; |
143 | 145 | case 'categorylinks': |
144 | | - $conds = array( |
| 146 | + $conds = array( |
145 | 147 | 'cl_to' => $this->title->getDBkey(), |
146 | 148 | 'page_id=cl_from', |
147 | 149 | ); |
— | — | @@ -158,10 +160,12 @@ |
159 | 161 | if ( isset( $this->fullResultCache[$table] ) ) { |
160 | 162 | return $this->fullResultCache[$table]->numRows(); |
161 | 163 | } |
| 164 | + |
162 | 165 | if ( isset( $this->partitionCache[$table] ) ) { |
163 | 166 | $entry = reset( $this->partitionCache[$table] ); |
164 | 167 | return $entry['numRows']; |
165 | 168 | } |
| 169 | + |
166 | 170 | $titleArray = $this->getLinks( $table ); |
167 | 171 | return $titleArray->count(); |
168 | 172 | } |
— | — | @@ -178,26 +182,33 @@ |
179 | 183 | public function partition( $table, $batchSize ) { |
180 | 184 | // Try cache |
181 | 185 | if ( isset( $this->partitionCache[$table][$batchSize] ) ) { |
182 | | - wfDebug( __METHOD__.": got from partition cache\n" ); |
| 186 | + wfDebug( __METHOD__ . ": got from partition cache\n" ); |
183 | 187 | return $this->partitionCache[$table][$batchSize]['batches']; |
184 | 188 | } |
| 189 | + |
185 | 190 | $this->partitionCache[$table][$batchSize] = false; |
186 | 191 | $cacheEntry =& $this->partitionCache[$table][$batchSize]; |
187 | 192 | |
188 | 193 | // Try full result cache |
189 | 194 | if ( isset( $this->fullResultCache[$table] ) ) { |
190 | 195 | $cacheEntry = $this->partitionResult( $this->fullResultCache[$table], $batchSize ); |
191 | | - wfDebug( __METHOD__.": got from full result cache\n" ); |
| 196 | + wfDebug( __METHOD__ . ": got from full result cache\n" ); |
192 | 197 | return $cacheEntry['batches']; |
193 | 198 | } |
| 199 | + |
194 | 200 | // Try memcached |
195 | 201 | global $wgMemc; |
196 | | - $memcKey = wfMemcKey( 'backlinks', md5( $this->title->getPrefixedDBkey() ), |
197 | | - $table, $batchSize ); |
| 202 | + $memcKey = wfMemcKey( |
| 203 | + 'backlinks', |
| 204 | + md5( $this->title->getPrefixedDBkey() ), |
| 205 | + $table, |
| 206 | + $batchSize |
| 207 | + ); |
198 | 208 | $memcValue = $wgMemc->get( $memcKey ); |
| 209 | + |
199 | 210 | if ( is_array( $memcValue ) ) { |
200 | 211 | $cacheEntry = $memcValue; |
201 | | - wfDebug( __METHOD__.": got from memcached $memcKey\n" ); |
| 212 | + wfDebug( __METHOD__ . ": got from memcached $memcKey\n" ); |
202 | 213 | return $cacheEntry['batches']; |
203 | 214 | } |
204 | 215 | // Fetch from database |
— | — | @@ -205,17 +216,18 @@ |
206 | 217 | $cacheEntry = $this->partitionResult( $this->fullResultCache[$table], $batchSize ); |
207 | 218 | // Save to memcached |
208 | 219 | $wgMemc->set( $memcKey, $cacheEntry, self::CACHE_EXPIRY ); |
209 | | - wfDebug( __METHOD__.": got from database\n" ); |
| 220 | + wfDebug( __METHOD__ . ": got from database\n" ); |
210 | 221 | return $cacheEntry['batches']; |
211 | 222 | } |
212 | 223 | |
213 | | - /** |
| 224 | + /** |
214 | 225 | * Partition a DB result with backlinks in it into batches |
215 | 226 | */ |
216 | 227 | protected function partitionResult( $res, $batchSize ) { |
217 | 228 | $batches = array(); |
218 | 229 | $numRows = $res->numRows(); |
219 | 230 | $numBatches = ceil( $numRows / $batchSize ); |
| 231 | + |
220 | 232 | for ( $i = 0; $i < $numBatches; $i++ ) { |
221 | 233 | if ( $i == 0 ) { |
222 | 234 | $start = false; |
— | — | @@ -225,6 +237,7 @@ |
226 | 238 | $row = $res->fetchObject(); |
227 | 239 | $start = $row->page_id; |
228 | 240 | } |
| 241 | + |
229 | 242 | if ( $i == $numBatches - 1 ) { |
230 | 243 | $end = false; |
231 | 244 | } else { |
— | — | @@ -236,7 +249,7 @@ |
237 | 250 | |
238 | 251 | # Sanity check order |
239 | 252 | if ( $start && $end && $start > $end ) { |
240 | | - throw new MWException( __METHOD__.': Internal error: query result out of order' ); |
| 253 | + throw new MWException( __METHOD__ . ': Internal error: query result out of order' ); |
241 | 254 | } |
242 | 255 | |
243 | 256 | $batches[] = array( $start, $end ); |
Index: trunk/phase3/includes/AjaxFunctions.php |
— | — | @@ -4,7 +4,7 @@ |
5 | 5 | * @ingroup Ajax |
6 | 6 | */ |
7 | 7 | |
8 | | -if( !defined( 'MEDIAWIKI' ) ) { |
| 8 | +if ( !defined( 'MEDIAWIKI' ) ) { |
9 | 9 | die( 1 ); |
10 | 10 | } |
11 | 11 | |
— | — | @@ -14,31 +14,31 @@ |
15 | 15 | * Modified function from http://pure-essence.net/stuff/code/utf8RawUrlDecode.phps |
16 | 16 | * |
17 | 17 | * @param $source String escaped with Javascript's escape() function |
18 | | - * @param $iconv_to String destination character set will be used as second parameter |
| 18 | + * @param $iconv_to String destination character set will be used as second parameter |
19 | 19 | * in the iconv function. Default is UTF-8. |
20 | 20 | * @return string |
21 | 21 | */ |
22 | | -function js_unescape($source, $iconv_to = 'UTF-8') { |
| 22 | +function js_unescape( $source, $iconv_to = 'UTF-8' ) { |
23 | 23 | $decodedStr = ''; |
24 | 24 | $pos = 0; |
25 | | - $len = strlen ($source); |
| 25 | + $len = strlen ( $source ); |
26 | 26 | |
27 | | - while ($pos < $len) { |
28 | | - $charAt = substr ($source, $pos, 1); |
29 | | - if ($charAt == '%') { |
| 27 | + while ( $pos < $len ) { |
| 28 | + $charAt = substr ( $source, $pos, 1 ); |
| 29 | + if ( $charAt == '%' ) { |
30 | 30 | $pos++; |
31 | | - $charAt = substr ($source, $pos, 1); |
32 | | - if ($charAt == 'u') { |
| 31 | + $charAt = substr ( $source, $pos, 1 ); |
| 32 | + if ( $charAt == 'u' ) { |
33 | 33 | // we got a unicode character |
34 | 34 | $pos++; |
35 | | - $unicodeHexVal = substr ($source, $pos, 4); |
36 | | - $unicode = hexdec ($unicodeHexVal); |
37 | | - $decodedStr .= code2utf($unicode); |
| 35 | + $unicodeHexVal = substr ( $source, $pos, 4 ); |
| 36 | + $unicode = hexdec ( $unicodeHexVal ); |
| 37 | + $decodedStr .= code2utf( $unicode ); |
38 | 38 | $pos += 4; |
39 | 39 | } else { |
40 | 40 | // we have an escaped ascii character |
41 | | - $hexVal = substr ($source, $pos, 2); |
42 | | - $decodedStr .= chr (hexdec ($hexVal)); |
| 41 | + $hexVal = substr ( $source, $pos, 2 ); |
| 42 | + $decodedStr .= chr ( hexdec ( $hexVal ) ); |
43 | 43 | $pos += 2; |
44 | 44 | } |
45 | 45 | } else { |
— | — | @@ -47,8 +47,8 @@ |
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
51 | | - if ($iconv_to != "UTF-8") { |
52 | | - $decodedStr = iconv("UTF-8", $iconv_to, $decodedStr); |
| 51 | + if ( $iconv_to != "UTF-8" ) { |
| 52 | + $decodedStr = iconv( "UTF-8", $iconv_to, $decodedStr ); |
53 | 53 | } |
54 | 54 | |
55 | 55 | return $decodedStr; |
— | — | @@ -61,16 +61,16 @@ |
62 | 62 | * @param $num Integer |
63 | 63 | * @return utf8char |
64 | 64 | */ |
65 | | -function code2utf($num){ |
66 | | - if ( $num<128 ) |
67 | | - return chr($num); |
68 | | - if ( $num<2048 ) |
69 | | - return chr(($num>>6)+192).chr(($num&63)+128); |
70 | | - if ( $num<65536 ) |
71 | | - return chr(($num>>12)+224).chr((($num>>6)&63)+128).chr(($num&63)+128); |
72 | | - if ( $num<2097152 ) |
73 | | - return chr(($num>>18)+240).chr((($num>>12)&63)+128).chr((($num>>6)&63)+128) .chr(($num&63)+128); |
74 | | - return ''; |
| 65 | +function code2utf( $num ) { |
| 66 | + if ( $num < 128 ) |
| 67 | + return chr( $num ); |
| 68 | + if ( $num < 2048 ) |
| 69 | + return chr( ( $num >> 6 ) + 192 ) . chr( ( $num&63 ) + 128 ); |
| 70 | + if ( $num < 65536 ) |
| 71 | + return chr( ( $num >> 12 ) + 224 ) . chr( ( ( $num >> 6 )&63 ) + 128 ) . chr( ( $num&63 ) + 128 ); |
| 72 | + if ( $num < 2097152 ) |
| 73 | + return chr( ( $num >> 18 ) + 240 ) . chr( ( ( $num >> 12 )&63 ) + 128 ) . chr( ( ( $num >> 6 )&63 ) + 128 ) . chr( ( $num&63 ) + 128 ); |
| 74 | + return ''; |
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
— | — | @@ -81,49 +81,49 @@ |
82 | 82 | * respectively, followed by an HTML message to display in the alert box; or |
83 | 83 | * '<err#>' on error |
84 | 84 | */ |
85 | | -function wfAjaxWatch($pagename = "", $watch = "") { |
86 | | - if(wfReadOnly()) { |
| 85 | +function wfAjaxWatch( $pagename = "", $watch = "" ) { |
| 86 | + if ( wfReadOnly() ) { |
87 | 87 | // redirect to action=(un)watch, which will display the database lock |
88 | 88 | // message |
89 | 89 | return '<err#>'; |
90 | 90 | } |
91 | 91 | |
92 | | - if('w' !== $watch && 'u' !== $watch) { |
| 92 | + if ( 'w' !== $watch && 'u' !== $watch ) { |
93 | 93 | return '<err#>'; |
94 | 94 | } |
95 | 95 | $watch = 'w' === $watch; |
96 | 96 | |
97 | | - $title = Title::newFromDBkey($pagename); |
98 | | - if(!$title) { |
| 97 | + $title = Title::newFromDBkey( $pagename ); |
| 98 | + if ( !$title ) { |
99 | 99 | // Invalid title |
100 | 100 | return '<err#>'; |
101 | 101 | } |
102 | | - $article = new Article($title); |
| 102 | + $article = new Article( $title ); |
103 | 103 | $watching = $title->userIsWatching(); |
104 | 104 | |
105 | | - if($watch) { |
106 | | - if(!$watching) { |
107 | | - $dbw = wfGetDB(DB_MASTER); |
| 105 | + if ( $watch ) { |
| 106 | + if ( !$watching ) { |
| 107 | + $dbw = wfGetDB( DB_MASTER ); |
108 | 108 | $dbw->begin(); |
109 | 109 | $ok = $article->doWatch(); |
110 | 110 | $dbw->commit(); |
111 | 111 | } |
112 | 112 | } else { |
113 | | - if($watching) { |
114 | | - $dbw = wfGetDB(DB_MASTER); |
| 113 | + if ( $watching ) { |
| 114 | + $dbw = wfGetDB( DB_MASTER ); |
115 | 115 | $dbw->begin(); |
116 | 116 | $ok = $article->doUnwatch(); |
117 | 117 | $dbw->commit(); |
118 | 118 | } |
119 | 119 | } |
120 | 120 | // Something stopped the change |
121 | | - if( isset($ok) && !$ok ) { |
| 121 | + if ( isset( $ok ) && !$ok ) { |
122 | 122 | return '<err#>'; |
123 | 123 | } |
124 | | - if( $watch ) { |
125 | | - return '<w#>'.wfMsgExt( 'addedwatchtext', array( 'parse' ), $title->getPrefixedText() ); |
| 124 | + if ( $watch ) { |
| 125 | + return '<w#>' . wfMsgExt( 'addedwatchtext', array( 'parse' ), $title->getPrefixedText() ); |
126 | 126 | } else { |
127 | | - return '<u#>'.wfMsgExt( 'removedwatchtext', array( 'parse' ), $title->getPrefixedText() ); |
| 127 | + return '<u#>' . wfMsgExt( 'removedwatchtext', array( 'parse' ), $title->getPrefixedText() ); |
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
— | — | @@ -133,12 +133,12 @@ |
134 | 134 | */ |
135 | 135 | function wfAjaxGetThumbnailUrl( $file, $width, $height ) { |
136 | 136 | $file = wfFindFile( $file ); |
137 | | - |
| 137 | + |
138 | 138 | if ( !$file || !$file->exists() ) |
139 | 139 | return null; |
140 | | - |
| 140 | + |
141 | 141 | $url = $file->getThumbnail( $width, $height )->url; |
142 | | - |
| 142 | + |
143 | 143 | return $url; |
144 | 144 | } |
145 | 145 | |
— | — | @@ -148,11 +148,11 @@ |
149 | 149 | */ |
150 | 150 | function wfAjaxGetFileUrl( $file ) { |
151 | 151 | $file = wfFindFile( $file ); |
152 | | - |
| 152 | + |
153 | 153 | if ( !$file || !$file->exists() ) |
154 | 154 | return null; |
155 | | - |
| 155 | + |
156 | 156 | $url = $file->getUrl(); |
157 | | - |
| 157 | + |
158 | 158 | return $url; |
159 | | -} |
\ No newline at end of file |
| 159 | +} |
Index: trunk/phase3/includes/Autopromote.php |
— | — | @@ -1,5 +1,4 @@ |
2 | 2 | <?php |
3 | | - |
4 | 3 | /** |
5 | 4 | * This class checks if user can get extra rights |
6 | 5 | * because of conditions specified in $wgAutopromote |
Index: trunk/phase3/includes/Block.php |
— | — | @@ -34,7 +34,7 @@ |
35 | 35 | $this->mUser = $user; |
36 | 36 | $this->mBy = $by; |
37 | 37 | $this->mReason = $reason; |
38 | | - $this->mTimestamp = wfTimestamp(TS_MW,$timestamp); |
| 38 | + $this->mTimestamp = wfTimestamp( TS_MW, $timestamp ); |
39 | 39 | $this->mAuto = $auto; |
40 | 40 | $this->mAnonOnly = $anonOnly; |
41 | 41 | $this->mCreateAccount = $createAccount; |
— | — | @@ -54,7 +54,7 @@ |
55 | 55 | * Load a block from the database, using either the IP address or |
56 | 56 | * user ID. Tries the user ID first, and if that doesn't work, tries |
57 | 57 | * the address. |
58 | | - * |
| 58 | + * |
59 | 59 | * @param $address String: IP address of user/anon |
60 | 60 | * @param $user Integer: user id of user |
61 | 61 | * @param $killExpired Boolean: delete expired blocks on load |
— | — | @@ -130,6 +130,7 @@ |
131 | 131 | */ |
132 | 132 | protected function &getDBOptions( &$options ) { |
133 | 133 | global $wgAntiLockFlags; |
| 134 | + |
134 | 135 | if ( $this->mForUpdate || $this->mFromMaster ) { |
135 | 136 | $db = wfGetDB( DB_MASTER ); |
136 | 137 | if ( !$this->mForUpdate || ( $wgAntiLockFlags & ALF_NO_BLOCK_LOCK ) ) { |
— | — | @@ -180,12 +181,13 @@ |
181 | 182 | if ( $address ) { |
182 | 183 | $conds = array( 'ipb_address' => $address, 'ipb_auto' => 0 ); |
183 | 184 | $res = $db->resultObject( $db->select( 'ipblocks', '*', $conds, __METHOD__, $options ) ); |
| 185 | + |
184 | 186 | if ( $this->loadFromResult( $res, $killExpired ) ) { |
185 | 187 | if ( $user && $this->mAnonOnly ) { |
186 | 188 | # Block is marked anon-only |
187 | 189 | # Whitelist this IP address against autoblocks and range blocks |
188 | 190 | # (but not account creation blocks -- bug 13611) |
189 | | - if( !$this->mCreateAccount ) { |
| 191 | + if ( !$this->mCreateAccount ) { |
190 | 192 | $this->clear(); |
191 | 193 | } |
192 | 194 | return false; |
— | — | @@ -199,7 +201,7 @@ |
200 | 202 | if ( $this->loadRange( $address, $killExpired, $user ) ) { |
201 | 203 | if ( $user && $this->mAnonOnly ) { |
202 | 204 | # Respect account creation blocks on logged-in users -- bug 13611 |
203 | | - if( !$this->mCreateAccount ) { |
| 205 | + if ( !$this->mCreateAccount ) { |
204 | 206 | $this->clear(); |
205 | 207 | } |
206 | 208 | return false; |
— | — | @@ -211,10 +213,13 @@ |
212 | 214 | # Try autoblock |
213 | 215 | if ( $address ) { |
214 | 216 | $conds = array( 'ipb_address' => $address, 'ipb_auto' => 1 ); |
| 217 | + |
215 | 218 | if ( $user ) { |
216 | 219 | $conds['ipb_anon_only'] = 0; |
217 | 220 | } |
| 221 | + |
218 | 222 | $res = $db->resultObject( $db->select( 'ipblocks', '*', $conds, __METHOD__, $options ) ); |
| 223 | + |
219 | 224 | if ( $this->loadFromResult( $res, $killExpired ) ) { |
220 | 225 | return true; |
221 | 226 | } |
— | — | @@ -234,6 +239,7 @@ |
235 | 240 | */ |
236 | 241 | protected function loadFromResult( ResultWrapper $res, $killExpired = true ) { |
237 | 242 | $ret = false; |
| 243 | + |
238 | 244 | if ( 0 != $res->numRows() ) { |
239 | 245 | # Get first block |
240 | 246 | $row = $res->fetchObject(); |
— | — | @@ -274,6 +280,7 @@ |
275 | 281 | */ |
276 | 282 | public function loadRange( $address, $killExpired = true, $user = 0 ) { |
277 | 283 | $iaddr = IP::toHex( $address ); |
| 284 | + |
278 | 285 | if ( $iaddr === false ) { |
279 | 286 | # Invalid address |
280 | 287 | return false; |
— | — | @@ -309,7 +316,7 @@ |
310 | 317 | public function initFromRow( $row ) { |
311 | 318 | $this->mAddress = $row->ipb_address; |
312 | 319 | $this->mReason = $row->ipb_reason; |
313 | | - $this->mTimestamp = wfTimestamp(TS_MW,$row->ipb_timestamp); |
| 320 | + $this->mTimestamp = wfTimestamp( TS_MW, $row->ipb_timestamp ); |
314 | 321 | $this->mUser = $row->ipb_user; |
315 | 322 | $this->mBy = $row->ipb_by; |
316 | 323 | $this->mAuto = $row->ipb_auto; |
— | — | @@ -321,17 +328,19 @@ |
322 | 329 | $this->mHideName = $row->ipb_deleted; |
323 | 330 | $this->mId = $row->ipb_id; |
324 | 331 | $this->mExpiry = self::decodeExpiry( $row->ipb_expiry ); |
| 332 | + |
325 | 333 | if ( isset( $row->user_name ) ) { |
326 | 334 | $this->mByName = $row->user_name; |
327 | 335 | } else { |
328 | 336 | $this->mByName = $row->ipb_by_text; |
329 | 337 | } |
| 338 | + |
330 | 339 | $this->mRangeStart = $row->ipb_range_start; |
331 | 340 | $this->mRangeEnd = $row->ipb_range_end; |
332 | 341 | } |
333 | 342 | |
334 | 343 | /** |
335 | | - * Once $mAddress has been set, get the range they came from. |
| 344 | + * Once $mAddress has been set, get the range they came from. |
336 | 345 | * Wrapper for IP::parseRange |
337 | 346 | */ |
338 | 347 | protected function initialiseRange() { |
— | — | @@ -352,6 +361,7 @@ |
353 | 362 | if ( wfReadOnly() ) { |
354 | 363 | return false; |
355 | 364 | } |
| 365 | + |
356 | 366 | if ( !$this->mId ) { |
357 | 367 | throw new MWException( "Block::delete() now requires that the mId member be filled\n" ); |
358 | 368 | } |
— | — | @@ -377,8 +387,9 @@ |
378 | 388 | # Don't collide with expired blocks |
379 | 389 | Block::purgeExpired(); |
380 | 390 | |
381 | | - $ipb_id = $dbw->nextSequenceValue('ipblocks_ipb_id_seq'); |
382 | | - $dbw->insert( 'ipblocks', |
| 391 | + $ipb_id = $dbw->nextSequenceValue( 'ipblocks_ipb_id_seq' ); |
| 392 | + $dbw->insert( |
| 393 | + 'ipblocks', |
383 | 394 | array( |
384 | 395 | 'ipb_id' => $ipb_id, |
385 | 396 | 'ipb_address' => $this->mAddress, |
— | — | @@ -386,7 +397,7 @@ |
387 | 398 | 'ipb_by' => $this->mBy, |
388 | 399 | 'ipb_by_text' => $this->mByName, |
389 | 400 | 'ipb_reason' => $this->mReason, |
390 | | - 'ipb_timestamp' => $dbw->timestamp($this->mTimestamp), |
| 401 | + 'ipb_timestamp' => $dbw->timestamp( $this->mTimestamp ), |
391 | 402 | 'ipb_auto' => $this->mAuto, |
392 | 403 | 'ipb_anon_only' => $this->mAnonOnly, |
393 | 404 | 'ipb_create_account' => $this->mCreateAccount, |
— | — | @@ -397,7 +408,9 @@ |
398 | 409 | 'ipb_deleted' => $this->mHideName, |
399 | 410 | 'ipb_block_email' => $this->mBlockEmail, |
400 | 411 | 'ipb_allow_usertalk' => $this->mAllowUsertalk |
401 | | - ), 'Block::insert', array( 'IGNORE' ) |
| 412 | + ), |
| 413 | + 'Block::insert', |
| 414 | + array( 'IGNORE' ) |
402 | 415 | ); |
403 | 416 | $affected = $dbw->affectedRows(); |
404 | 417 | |
— | — | @@ -417,13 +430,14 @@ |
418 | 431 | |
419 | 432 | $this->validateBlockParams(); |
420 | 433 | |
421 | | - $dbw->update( 'ipblocks', |
| 434 | + $dbw->update( |
| 435 | + 'ipblocks', |
422 | 436 | array( |
423 | 437 | 'ipb_user' => $this->mUser, |
424 | 438 | 'ipb_by' => $this->mBy, |
425 | 439 | 'ipb_by_text' => $this->mByName, |
426 | 440 | 'ipb_reason' => $this->mReason, |
427 | | - 'ipb_timestamp' => $dbw->timestamp($this->mTimestamp), |
| 441 | + 'ipb_timestamp' => $dbw->timestamp( $this->mTimestamp ), |
428 | 442 | 'ipb_auto' => $this->mAuto, |
429 | 443 | 'ipb_anon_only' => $this->mAnonOnly, |
430 | 444 | 'ipb_create_account' => $this->mCreateAccount, |
— | — | @@ -433,13 +447,15 @@ |
434 | 448 | 'ipb_range_end' => $this->mRangeEnd, |
435 | 449 | 'ipb_deleted' => $this->mHideName, |
436 | 450 | 'ipb_block_email' => $this->mBlockEmail, |
437 | | - 'ipb_allow_usertalk' => $this->mAllowUsertalk ), |
| 451 | + 'ipb_allow_usertalk' => $this->mAllowUsertalk |
| 452 | + ), |
438 | 453 | array( 'ipb_id' => $this->mId ), |
439 | | - 'Block::update' ); |
| 454 | + 'Block::update' |
| 455 | + ); |
440 | 456 | |
441 | 457 | return $dbw->affectedRows(); |
442 | 458 | } |
443 | | - |
| 459 | + |
444 | 460 | /** |
445 | 461 | * Make sure all the proper members are set to sane values |
446 | 462 | * before adding/updating a block |
— | — | @@ -459,8 +475,8 @@ |
460 | 476 | if ( !$this->mUser && $this->mAnonOnly ) { |
461 | 477 | $this->mBlockEmail = 0; |
462 | 478 | } |
463 | | - if( !$this->mByName ) { |
464 | | - if( $this->mBy ) { |
| 479 | + if ( !$this->mByName ) { |
| 480 | + if ( $this->mBy ) { |
465 | 481 | $this->mByName = User::whoIs( $this->mBy ); |
466 | 482 | } else { |
467 | 483 | global $wgUser; |
— | — | @@ -481,7 +497,7 @@ |
482 | 498 | # - stolen shamelessly from CheckUser_body.php |
483 | 499 | |
484 | 500 | if ( $this->mEnableAutoblock && $this->mUser ) { |
485 | | - wfDebug("Doing retroactive autoblocks for " . $this->mAddress . "\n"); |
| 501 | + wfDebug( "Doing retroactive autoblocks for " . $this->mAddress . "\n" ); |
486 | 502 | |
487 | 503 | $options = array( 'ORDER BY' => 'rc_timestamp DESC' ); |
488 | 504 | $conds = array( 'rc_user_text' => $this->mAddress ); |
— | — | @@ -500,7 +516,7 @@ |
501 | 517 | |
502 | 518 | if ( !$dbr->numRows( $res ) ) { |
503 | 519 | # No results, don't autoblock anything |
504 | | - wfDebug("No IP found to retroactively autoblock\n"); |
| 520 | + wfDebug( "No IP found to retroactively autoblock\n" ); |
505 | 521 | } else { |
506 | 522 | while ( $row = $dbr->fetchObject( $res ) ) { |
507 | 523 | if ( $row->rc_ip ) |
— | — | @@ -528,9 +544,9 @@ |
529 | 545 | $wgMemc->set( $key, $lines, 3600 * 24 ); |
530 | 546 | } |
531 | 547 | |
532 | | - wfDebug("Checking the autoblock whitelist..\n"); |
| 548 | + wfDebug( "Checking the autoblock whitelist..\n" ); |
533 | 549 | |
534 | | - foreach( $lines as $line ) { |
| 550 | + foreach ( $lines as $line ) { |
535 | 551 | # List items only |
536 | 552 | if ( substr( $line, 0, 1 ) !== '*' ) { |
537 | 553 | continue; |
— | — | @@ -539,11 +555,11 @@ |
540 | 556 | $wlEntry = substr( $line, 1 ); |
541 | 557 | $wlEntry = trim( $wlEntry ); |
542 | 558 | |
543 | | - wfDebug("Checking $ip against $wlEntry..."); |
| 559 | + wfDebug( "Checking $ip against $wlEntry..." ); |
544 | 560 | |
545 | 561 | # Is the IP in this range? |
546 | 562 | if ( IP::isInRange( $ip, $wlEntry ) ) { |
547 | | - wfDebug(" IP $ip matches $wlEntry, not autoblocking\n"); |
| 563 | + wfDebug( " IP $ip matches $wlEntry, not autoblocking\n" ); |
548 | 564 | return true; |
549 | 565 | } else { |
550 | 566 | wfDebug( " No match\n" ); |
— | — | @@ -570,8 +586,8 @@ |
571 | 587 | if ( Block::isWhitelistedFromAutoblocks( $autoblockIP ) ) { |
572 | 588 | return; |
573 | 589 | } |
574 | | - |
575 | | - ## Allow hooks to cancel the autoblock. |
| 590 | + |
| 591 | + # # Allow hooks to cancel the autoblock. |
576 | 592 | if ( !wfRunHooks( 'AbortAutoblock', array( $autoblockIP, &$this ) ) ) { |
577 | 593 | wfDebug( "Autoblock aborted by hook.\n" ); |
578 | 594 | return false; |
— | — | @@ -612,7 +628,7 @@ |
613 | 629 | $ipblock->mAllowUsertalk = $this->mAllowUsertalk; |
614 | 630 | # If the user is already blocked with an expiry date, we don't |
615 | 631 | # want to pile on top of that! |
616 | | - if( $this->mExpiry ) { |
| 632 | + if ( $this->mExpiry ) { |
617 | 633 | $ipblock->mExpiry = min( $this->mExpiry, Block::getAutoblockExpiry( $this->mTimestamp ) ); |
618 | 634 | } else { |
619 | 635 | $ipblock->mExpiry = Block::getAutoblockExpiry( $this->mTimestamp ); |
— | — | @@ -661,7 +677,7 @@ |
662 | 678 | } |
663 | 679 | |
664 | 680 | /** |
665 | | - * Update the timestamp on autoblocks. |
| 681 | + * Update the timestamp on autoblocks. |
666 | 682 | */ |
667 | 683 | public function updateTimestamp() { |
668 | 684 | if ( $this->mAuto ) { |
— | — | @@ -727,7 +743,7 @@ |
728 | 744 | /** |
729 | 745 | * Encode expiry for DB |
730 | 746 | * |
731 | | - * @param $expiry String: timestamp for expiry, or |
| 747 | + * @param $expiry String: timestamp for expiry, or |
732 | 748 | * @param $db Database object |
733 | 749 | * @return String |
734 | 750 | */ |
— | — | @@ -809,7 +825,7 @@ |
810 | 826 | |
811 | 827 | /** |
812 | 828 | * Get a value to insert into expiry field of the database when infinite expiry |
813 | | - * is desired. In principle this could be DBMS-dependant, but currently all |
| 829 | + * is desired. In principle this could be DBMS-dependant, but currently all |
814 | 830 | * supported DBMS's support the string "infinity", so we just use that. |
815 | 831 | * |
816 | 832 | * @return String |
— | — | @@ -829,10 +845,10 @@ |
830 | 846 | public static function formatExpiry( $encoded_expiry ) { |
831 | 847 | static $msg = null; |
832 | 848 | |
833 | | - if( is_null( $msg ) ) { |
| 849 | + if ( is_null( $msg ) ) { |
834 | 850 | $msg = array(); |
835 | 851 | $keys = array( 'infiniteblock', 'expiringblock' ); |
836 | | - foreach( $keys as $key ) { |
| 852 | + foreach ( $keys as $key ) { |
837 | 853 | $msg[$key] = wfMsgHtml( $key ); |
838 | 854 | } |
839 | 855 | } |
— | — | @@ -859,6 +875,7 @@ |
860 | 876 | $expiry = 'infinity'; |
861 | 877 | } else { |
862 | 878 | $expiry = strtotime( $expiry_input ); |
| 879 | + |
863 | 880 | if ( $expiry < 0 || $expiry === false ) { |
864 | 881 | return false; |
865 | 882 | } |
Index: trunk/phase3/includes/AjaxResponse.php |
— | — | @@ -4,14 +4,14 @@ |
5 | 5 | * @ingroup Ajax |
6 | 6 | */ |
7 | 7 | |
8 | | -if( !defined( 'MEDIAWIKI' ) ) { |
| 8 | +if ( !defined( 'MEDIAWIKI' ) ) { |
9 | 9 | die( 1 ); |
10 | 10 | } |
11 | 11 | |
12 | 12 | /** |
13 | 13 | * Handle responses for Ajax requests (send headers, print |
14 | 14 | * content, that sort of thing) |
15 | | - * |
| 15 | + * |
16 | 16 | * @ingroup Ajax |
17 | 17 | */ |
18 | 18 | class AjaxResponse { |
— | — | @@ -45,7 +45,7 @@ |
46 | 46 | $this->mText = ''; |
47 | 47 | $this->mResponseCode = '200 OK'; |
48 | 48 | $this->mLastModified = false; |
49 | | - $this->mContentType= 'application/x-wiki'; |
| 49 | + $this->mContentType = 'application/x-wiki'; |
50 | 50 | |
51 | 51 | if ( $text ) { |
52 | 52 | $this->addText( $text ); |
— | — | @@ -95,13 +95,13 @@ |
96 | 96 | header( "Status: " . $this->mResponseCode, true, (int)$n ); |
97 | 97 | } |
98 | 98 | |
99 | | - header ("Content-Type: " . $this->mContentType ); |
| 99 | + header ( "Content-Type: " . $this->mContentType ); |
100 | 100 | |
101 | 101 | if ( $this->mLastModified ) { |
102 | | - header ("Last-Modified: " . $this->mLastModified ); |
| 102 | + header ( "Last-Modified: " . $this->mLastModified ); |
103 | 103 | } |
104 | 104 | else { |
105 | | - header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); |
| 105 | + header ( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . " GMT" ); |
106 | 106 | } |
107 | 107 | |
108 | 108 | if ( $this->mCacheDuration ) { |
— | — | @@ -110,31 +110,31 @@ |
111 | 111 | # and tell the client to always check with the squid. Otherwise, |
112 | 112 | # tell the client to use a cached copy, without a way to purge it. |
113 | 113 | |
114 | | - if( $wgUseSquid ) { |
| 114 | + if ( $wgUseSquid ) { |
115 | 115 | |
116 | 116 | # Expect explicite purge of the proxy cache, but require end user agents |
117 | 117 | # to revalidate against the proxy on each visit. |
118 | 118 | # Surrogate-Control controls our Squid, Cache-Control downstream caches |
119 | 119 | |
120 | 120 | if ( $wgUseESI ) { |
121 | | - header( 'Surrogate-Control: max-age='.$this->mCacheDuration.', content="ESI/1.0"'); |
| 121 | + header( 'Surrogate-Control: max-age=' . $this->mCacheDuration . ', content="ESI/1.0"' ); |
122 | 122 | header( 'Cache-Control: s-maxage=0, must-revalidate, max-age=0' ); |
123 | 123 | } else { |
124 | | - header( 'Cache-Control: s-maxage='.$this->mCacheDuration.', must-revalidate, max-age=0' ); |
| 124 | + header( 'Cache-Control: s-maxage=' . $this->mCacheDuration . ', must-revalidate, max-age=0' ); |
125 | 125 | } |
126 | 126 | |
127 | 127 | } else { |
128 | 128 | |
129 | 129 | # Let the client do the caching. Cache is not purged. |
130 | | - header ("Expires: " . gmdate( "D, d M Y H:i:s", time() + $this->mCacheDuration ) . " GMT"); |
131 | | - header ("Cache-Control: s-max-age={$this->mCacheDuration},public,max-age={$this->mCacheDuration}"); |
| 130 | + header ( "Expires: " . gmdate( "D, d M Y H:i:s", time() + $this->mCacheDuration ) . " GMT" ); |
| 131 | + header ( "Cache-Control: s-max-age={$this->mCacheDuration},public,max-age={$this->mCacheDuration}" ); |
132 | 132 | } |
133 | 133 | |
134 | 134 | } else { |
135 | 135 | # always expired, always modified |
136 | | - header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past |
137 | | - header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 |
138 | | - header ("Pragma: no-cache"); // HTTP/1.0 |
| 136 | + header ( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); // Date in the past |
| 137 | + header ( "Cache-Control: no-cache, must-revalidate" ); // HTTP/1.1 |
| 138 | + header ( "Pragma: no-cache" ); // HTTP/1.0 |
139 | 139 | } |
140 | 140 | |
141 | 141 | if ( $this->mVary ) { |
— | — | @@ -156,11 +156,11 @@ |
157 | 157 | wfDebug( "$fname: CACHE DISABLED, NO TIMESTAMP\n" ); |
158 | 158 | return; |
159 | 159 | } |
160 | | - if( !$wgCachePages ) { |
| 160 | + if ( !$wgCachePages ) { |
161 | 161 | wfDebug( "$fname: CACHE DISABLED\n", false ); |
162 | 162 | return; |
163 | 163 | } |
164 | | - if( $wgUser->getOption( 'nocache' ) ) { |
| 164 | + if ( $wgUser->getOption( 'nocache' ) ) { |
165 | 165 | wfDebug( "$fname: USER DISABLED CACHE\n", false ); |
166 | 166 | return; |
167 | 167 | } |
— | — | @@ -168,7 +168,7 @@ |
169 | 169 | $timestamp = wfTimestamp( TS_MW, $timestamp ); |
170 | 170 | $lastmod = wfTimestamp( TS_RFC2822, max( $timestamp, $wgUser->mTouched, $wgCacheEpoch ) ); |
171 | 171 | |
172 | | - if( !empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) { |
| 172 | + if ( !empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) { |
173 | 173 | # IE sends sizes after the date like this: |
174 | 174 | # Wed, 20 Aug 2003 06:51:19 GMT; length=5202 |
175 | 175 | # this breaks strtotime(). |
— | — | @@ -177,8 +177,8 @@ |
178 | 178 | $ismodsince = wfTimestamp( TS_MW, $modsinceTime ? $modsinceTime : 1 ); |
179 | 179 | wfDebug( "$fname: -- client send If-Modified-Since: " . $modsince . "\n", false ); |
180 | 180 | wfDebug( "$fname: -- we might send Last-Modified : $lastmod\n", false ); |
181 | | - if( ($ismodsince >= $timestamp ) && $wgUser->validateCache( $ismodsince ) && $ismodsince >= $wgCacheEpoch ) { |
182 | | - ini_set('zlib.output_compression', 0); |
| 181 | + if ( ( $ismodsince >= $timestamp ) && $wgUser->validateCache( $ismodsince ) && $ismodsince >= $wgCacheEpoch ) { |
| 182 | + ini_set( 'zlib.output_compression', 0 ); |
183 | 183 | $this->setResponseCode( "304 Not Modified" ); |
184 | 184 | $this->disable(); |
185 | 185 | $this->mLastModified = $lastmod; |
Index: trunk/phase3/includes/Category.php |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * Category objects are immutable, strictly speaking. If you call methods that change the database, |
| 4 | + * Category objects are immutable, strictly speaking. If you call methods that change the database, |
5 | 5 | * like to refresh link counts, the objects will be appropriately reinitialized. |
6 | 6 | * Member variables are lazy-initialized. |
7 | 7 | * |
— | — | @@ -18,21 +18,21 @@ |
19 | 19 | /** Counts of membership (cat_pages, cat_subcats, cat_files) */ |
20 | 20 | private $mPages = null, $mSubcats = null, $mFiles = null; |
21 | 21 | |
22 | | - private function __construct() {} |
| 22 | + private function __construct() { } |
23 | 23 | |
24 | 24 | /** |
25 | 25 | * Set up all member variables using a database query. |
26 | 26 | * @return bool True on success, false on failure. |
27 | 27 | */ |
28 | 28 | protected function initialize() { |
29 | | - if ( $this->mName === null && $this->mTitle ) |
| 29 | + if ( $this->mName === null && $this->mTitle ) |
30 | 30 | $this->mName = $title->getDBkey(); |
31 | 31 | |
32 | | - if( $this->mName === null && $this->mID === null ) { |
33 | | - throw new MWException( __METHOD__.' has both names and IDs null' ); |
34 | | - } elseif( $this->mID === null ) { |
| 32 | + if ( $this->mName === null && $this->mID === null ) { |
| 33 | + throw new MWException( __METHOD__ . ' has both names and IDs null' ); |
| 34 | + } elseif ( $this->mID === null ) { |
35 | 35 | $where = array( 'cat_title' => $this->mName ); |
36 | | - } elseif( $this->mName === null ) { |
| 36 | + } elseif ( $this->mName === null ) { |
37 | 37 | $where = array( 'cat_id' => $this->mID ); |
38 | 38 | } else { |
39 | 39 | # Already initialized |
— | — | @@ -45,7 +45,8 @@ |
46 | 46 | $where, |
47 | 47 | __METHOD__ |
48 | 48 | ); |
49 | | - if( !$row ) { |
| 49 | + |
| 50 | + if ( !$row ) { |
50 | 51 | # Okay, there were no contents. Nothing to initialize. |
51 | 52 | if ( $this->mTitle ) { |
52 | 53 | # If there is a title object but no record in the category table, treat this as an empty category |
— | — | @@ -60,6 +61,7 @@ |
61 | 62 | return false; # Fail |
62 | 63 | } |
63 | 64 | } |
| 65 | + |
64 | 66 | $this->mID = $row->cat_id; |
65 | 67 | $this->mName = $row->cat_title; |
66 | 68 | $this->mPages = $row->cat_pages; |
— | — | @@ -69,7 +71,7 @@ |
70 | 72 | # (bug 13683) If the count is negative, then 1) it's obviously wrong |
71 | 73 | # and should not be kept, and 2) we *probably* don't have to scan many |
72 | 74 | # rows to obtain the correct figure, so let's risk a one-time recount. |
73 | | - if( $this->mPages < 0 || $this->mSubcats < 0 || $this->mFiles < 0 ) { |
| 75 | + if ( $this->mPages < 0 || $this->mSubcats < 0 || $this->mFiles < 0 ) { |
74 | 76 | $this->refreshCounts(); |
75 | 77 | } |
76 | 78 | |
— | — | @@ -86,7 +88,8 @@ |
87 | 89 | public static function newFromName( $name ) { |
88 | 90 | $cat = new self(); |
89 | 91 | $title = Title::makeTitleSafe( NS_CATEGORY, $name ); |
90 | | - if( !is_object( $title ) ) { |
| 92 | + |
| 93 | + if ( !is_object( $title ) ) { |
91 | 94 | return false; |
92 | 95 | } |
93 | 96 | |
— | — | @@ -126,7 +129,7 @@ |
127 | 130 | /** |
128 | 131 | * Factory function, for constructing a Category object from a result set |
129 | 132 | * |
130 | | - * @param $row result set row, must contain the cat_xxx fields. If the fields are null, |
| 133 | + * @param $row result set row, must contain the cat_xxx fields. If the fields are null, |
131 | 134 | * the resulting Category object will represent an empty category if a title object |
132 | 135 | * was given. If the fields are null and no title was given, this method fails and returns false. |
133 | 136 | * @param $title optional title object for the category represented by the given row. |
— | — | @@ -137,8 +140,7 @@ |
138 | 141 | $cat = new self(); |
139 | 142 | $cat->mTitle = $title; |
140 | 143 | |
141 | | - |
142 | | - # NOTE: the row often results from a LEFT JOIN on categorylinks. This may result in |
| 144 | + # NOTE: the row often results from a LEFT JOIN on categorylinks. This may result in |
143 | 145 | # all the cat_xxx fields being null, if the category page exists, but nothing |
144 | 146 | # was ever added to the category. This case should be treated linke an empty |
145 | 147 | # category, if possible. |
— | — | @@ -169,12 +171,16 @@ |
170 | 172 | |
171 | 173 | /** @return mixed DB key name, or false on failure */ |
172 | 174 | public function getName() { return $this->getX( 'mName' ); } |
| 175 | + |
173 | 176 | /** @return mixed Category ID, or false on failure */ |
174 | 177 | public function getID() { return $this->getX( 'mID' ); } |
| 178 | + |
175 | 179 | /** @return mixed Total number of member pages, or false on failure */ |
176 | 180 | public function getPageCount() { return $this->getX( 'mPages' ); } |
| 181 | + |
177 | 182 | /** @return mixed Number of subcategories, or false on failure */ |
178 | 183 | public function getSubcatCount() { return $this->getX( 'mSubcats' ); } |
| 184 | + |
179 | 185 | /** @return mixed Number of member files, or false on failure */ |
180 | 186 | public function getFileCount() { return $this->getX( 'mFiles' ); } |
181 | 187 | |
— | — | @@ -182,9 +188,9 @@ |
183 | 189 | * @return mixed The Title for this category, or false on failure. |
184 | 190 | */ |
185 | 191 | public function getTitle() { |
186 | | - if( $this->mTitle ) return $this->mTitle; |
187 | | - |
188 | | - if( !$this->initialize() ) { |
| 192 | + if ( $this->mTitle ) return $this->mTitle; |
| 193 | + |
| 194 | + if ( !$this->initialize() ) { |
189 | 195 | return false; |
190 | 196 | } |
191 | 197 | |
— | — | @@ -204,13 +210,19 @@ |
205 | 211 | |
206 | 212 | $conds = array( 'cl_to' => $this->getName(), 'cl_from = page_id' ); |
207 | 213 | $options = array( 'ORDER BY' => 'cl_sortkey' ); |
208 | | - if( $limit ) $options[ 'LIMIT' ] = $limit; |
209 | | - if( $offset !== '' ) $conds[] = 'cl_sortkey > ' . $dbr->addQuotes( $offset ); |
210 | 214 | |
| 215 | + if ( $limit ) { |
| 216 | + $options[ 'LIMIT' ] = $limit; |
| 217 | + } |
| 218 | + |
| 219 | + if ( $offset !== '' ) { |
| 220 | + $conds[] = 'cl_sortkey > ' . $dbr->addQuotes( $offset ); |
| 221 | + } |
| 222 | + |
211 | 223 | return TitleArray::newFromResult( |
212 | 224 | $dbr->select( |
213 | 225 | array( 'page', 'categorylinks' ), |
214 | | - array( 'page_id', 'page_namespace','page_title', 'page_len', |
| 226 | + array( 'page_id', 'page_namespace', 'page_title', 'page_len', |
215 | 227 | 'page_is_redirect', 'page_latest' ), |
216 | 228 | $conds, |
217 | 229 | __METHOD__, |
— | — | @@ -221,10 +233,10 @@ |
222 | 234 | |
223 | 235 | /** Generic accessor */ |
224 | 236 | private function getX( $key ) { |
225 | | - if( !$this->initialize() ) { |
| 237 | + if ( !$this->initialize() ) { |
226 | 238 | return false; |
227 | 239 | } |
228 | | - return $this->{$key}; |
| 240 | + return $this-> { $key } ; |
229 | 241 | } |
230 | 242 | |
231 | 243 | /** |
— | — | @@ -233,14 +245,14 @@ |
234 | 246 | * @return bool True on success, false on failure |
235 | 247 | */ |
236 | 248 | public function refreshCounts() { |
237 | | - if( wfReadOnly() ) { |
| 249 | + if ( wfReadOnly() ) { |
238 | 250 | return false; |
239 | 251 | } |
240 | 252 | $dbw = wfGetDB( DB_MASTER ); |
241 | 253 | $dbw->begin(); |
242 | 254 | # Note, we must use names for this, since categorylinks does. |
243 | | - if( $this->mName === null ) { |
244 | | - if( !$this->initialize() ) { |
| 255 | + if ( $this->mName === null ) { |
| 256 | + if ( !$this->initialize() ) { |
245 | 257 | return false; |
246 | 258 | } |
247 | 259 | } else { |
— | — | @@ -249,15 +261,17 @@ |
250 | 262 | $seqVal = $dbw->nextSequenceValue( 'category_cat_id_seq' ); |
251 | 263 | $dbw->insert( |
252 | 264 | 'category', |
253 | | - array( 'cat_id' => $seqVal, |
254 | | - 'cat_title' => $this->mName ), |
| 265 | + array( |
| 266 | + 'cat_id' => $seqVal, |
| 267 | + 'cat_title' => $this->mName |
| 268 | + ), |
255 | 269 | __METHOD__, |
256 | 270 | 'IGNORE' |
257 | 271 | ); |
258 | 272 | } |
259 | 273 | |
260 | | - $cond1 = $dbw->conditional( 'page_namespace='.NS_CATEGORY, 1, 'NULL' ); |
261 | | - $cond2 = $dbw->conditional( 'page_namespace='.NS_FILE, 1, 'NULL' ); |
| 274 | + $cond1 = $dbw->conditional( 'page_namespace=' . NS_CATEGORY, 1, 'NULL' ); |
| 275 | + $cond2 = $dbw->conditional( 'page_namespace=' . NS_FILE, 1, 'NULL' ); |
262 | 276 | $result = $dbw->selectRow( |
263 | 277 | array( 'categorylinks', 'page' ), |
264 | 278 | array( 'COUNT(*) AS pages', |