Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php |
— | — | @@ -259,7 +259,7 @@ |
260 | 260 | * @param array $config |
261 | 261 | * @returns string |
262 | 262 | */ |
263 | | - public static function getProtectionLevel( $config ) { |
| 263 | + public static function getProtectionLevel( array $config ) { |
264 | 264 | if( !self::useProtectionLevels() ) { |
265 | 265 | throw new MWException('getProtectionLevel() called with $wgFlaggedRevsProtection off'); |
266 | 266 | } |
— | — | @@ -472,11 +472,11 @@ |
473 | 473 | /** |
474 | 474 | * Get minimum tags that are closest to $oldFlags |
475 | 475 | * given the site, page, and user rights limitations. |
476 | | - * @param Array $oldFlags previous stable rev flags |
477 | | - * @param Array $config |
| 476 | + * @param array $oldFlags previous stable rev flags |
| 477 | + * @param array $config |
478 | 478 | * @return mixed array or null |
479 | 479 | */ |
480 | | - public static function getAutoReviewTags( $oldFlags, $config = array() ) { |
| 480 | + public static function getAutoReviewTags( $oldFlags, array $config = array() ) { |
481 | 481 | if ( !FlaggedRevs::autoReviewEdits() ) { |
482 | 482 | return null; // shouldn't happen |
483 | 483 | } |
— | — | @@ -506,7 +506,7 @@ |
507 | 507 | * @return array( string, array, array, array, int ) |
508 | 508 | * All included pages/arguments are expanded out |
509 | 509 | */ |
510 | | - public static function expandText( $text = '', $title, $id ) { |
| 510 | + public static function expandText( $text = '', Title $title, $id ) { |
511 | 511 | global $wgParser; |
512 | 512 | # Make our hooks trigger (force unstub so setting doesn't get lost) |
513 | 513 | $wgParser->firstCallInit(); |
— | — | @@ -530,7 +530,7 @@ |
531 | 531 | * @param int $id |
532 | 532 | * @return ParserOutput |
533 | 533 | */ |
534 | | - public static function parseStableText( $article, $text = '', $id ) { |
| 534 | + public static function parseStableText( Article $article, $text, $id ) { |
535 | 535 | global $wgParser; |
536 | 536 | $title = $article->getTitle(); // avoid pass-by-reference error |
537 | 537 | # Make our hooks trigger (force unstub so setting doesn't get lost) |
— | — | @@ -550,7 +550,7 @@ |
551 | 551 | * @param User $user (optional) |
552 | 552 | * @returns ParserOptions |
553 | 553 | */ |
554 | | - public static function makeParserOptions( $user = null ) { |
| 554 | + public static function makeParserOptions( User $user = null ) { |
555 | 555 | global $wgUser; |
556 | 556 | $user = $user ? $user : $wgUser; // assume current |
557 | 557 | $options = ParserOptions::newFromUser( $user ); |
— | — | @@ -567,7 +567,7 @@ |
568 | 568 | * @return ParserOutput |
569 | 569 | * Get the page cache for the top stable revision of an article |
570 | 570 | */ |
571 | | - public static function getPageCache( $article, $user ) { |
| 571 | + public static function getPageCache( Article $article, User $user ) { |
572 | 572 | global $parserMemc, $wgCacheEpoch; |
573 | 573 | wfProfileIn( __METHOD__ ); |
574 | 574 | # Make sure it is valid |
— | — | @@ -615,7 +615,7 @@ |
616 | 616 | /** |
617 | 617 | * Like ParserCache::getKey() with stable-pcache instead of pcache |
618 | 618 | */ |
619 | | - public static function getCacheKey( $parserCache, $article, $user ) { |
| 619 | + public static function getCacheKey( $parserCache, Article $article, User $user ) { |
620 | 620 | $key = $parserCache->getKey( $article, $user ); |
621 | 621 | $key = str_replace( ':pcache:', ':stable-pcache:', $key ); |
622 | 622 | return $key; |
— | — | @@ -627,7 +627,9 @@ |
628 | 628 | * @param parserOutput $parserOut |
629 | 629 | * Updates the stable cache of a page with the given $parserOut |
630 | 630 | */ |
631 | | - public static function updatePageCache( $article, $user, $parserOut = null ) { |
| 631 | + public static function updatePageCache( |
| 632 | + Article $article, User $user, ParserOutput $parserOut = null |
| 633 | + ) { |
632 | 634 | global $parserMemc, $wgParserCacheExpireTime, $wgEnableParserCache; |
633 | 635 | # Make sure it is valid and $wgEnableParserCache is enabled |
634 | 636 | if ( !$wgEnableParserCache || is_null( $parserOut ) ) |
— | — | @@ -659,7 +661,7 @@ |
660 | 662 | * @param array $imgParams (like ParserOutput image time->sha1 pairs) |
661 | 663 | * Set the template/image versioning cache for parser |
662 | 664 | */ |
663 | | - public static function setIncludeVersionCache( $revId, $tmpParams, $imgParams ) { |
| 665 | + public static function setIncludeVersionCache( $revId, array $tmpParams, array $imgParams ) { |
664 | 666 | self::load(); |
665 | 667 | self::$includeVersionCache[$revId] = array(); |
666 | 668 | self::$includeVersionCache[$revId]['templates'] = $tmpParams; |
— | — | @@ -741,7 +743,10 @@ |
742 | 744 | * This function is pretty expensive... |
743 | 745 | */ |
744 | 746 | public static function stableVersionIsSynced( |
745 | | - $srev, $article, $stableOutput = null, $currentOutput = null |
| 747 | + FlaggedRevision $srev, |
| 748 | + Article $article, |
| 749 | + ParserOutput $stableOutput = null, |
| 750 | + ParserOutput $currentOutput = null |
746 | 751 | ) { |
747 | 752 | global $wgMemc, $wgEnableParserCache, $wgUser; |
748 | 753 | # Must be the same revision as the current |
— | — | @@ -825,7 +830,7 @@ |
826 | 831 | |
827 | 832 | /** |
828 | 833 | * @param string $val |
829 | | - * @return obj array |
| 834 | + * @return Object (val,time) tuple |
830 | 835 | * Get a memcache storage object |
831 | 836 | */ |
832 | 837 | public static function makeMemcObj( $val ) { |
— | — | @@ -836,12 +841,12 @@ |
837 | 842 | } |
838 | 843 | |
839 | 844 | /** |
840 | | - * @param mixed $data Memc data returned |
| 845 | + * @param mixed $data makeMemcObj() tuple (false/Object) |
841 | 846 | * @param Article $article |
842 | 847 | * @return mixed |
843 | 848 | * Return memc value if not expired |
844 | 849 | */ |
845 | | - public static function getMemcValue( $data, $article ) { |
| 850 | + public static function getMemcValue( $data, Article $article ) { |
846 | 851 | if ( is_object( $data ) && $data->time >= $article->getTouched() ) { |
847 | 852 | return $data->value; |
848 | 853 | } |
— | — | @@ -855,7 +860,7 @@ |
856 | 861 | * @return int |
857 | 862 | * Get number of revs since the stable revision |
858 | 863 | */ |
859 | | - public static function getRevCountSince( $article, $revId, $forUpdate = false ) { |
| 864 | + public static function getRevCountSince( Article $article, $revId, $forUpdate = false ) { |
860 | 865 | global $wgMemc, $wgParserCacheExpireTime; |
861 | 866 | # Try the cache |
862 | 867 | $count = null; |
— | — | @@ -884,7 +889,7 @@ |
885 | 890 | * @param mixed $latest, the latest rev ID (optional) |
886 | 891 | * Updates the tracking tables and pending edit count cache. Called on edit. |
887 | 892 | */ |
888 | | - public static function updateStableVersion( $article, $rev, $latest = null ) { |
| 893 | + public static function updateStableVersion( Article $article, Revision $rev, $latest = null ) { |
889 | 894 | if ( !$article->getId() ) |
890 | 895 | return true; // no bogus entries |
891 | 896 | # Get the latest revision ID if not set |
— | — | @@ -939,7 +944,7 @@ |
940 | 945 | * @param mixed $latest, the latest rev ID (optional) |
941 | 946 | * Updates the flaggedpage_pending table |
942 | 947 | */ |
943 | | - public static function updatePendingList( $article, $latest = null ) { |
| 948 | + public static function updatePendingList( Article $article, $latest = null ) { |
944 | 949 | $data = array(); |
945 | 950 | $level = self::pristineVersions() ? FR_PRISTINE : FR_QUALITY; |
946 | 951 | if ( !self::qualityVersions() ) |
— | — | @@ -1006,7 +1011,7 @@ |
1007 | 1012 | /** |
1008 | 1013 | * Resets links for a page when changed (other than edits) |
1009 | 1014 | */ |
1010 | | - public static function articleLinksUpdate( $article ) { |
| 1015 | + public static function articleLinksUpdate( Article $article ) { |
1011 | 1016 | global $wgUser, $wgParser; |
1012 | 1017 | # Update the links tables as the stable version may now be the default page... |
1013 | 1018 | $parserCache = ParserCache::singleton(); |
— | — | @@ -1027,7 +1032,7 @@ |
1028 | 1033 | /** |
1029 | 1034 | * Resets links for a page when changed (other than edits) |
1030 | 1035 | */ |
1031 | | - public static function titleLinksUpdate( $title ) { |
| 1036 | + public static function titleLinksUpdate( Title $title ) { |
1032 | 1037 | return self::articleLinksUpdate( new Article( $title ) ); |
1033 | 1038 | } |
1034 | 1039 | |
— | — | @@ -1039,7 +1044,7 @@ |
1040 | 1045 | * @param int $rev_id |
1041 | 1046 | * @return Array |
1042 | 1047 | */ |
1043 | | - public static function getRevisionTags( $title, $rev_id ) { |
| 1048 | + public static function getRevisionTags( Title $title, $rev_id ) { |
1044 | 1049 | $dbr = wfGetDB( DB_SLAVE ); |
1045 | 1050 | $tags = $dbr->selectField( 'flaggedrevs', 'fr_tags', |
1046 | 1051 | array( 'fr_rev_id' => $rev_id, |
— | — | @@ -1074,7 +1079,7 @@ |
1075 | 1080 | * @returns bool |
1076 | 1081 | * Useful for quickly pinging to see if a revision is flagged |
1077 | 1082 | */ |
1078 | | - public static function revIsFlagged( $title, $rev_id, $flags = 0 ) { |
| 1083 | + public static function revIsFlagged( Title $title, $rev_id, $flags = 0 ) { |
1079 | 1084 | $quality = self::getRevQuality( $title->getArticleId(), $rev_id, $flags ); |
1080 | 1085 | return ( $quality !== false ); |
1081 | 1086 | } |
— | — | @@ -1085,7 +1090,7 @@ |
1086 | 1091 | * @returns mixed (integer/false) |
1087 | 1092 | * Will not return a revision if deleted |
1088 | 1093 | */ |
1089 | | - public static function getPrimeFlaggedRevId( $article ) { |
| 1094 | + public static function getPrimeFlaggedRevId( Article $article ) { |
1090 | 1095 | $dbr = wfGetDB( DB_SLAVE ); |
1091 | 1096 | # Get the highest quality revision (not necessarily this one). |
1092 | 1097 | $oldid = $dbr->selectField( array( 'flaggedrevs', 'revision' ), |
— | — | @@ -1109,7 +1114,7 @@ |
1110 | 1115 | * @param Revision $rev |
1111 | 1116 | * @returns bool DB write query used |
1112 | 1117 | */ |
1113 | | - public static function markRevisionPatrolled( $rev ) { |
| 1118 | + public static function markRevisionPatrolled( Revision $rev ) { |
1114 | 1119 | $rcid = $rev->isUnpatrolled(); |
1115 | 1120 | # Make sure it is now marked patrolled... |
1116 | 1121 | if ( $rcid ) { |
— | — | @@ -1130,9 +1135,9 @@ |
1131 | 1136 | * Get visibility settings/restrictions for a page |
1132 | 1137 | * @param Title $title, page title |
1133 | 1138 | * @param int $flags, FR_MASTER |
1134 | | - * @returns Array (associative) (select,override,autoreview,expiry) |
| 1139 | + * @returns array (associative) (select,override,autoreview,expiry) |
1135 | 1140 | */ |
1136 | | - public static function getPageVisibilitySettings( $title, $flags = 0 ) { |
| 1141 | + public static function getPageVisibilitySettings( Title $title, $flags = 0 ) { |
1137 | 1142 | $db = ($flags & FR_MASTER) ? |
1138 | 1143 | wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE ); |
1139 | 1144 | $row = $db->selectRow( 'flaggedpage_config', |
— | — | @@ -1266,7 +1271,7 @@ |
1267 | 1272 | $srev = FlaggedRevision::newFromStable( $title, FR_MASTER, $config ); |
1268 | 1273 | if ( $srev ) { |
1269 | 1274 | $article = new Article( $title ); |
1270 | | - self::updateStableVersion( $article, $srev, $title->getArticleID() ); |
| 1275 | + self::updateStableVersion( $article, $srev->getRevision(), $title->getArticleID() ); |
1271 | 1276 | } else { |
1272 | 1277 | self::clearTrackingRows( $pageId ); // no stable version |
1273 | 1278 | } |
— | — | @@ -1276,45 +1281,48 @@ |
1277 | 1282 | # ################ Other utility functions ################# |
1278 | 1283 | |
1279 | 1284 | /** |
1280 | | - * @param Array $flags |
| 1285 | + * @param array $flags |
1281 | 1286 | * @return bool, is this revision at basic review condition? |
1282 | 1287 | */ |
1283 | | - public static function isSighted( $flags ) { |
| 1288 | + public static function isSighted( array $flags ) { |
1284 | 1289 | return self::tagsAtLevel( $flags, self::$minSL ); |
1285 | 1290 | } |
1286 | 1291 | |
1287 | 1292 | /** |
1288 | | - * @param Array $flags |
| 1293 | + * @param array $flags |
1289 | 1294 | * @return bool, is this revision at quality review condition? |
1290 | 1295 | */ |
1291 | | - public static function isQuality( $flags ) { |
| 1296 | + public static function isQuality( array $flags ) { |
1292 | 1297 | return self::tagsAtLevel( $flags, self::$minQL ); |
1293 | 1298 | } |
1294 | 1299 | |
1295 | 1300 | /** |
1296 | | - * @param Array $flags |
| 1301 | + * @param array $flags |
1297 | 1302 | * @return bool, is this revision at pristine review condition? |
1298 | 1303 | */ |
1299 | | - public static function isPristine( $flags ) { |
| 1304 | + public static function isPristine( array $flags ) { |
1300 | 1305 | return self::tagsAtLevel( $flags, self::$minPL ); |
1301 | 1306 | } |
1302 | 1307 | |
1303 | 1308 | // Checks if $flags meets $reqFlagLevels |
1304 | | - protected static function tagsAtLevel( $flags, $reqFlagLevels ) { |
1305 | | - if ( empty( $flags ) ) return false; |
| 1309 | + protected static function tagsAtLevel( array $flags, $reqFlagLevels ) { |
| 1310 | + if ( empty( $flags ) ) { |
| 1311 | + return false; |
| 1312 | + } |
1306 | 1313 | foreach ( self::$dimensions as $f => $x ) { |
1307 | | - if ( !isset( $flags[$f] ) || $reqFlagLevels[$f] > $flags[$f] ) |
| 1314 | + if ( !isset( $flags[$f] ) || $reqFlagLevels[$f] > $flags[$f] ) { |
1308 | 1315 | return false; |
| 1316 | + } |
1309 | 1317 | } |
1310 | 1318 | return true; |
1311 | 1319 | } |
1312 | 1320 | |
1313 | 1321 | /** |
1314 | 1322 | * Get the quality tier of review flags |
1315 | | - * @param Array $flags |
| 1323 | + * @param array $flags |
1316 | 1324 | * @return int, flagging tier (-1 for non-sighted) |
1317 | 1325 | */ |
1318 | | - public static function getLevelTier( $flags ) { |
| 1326 | + public static function getLevelTier( array $flags ) { |
1319 | 1327 | if ( self::isPristine( $flags ) ) |
1320 | 1328 | return FR_PRISTINE; // 2 |
1321 | 1329 | elseif ( self::isQuality( $flags ) ) |
— | — | @@ -1350,7 +1358,7 @@ |
1351 | 1359 | * @param Title, $title |
1352 | 1360 | * @return bool |
1353 | 1361 | */ |
1354 | | - public static function inReviewNamespace( $title ) { |
| 1362 | + public static function inReviewNamespace( Title $title ) { |
1355 | 1363 | global $wgFlaggedRevsWhitelist; |
1356 | 1364 | $namespaces = self::getReviewNamespaces(); |
1357 | 1365 | $ns = ( $title->getNamespace() == NS_MEDIA ) ? |
— | — | @@ -1367,7 +1375,7 @@ |
1368 | 1376 | * @param Title, $title |
1369 | 1377 | * @return bool |
1370 | 1378 | */ |
1371 | | - public static function inPatrolNamespace( $title ) { |
| 1379 | + public static function inPatrolNamespace( Title $title ) { |
1372 | 1380 | $namespaces = self::getPatrolNamespaces(); |
1373 | 1381 | $ns = ( $title->getNamespace() == NS_MEDIA ) ? |
1374 | 1382 | NS_FILE : $title->getNamespace(); // Treat NS_MEDIA as NS_FILE |
— | — | @@ -1389,7 +1397,7 @@ |
1390 | 1398 | * Get params for a user |
1391 | 1399 | * @param int $uid |
1392 | 1400 | * @param string $DBName, optional wiki name |
1393 | | - * @returns Array $params |
| 1401 | + * @returns array $params |
1394 | 1402 | */ |
1395 | 1403 | public static function getUserParams( $uid, $DBName = false ) { |
1396 | 1404 | $dbw = wfGetDB( DB_MASTER, array(), $DBName ); |
— | — | @@ -1425,11 +1433,11 @@ |
1426 | 1434 | /** |
1427 | 1435 | * Save params for a user |
1428 | 1436 | * @param int $uid |
1429 | | - * @param Array $params |
| 1437 | + * @param array $params |
1430 | 1438 | * @param string $DBName, optional wiki name |
1431 | 1439 | * @returns bool success |
1432 | 1440 | */ |
1433 | | - public static function saveUserParams( $uid, $params, $DBName = false ) { |
| 1441 | + public static function saveUserParams( $uid, array $params, $DBName = false ) { |
1434 | 1442 | $flatParams = ''; |
1435 | 1443 | foreach ( $params as $key => $value ) { |
1436 | 1444 | $flatParams .= "{$key}={$value}\n"; |
— | — | @@ -1459,7 +1467,7 @@ |
1460 | 1468 | * If no appropriate tags can be found, then the review will abort. |
1461 | 1469 | */ |
1462 | 1470 | public static function autoReviewEdit( |
1463 | | - $article, $user, $text, $rev, $flags = null, $auto = true |
| 1471 | + Article $article, User $user, $text, Revision $rev, array $flags = null, $auto = true |
1464 | 1472 | ) { |
1465 | 1473 | wfProfileIn( __METHOD__ ); |
1466 | 1474 | $title = $article->getTitle(); |
— | — | @@ -1602,7 +1610,9 @@ |
1603 | 1611 | * @param array $imageSHA1Keys (from ParserOutput/OutputPage->fr_ImageSHA1Keys) |
1604 | 1612 | * @returns array( templateParams, imageParams, fileVersion ) |
1605 | 1613 | */ |
1606 | | - public static function getIncludeParams( $article, $templateIDs, $imageSHA1Keys ) { |
| 1614 | + public static function getIncludeParams( |
| 1615 | + Article $article, array $templateIDs, array $imageSHA1Keys |
| 1616 | + ) { |
1607 | 1617 | $templateParams = $imageParams = $fileVersion = ''; |
1608 | 1618 | # NS -> title -> rev ID mapping |
1609 | 1619 | foreach ( $templateIDs as $namespace => $t ) { |
Index: trunk/extensions/FlaggedRevs/FlaggedRevision.php |
— | — | @@ -217,7 +217,7 @@ |
218 | 218 | * @param bool $auto autopatrolled |
219 | 219 | * @return bool success |
220 | 220 | */ |
221 | | - public function insertOn( $tmpRows, $fileRows, $auto = false ) { |
| 221 | + public function insertOn( array $tmpRows, array $fileRows, $auto = false ) { |
222 | 222 | $textFlags = 'dynamic'; |
223 | 223 | if ( $auto ) $textFlags .= ',auto'; |
224 | 224 | $this->mFlags = explode( ',', $textFlags ); |
— | — | @@ -257,7 +257,7 @@ |
258 | 258 | } |
259 | 259 | |
260 | 260 | /** |
261 | | - * @returns Array basic select fields (not including text/text flags) |
| 261 | + * @returns array basic select fields (not including text/text flags) |
262 | 262 | */ |
263 | 263 | public static function selectFields() { |
264 | 264 | return array( |
— | — | @@ -346,7 +346,7 @@ |
347 | 347 | } |
348 | 348 | |
349 | 349 | /** |
350 | | - * @returns Array tag metadata |
| 350 | + * @returns array tag metadata |
351 | 351 | */ |
352 | 352 | public function getTags() { |
353 | 353 | return $this->mTags; |
— | — | @@ -385,22 +385,22 @@ |
386 | 386 | |
387 | 387 | /** |
388 | 388 | * Set template versions array |
389 | | - * @param Array template versions (ns -> dbKey -> rev id) |
| 389 | + * @param array template versions (ns -> dbKey -> rev id) |
390 | 390 | */ |
391 | | - public function setTemplateVersions( $templateVersions ) { |
| 391 | + public function setTemplateVersions( array $templateVersions ) { |
392 | 392 | $this->mTemplates = $templateVersions; |
393 | 393 | } |
394 | 394 | |
395 | 395 | /** |
396 | 396 | * Set file versions array |
397 | | - * @param Array file versions (dbKey -> sha1) |
| 397 | + * @param array file versions (dbKey -> sha1) |
398 | 398 | */ |
399 | | - public function setFileVersions( $fileVersions ) { |
| 399 | + public function setFileVersions( array $fileVersions ) { |
400 | 400 | $this->mFiles = $fileVersions; |
401 | 401 | } |
402 | 402 | |
403 | 403 | /** |
404 | | - * @returns Array template versions (ns -> dbKey -> rev id) |
| 404 | + * @returns array template versions (ns -> dbKey -> rev id) |
405 | 405 | */ |
406 | 406 | public function getTemplateVersions() { |
407 | 407 | if ( $this->mTemplates == null ) { |
— | — | @@ -421,7 +421,7 @@ |
422 | 422 | } |
423 | 423 | |
424 | 424 | /** |
425 | | - * @returns Array file versions (dbKey -> sha1) |
| 425 | + * @returns array file versions (dbKey -> sha1) |
426 | 426 | */ |
427 | 427 | public function getFileVersions() { |
428 | 428 | if ( $this->mFiles == null ) { |
— | — | @@ -480,10 +480,10 @@ |
481 | 481 | |
482 | 482 | /** |
483 | 483 | * Get flags for a revision |
484 | | - * @param Array $tags |
| 484 | + * @param array $tags |
485 | 485 | * @return string |
486 | 486 | */ |
487 | | - public static function flattenRevisionTags( $tags ) { |
| 487 | + public static function flattenRevisionTags( array $tags ) { |
488 | 488 | $flags = ''; |
489 | 489 | foreach ( $tags as $tag => $value ) { |
490 | 490 | # Add only currently recognized ones |