Index: trunk/phase3/includes/Title.php |
— | — | @@ -44,32 +44,32 @@ |
45 | 45 | */ |
46 | 46 | //@{ |
47 | 47 | |
48 | | - var $mTextform = ''; ///< Text form (spaces not underscores) of the main part |
49 | | - var $mUrlform = ''; ///< URL-encoded form of the main part |
50 | | - var $mDbkeyform = ''; ///< Main part with underscores |
| 48 | + var $mTextform = ''; ///< Text form (spaces not underscores) of the main part |
| 49 | + var $mUrlform = ''; ///< URL-encoded form of the main part |
| 50 | + var $mDbkeyform = ''; ///< Main part with underscores |
51 | 51 | var $mUserCaseDBKey; ///< DB key with the initial letter in the case specified by the user |
52 | 52 | var $mNamespace = NS_MAIN; ///< Namespace index, i.e. one of the NS_xxxx constants |
53 | | - var $mInterwiki = ''; ///< Interwiki prefix (or null string) |
54 | | - var $mFragment; ///< Title fragment (i.e. the bit after the #) |
| 53 | + var $mInterwiki = ''; ///< Interwiki prefix (or null string) |
| 54 | + var $mFragment; ///< Title fragment (i.e. the bit after the #) |
55 | 55 | var $mArticleID = -1; ///< Article ID, fetched from the link cache on demand |
56 | 56 | var $mLatestID = false; ///< ID of most recent revision |
57 | 57 | var $mRestrictions = array(); ///< Array of groups allowed to edit this article |
58 | 58 | var $mOldRestrictions = false; |
59 | | - var $mCascadeRestriction; ///< Cascade restrictions on this page to included templates and images? |
60 | | - var $mRestrictionsExpiry = array(); ///< When do the restrictions on this page expire? |
61 | | - var $mHasCascadingRestrictions; ///< Are cascading restrictions in effect on this page? |
62 | | - var $mCascadeSources; ///< Where are the cascading restrictions coming from on this page? |
| 59 | + var $mCascadeRestriction; ///< Cascade restrictions on this page to included templates and images? |
| 60 | + var $mRestrictionsExpiry = array(); ///< When do the restrictions on this page expire? |
| 61 | + var $mHasCascadingRestrictions; ///< Are cascading restrictions in effect on this page? |
| 62 | + var $mCascadeSources; ///< Where are the cascading restrictions coming from on this page? |
63 | 63 | var $mRestrictionsLoaded = false; ///< Boolean for initialisation on demand |
64 | | - var $mPrefixedText; ///< Text form including namespace/interwiki, initialised on demand |
| 64 | + var $mPrefixedText; ///< Text form including namespace/interwiki, initialised on demand |
65 | 65 | # Don't change the following default, NS_MAIN is hardcoded in several |
66 | 66 | # places. See bug 696. |
67 | 67 | var $mDefaultNamespace = NS_MAIN; ///< Namespace index when there is no namespace |
68 | | - # Zero except in {{transclusion}} tags |
69 | | - var $mWatched = null; ///< Is $wgUser watching this page? null if unfilled, accessed through userIsWatching() |
| 68 | + # Zero except in {{transclusion}} tags |
| 69 | + var $mWatched = null; ///< Is $wgUser watching this page? null if unfilled, accessed through userIsWatching() |
70 | 70 | var $mLength = -1; ///< The page length, 0 for special pages |
71 | 71 | var $mRedirect = null; ///< Is the article at this title a redirect? |
72 | 72 | var $mNotificationTimestamp = array(); ///< Associative array of user ID -> timestamp/false |
73 | | - var $mBacklinkCache = null; ///< Cache of links to this title |
| 73 | + var $mBacklinkCache = null; ///< Cache of links to this title |
74 | 74 | //@} |
75 | 75 | |
76 | 76 | |
— | — | @@ -280,7 +280,7 @@ |
281 | 281 | } else { |
282 | 282 | return null; |
283 | 283 | } |
284 | | - } |
| 284 | + } |
285 | 285 | |
286 | 286 | /** |
287 | 287 | * Create a new Title for the Main Page |
— | — | @@ -307,7 +307,7 @@ |
308 | 308 | public static function newFromRedirect( $text ) { |
309 | 309 | return self::newFromRedirectInternal( $text ); |
310 | 310 | } |
311 | | - |
| 311 | + |
312 | 312 | /** |
313 | 313 | * Extract a redirect destination from a string and return the |
314 | 314 | * Title, or null if the text doesn't contain a valid redirect |
— | — | @@ -321,7 +321,7 @@ |
322 | 322 | $titles = self::newFromRedirectArray( $text ); |
323 | 323 | return $titles ? array_pop( $titles ) : null; |
324 | 324 | } |
325 | | - |
| 325 | + |
326 | 326 | /** |
327 | 327 | * Extract a redirect destination from a string and return an |
328 | 328 | * array of Titles, or null if the text doesn't contain a valid redirect |
— | — | @@ -360,7 +360,7 @@ |
361 | 361 | } |
362 | 362 | return $titles; |
363 | 363 | } |
364 | | - |
| 364 | + |
365 | 365 | /** |
366 | 366 | * Really extract the redirect destination |
367 | 367 | * Do not call this function directly, use one of the newFromRedirect* functions above |
— | — | @@ -404,14 +404,14 @@ |
405 | 405 | * Get the prefixed DB key associated with an ID |
406 | 406 | * @param $id \type{\int} the page_id of the article |
407 | 407 | * @return \type{Title} an object representing the article, or NULL |
408 | | - * if no such article was found |
| 408 | + * if no such article was found |
409 | 409 | */ |
410 | 410 | public static function nameOf( $id ) { |
411 | 411 | $dbr = wfGetDB( DB_SLAVE ); |
412 | 412 | |
413 | 413 | $s = $dbr->selectRow( 'page', |
414 | 414 | array( 'page_namespace','page_title' ), |
415 | | - array( 'page_id' => $id ), |
| 415 | + array( 'page_id' => $id ), |
416 | 416 | __METHOD__ ); |
417 | 417 | if ( $s === false ) { return null; } |
418 | 418 | |
— | — | @@ -435,7 +435,7 @@ |
436 | 436 | * @param $ns \type{\int} a namespace index |
437 | 437 | * @param $title \type{\string} text-form main part |
438 | 438 | * @return \type{\string} a stripped-down title string ready for the |
439 | | - * search index |
| 439 | + * search index |
440 | 440 | */ |
441 | 441 | public static function indexTitle( $ns, $title ) { |
442 | 442 | global $wgContLang; |
— | — | @@ -499,7 +499,7 @@ |
500 | 500 | public function isTrans() { |
501 | 501 | if ($this->mInterwiki == '') |
502 | 502 | return false; |
503 | | - |
| 503 | + |
504 | 504 | return Interwiki::fetch( $this->mInterwiki )->isTranscludable(); |
505 | 505 | } |
506 | 506 | |
— | — | @@ -621,7 +621,7 @@ |
622 | 622 | /** |
623 | 623 | * Get title for search index |
624 | 624 | * @return \type{\string} a stripped-down title string ready for the |
625 | | - * search index |
| 625 | + * search index |
626 | 626 | */ |
627 | 627 | public function getIndexTitle() { |
628 | 628 | return Title::indexTitle( $this->mNamespace, $this->mTextform ); |
— | — | @@ -630,7 +630,7 @@ |
631 | 631 | /** |
632 | 632 | * Get the prefixed database key form |
633 | 633 | * @return \type{\string} the prefixed title, with underscores and |
634 | | - * any interwiki and namespace prefixes |
| 634 | + * any interwiki and namespace prefixes |
635 | 635 | */ |
636 | 636 | public function getPrefixedDBkey() { |
637 | 637 | $s = $this->prefix( $this->mDbkeyform ); |
— | — | @@ -656,7 +656,7 @@ |
657 | 657 | * Get the prefixed title with spaces, plus any fragment |
658 | 658 | * (part beginning with '#') |
659 | 659 | * @return \type{\string} the prefixed title, with spaces and |
660 | | - * the fragment, including '#' |
| 660 | + * the fragment, including '#' |
661 | 661 | */ |
662 | 662 | public function getFullText() { |
663 | 663 | $text = $this->getPrefixedText(); |
— | — | @@ -764,7 +764,7 @@ |
765 | 765 | * Get a URL with no fragment or server name. If this page is generated |
766 | 766 | * with action=render, $wgServer is prepended. |
767 | 767 | * @param mixed $query an optional query string; if not specified, |
768 | | - * $wgArticlePath will be used. Can be specified as an associative array |
| 768 | + * $wgArticlePath will be used. Can be specified as an associative array |
769 | 769 | * as well, e.g., array( 'action' => 'edit' ) (keys and values will be |
770 | 770 | * URL-escaped). |
771 | 771 | * @param $variant \type{\string} language variant of url (for sr, zh..) |
— | — | @@ -913,7 +913,7 @@ |
914 | 914 | /** |
915 | 915 | * Get the edit URL for this Title |
916 | 916 | * @return \type{\string} the URL, or a null string if this is an |
917 | | - * interwiki link |
| 917 | + * interwiki link |
918 | 918 | */ |
919 | 919 | public function getEditURL() { |
920 | 920 | if ( '' != $this->mInterwiki ) { return ''; } |
— | — | @@ -970,7 +970,7 @@ |
971 | 971 | */ |
972 | 972 | public function isProtected( $action = '' ) { |
973 | 973 | global $wgRestrictionLevels; |
974 | | - |
| 974 | + |
975 | 975 | $restrictionTypes = $this->getRestrictionTypes(); |
976 | 976 | |
977 | 977 | # Special pages have inherent protection |
— | — | @@ -1021,7 +1021,7 @@ |
1022 | 1022 | * |
1023 | 1023 | * @param $action \type{\string} action that permission needs to be checked for |
1024 | 1024 | * @return \type{\bool} |
1025 | | - */ |
| 1025 | + */ |
1026 | 1026 | public function quickUserCan( $action ) { |
1027 | 1027 | return $this->userCan( $action, false ); |
1028 | 1028 | } |
— | — | @@ -1048,7 +1048,7 @@ |
1049 | 1049 | * @param $action \type{\string} action that permission needs to be checked for |
1050 | 1050 | * @param $doExpensiveQueries \type{\bool} Set this to false to avoid doing unnecessary queries. |
1051 | 1051 | * @return \type{\bool} |
1052 | | - */ |
| 1052 | + */ |
1053 | 1053 | public function userCan( $action, $doExpensiveQueries = true ) { |
1054 | 1054 | global $wgUser; |
1055 | 1055 | return ($this->getUserPermissionsErrorsInternal( $action, $wgUser, $doExpensiveQueries, true ) === array()); |
— | — | @@ -1128,15 +1128,15 @@ |
1129 | 1129 | |
1130 | 1130 | $intended = $user->mBlock->mAddress; |
1131 | 1131 | |
1132 | | - $errors[] = array( ($block->mAuto ? 'autoblockedtext' : 'blockedtext'), $link, $reason, $ip, $name, |
| 1132 | + $errors[] = array( ($block->mAuto ? 'autoblockedtext' : 'blockedtext'), $link, $reason, $ip, $name, |
1133 | 1133 | $blockid, $blockExpiry, $intended, $blockTimestamp ); |
1134 | 1134 | } |
1135 | | - |
| 1135 | + |
1136 | 1136 | // Remove the errors being ignored. |
1137 | | - |
| 1137 | + |
1138 | 1138 | foreach( $errors as $index => $error ) { |
1139 | 1139 | $error_key = is_array($error) ? $error[0] : $error; |
1140 | | - |
| 1140 | + |
1141 | 1141 | if (in_array( $error_key, $ignoreErrors )) { |
1142 | 1142 | unset($errors[$index]); |
1143 | 1143 | } |
— | — | @@ -1169,12 +1169,12 @@ |
1170 | 1170 | // Show user page-specific message only if the user can move other pages |
1171 | 1171 | $errors[] = array( 'cant-move-user-page' ); |
1172 | 1172 | } |
1173 | | - |
| 1173 | + |
1174 | 1174 | // Check if user is allowed to move files if it's a file |
1175 | 1175 | if( $this->getNamespace() == NS_FILE && !$user->isAllowed( 'movefile' ) ) { |
1176 | 1176 | $errors[] = array( 'movenotallowedfile' ); |
1177 | 1177 | } |
1178 | | - |
| 1178 | + |
1179 | 1179 | if( !$user->isAllowed( 'move' ) ) { |
1180 | 1180 | // User can't move anything |
1181 | 1181 | global $wgGroupPermissions; |
— | — | @@ -1211,14 +1211,14 @@ |
1212 | 1212 | } |
1213 | 1213 | } elseif( !$user->isAllowed( $action ) ) { |
1214 | 1214 | $return = null; |
1215 | | - |
| 1215 | + |
1216 | 1216 | // We avoid expensive display logic for quickUserCan's and such |
1217 | | - $groups = false; |
| 1217 | + $groups = false; |
1218 | 1218 | if (!$short) { |
1219 | 1219 | $groups = array_map( array( 'User', 'makeGroupLinkWiki' ), |
1220 | 1220 | User::getGroupsWithPermission( $action ) ); |
1221 | | - } |
1222 | | - |
| 1221 | + } |
| 1222 | + |
1223 | 1223 | if( $groups ) { |
1224 | 1224 | $return = array( 'badaccess-groups', |
1225 | 1225 | array( implode( ', ', $groups ), count( $groups ) ) ); |
— | — | @@ -1271,7 +1271,7 @@ |
1272 | 1272 | wfProfileOut( __METHOD__ ); |
1273 | 1273 | return $errors; |
1274 | 1274 | } |
1275 | | - |
| 1275 | + |
1276 | 1276 | # Only 'createaccount' and 'execute' can be performed on |
1277 | 1277 | # special pages, which don't actually exist in the DB. |
1278 | 1278 | $specialOKActions = array( 'createaccount', 'execute' ); |
— | — | @@ -1289,7 +1289,7 @@ |
1290 | 1290 | |
1291 | 1291 | # Protect css/js subpages of user pages |
1292 | 1292 | # XXX: this might be better using restrictions |
1293 | | - # XXX: Find a way to work around the php bug that prevents using $this->userCanEditCssSubpage() |
| 1293 | + # XXX: Find a way to work around the php bug that prevents using $this->userCanEditCssSubpage() |
1294 | 1294 | # and $this->userCanEditJsSubpage() from working |
1295 | 1295 | # XXX: right 'editusercssjs' is deprecated, for backward compatibility only |
1296 | 1296 | if( $this->isCssSubpage() && !( $user->isAllowed('editusercssjs') || $user->isAllowed('editusercss') ) |
— | — | @@ -1329,7 +1329,7 @@ |
1330 | 1330 | wfProfileOut( __METHOD__ ); |
1331 | 1331 | return $errors; |
1332 | 1332 | } |
1333 | | - |
| 1333 | + |
1334 | 1334 | if( $doExpensiveQueries && !$this->isCssJsSubpage() ) { |
1335 | 1335 | # We /could/ use the protection level on the source page, but it's fairly ugly |
1336 | 1336 | # as we have to establish a precedence hierarchy for pages included by multiple |
— | — | @@ -1407,7 +1407,7 @@ |
1408 | 1408 | if ( $this->getNamespace() < 0 ) { |
1409 | 1409 | return false; |
1410 | 1410 | } |
1411 | | - |
| 1411 | + |
1412 | 1412 | // Can't protect pages that exist. |
1413 | 1413 | if ($this->exists()) { |
1414 | 1414 | return false; |
— | — | @@ -1454,7 +1454,7 @@ |
1455 | 1455 | else { |
1456 | 1456 | $expiry_description .= ' (' . wfMsgForContent( 'protect-expiry-indefinite' ).')'; |
1457 | 1457 | } |
1458 | | - |
| 1458 | + |
1459 | 1459 | # Update protection table |
1460 | 1460 | if ($create_perm != '' ) { |
1461 | 1461 | $dbw->replace( 'protected_titles', array(array('pt_namespace', 'pt_title')), |
— | — | @@ -1494,7 +1494,7 @@ |
1495 | 1495 | $dbw = wfGetDB( DB_MASTER ); |
1496 | 1496 | |
1497 | 1497 | $dbw->delete( 'protected_titles', |
1498 | | - array( 'pt_namespace' => $this->getNamespace(), 'pt_title' => $this->getDBkey() ), |
| 1498 | + array( 'pt_namespace' => $this->getNamespace(), 'pt_title' => $this->getDBkey() ), |
1499 | 1499 | __METHOD__ ); |
1500 | 1500 | } |
1501 | 1501 | |
— | — | @@ -1515,7 +1515,7 @@ |
1516 | 1516 | */ |
1517 | 1517 | public function userCanRead() { |
1518 | 1518 | global $wgUser, $wgGroupPermissions; |
1519 | | - |
| 1519 | + |
1520 | 1520 | static $useShortcut = null; |
1521 | 1521 | |
1522 | 1522 | # Initialize the $useShortcut boolean, to determine if we can skip quite a bit of code below |
— | — | @@ -1541,7 +1541,7 @@ |
1542 | 1542 | } |
1543 | 1543 | } |
1544 | 1544 | } |
1545 | | - |
| 1545 | + |
1546 | 1546 | $result = null; |
1547 | 1547 | wfRunHooks( 'userCan', array( &$this, &$wgUser, 'read', &$result ) ); |
1548 | 1548 | if ( $result !== null ) { |
— | — | @@ -1652,7 +1652,7 @@ |
1653 | 1653 | return $this->mHasSubpages = (bool)$subpages->count(); |
1654 | 1654 | return $this->mHasSubpages = false; |
1655 | 1655 | } |
1656 | | - |
| 1656 | + |
1657 | 1657 | /** |
1658 | 1658 | * Get all subpages of this page. |
1659 | 1659 | * @param $limit Maximum number of subpages to fetch; -1 for no limit |
— | — | @@ -1741,7 +1741,7 @@ |
1742 | 1742 | */ |
1743 | 1743 | public function userCanEditCssSubpage() { |
1744 | 1744 | global $wgUser; |
1745 | | - return ( ( $wgUser->isAllowed('editusercssjs') && $wgUser->isAllowed('editusercss') ) |
| 1745 | + return ( ( $wgUser->isAllowed('editusercssjs') && $wgUser->isAllowed('editusercss') ) |
1746 | 1746 | || preg_match('/^'.preg_quote($wgUser->getName(), '/').'\//', $this->mTextform) ); |
1747 | 1747 | } |
1748 | 1748 | /** |
— | — | @@ -1754,7 +1754,7 @@ |
1755 | 1755 | public function userCanEditJsSubpage() { |
1756 | 1756 | global $wgUser; |
1757 | 1757 | return ( ( $wgUser->isAllowed('editusercssjs') && $wgUser->isAllowed('edituserjs') ) |
1758 | | - || preg_match('/^'.preg_quote($wgUser->getName(), '/').'\//', $this->mTextform) ); |
| 1758 | + || preg_match('/^'.preg_quote($wgUser->getName(), '/').'\//', $this->mTextform) ); |
1759 | 1759 | } |
1760 | 1760 | |
1761 | 1761 | /** |
— | — | @@ -1771,7 +1771,7 @@ |
1772 | 1772 | * Cascading protection: Get the source of any cascading restrictions on this page. |
1773 | 1773 | * |
1774 | 1774 | * @param $get_pages \type{\bool} Whether or not to retrieve the actual pages that the restrictions have come from. |
1775 | | - * @return \type{\arrayof{mixed title array, restriction array}} Array of the Title objects of the pages from |
| 1775 | + * @return \type{\arrayof{mixed title array, restriction array}} Array of the Title objects of the pages from |
1776 | 1776 | * which cascading restrictions have come, false for none, or true if such restrictions exist, but $get_pages was not set. |
1777 | 1777 | * The restriction array is an array of each type, each of which contains an array of unique groups. |
1778 | 1778 | */ |
— | — | @@ -1827,11 +1827,11 @@ |
1828 | 1828 | $sources[$page_id] = Title::makeTitle($page_ns, $page_title); |
1829 | 1829 | # Add groups needed for each restriction type if its not already there |
1830 | 1830 | # Make sure this restriction type still exists |
1831 | | - |
| 1831 | + |
1832 | 1832 | if ( !isset( $pagerestrictions[$row->pr_type] ) ) { |
1833 | 1833 | $pagerestrictions[$row->pr_type] = array(); |
1834 | 1834 | } |
1835 | | - |
| 1835 | + |
1836 | 1836 | if ( isset($pagerestrictions[$row->pr_type]) && |
1837 | 1837 | !in_array($row->pr_level, $pagerestrictions[$row->pr_type]) ) { |
1838 | 1838 | $pagerestrictions[$row->pr_type][]=$row->pr_level; |
— | — | @@ -1874,17 +1874,17 @@ |
1875 | 1875 | private function loadRestrictionsFromResultWrapper( $res, $oldFashionedRestrictions = null ) { |
1876 | 1876 | $rows = array(); |
1877 | 1877 | $dbr = wfGetDB( DB_SLAVE ); |
1878 | | - |
| 1878 | + |
1879 | 1879 | while( $row = $dbr->fetchObject( $res ) ) { |
1880 | 1880 | $rows[] = $row; |
1881 | 1881 | } |
1882 | | - |
| 1882 | + |
1883 | 1883 | $this->loadRestrictionsFromRows( $rows, $oldFashionedRestrictions ); |
1884 | 1884 | } |
1885 | | - |
| 1885 | + |
1886 | 1886 | public function loadRestrictionsFromRows( $rows, $oldFashionedRestrictions = null ) { |
1887 | 1887 | $dbr = wfGetDB( DB_SLAVE ); |
1888 | | - |
| 1888 | + |
1889 | 1889 | $restrictionTypes = $this->getRestrictionTypes(); |
1890 | 1890 | |
1891 | 1891 | foreach( $restrictionTypes as $type ){ |
— | — | @@ -1897,7 +1897,7 @@ |
1898 | 1898 | # Backwards-compatibility: also load the restrictions from the page record (old format). |
1899 | 1899 | |
1900 | 1900 | if ( $oldFashionedRestrictions === null ) { |
1901 | | - $oldFashionedRestrictions = $dbr->selectField( 'page', 'page_restrictions', |
| 1901 | + $oldFashionedRestrictions = $dbr->selectField( 'page', 'page_restrictions', |
1902 | 1902 | array( 'page_id' => $this->getArticleId() ), __METHOD__ ); |
1903 | 1903 | } |
1904 | 1904 | |
— | — | @@ -1927,7 +1927,7 @@ |
1928 | 1928 | # Cycle through all the restrictions. |
1929 | 1929 | |
1930 | 1930 | // Don't take care of restrictions types that aren't allowed |
1931 | | - |
| 1931 | + |
1932 | 1932 | if( !in_array( $row->pr_type, $restrictionTypes ) ) |
1933 | 1933 | continue; |
1934 | 1934 | |
— | — | @@ -2022,7 +2022,7 @@ |
2023 | 2023 | |
2024 | 2024 | /** |
2025 | 2025 | * Get the expiry time for the restriction against a given action |
2026 | | - * @return 14-char timestamp, or 'infinity' if the page is protected forever |
| 2026 | + * @return 14-char timestamp, or 'infinity' if the page is protected forever |
2027 | 2027 | * or not protected at all, or false if the action is not recognised. |
2028 | 2028 | */ |
2029 | 2029 | public function getRestrictionExpiry( $action ) { |
— | — | @@ -2041,7 +2041,7 @@ |
2042 | 2042 | $n = 0; |
2043 | 2043 | } else { |
2044 | 2044 | $dbr = wfGetDB( DB_SLAVE ); |
2045 | | - $n = $dbr->selectField( 'archive', 'COUNT(*)', |
| 2045 | + $n = $dbr->selectField( 'archive', 'COUNT(*)', |
2046 | 2046 | array( 'ar_namespace' => $this->getNamespace(), 'ar_title' => $this->getDBkey() ), |
2047 | 2047 | __METHOD__ |
2048 | 2048 | ); |
— | — | @@ -2054,7 +2054,7 @@ |
2055 | 2055 | } |
2056 | 2056 | return (int)$n; |
2057 | 2057 | } |
2058 | | - |
| 2058 | + |
2059 | 2059 | /** |
2060 | 2060 | * Is there a version of this page in the deletion archive? |
2061 | 2061 | * @return bool |
— | — | @@ -2081,7 +2081,7 @@ |
2082 | 2082 | * Get the article ID for this Title from the link cache, |
2083 | 2083 | * adding it if necessary |
2084 | 2084 | * @param $flags \type{\int} a bit field; may be GAID_FOR_UPDATE to select |
2085 | | - * for update |
| 2085 | + * for update |
2086 | 2086 | * @return \type{\int} the ID |
2087 | 2087 | */ |
2088 | 2088 | public function getArticleID( $flags = 0 ) { |
— | — | @@ -2184,8 +2184,8 @@ |
2185 | 2185 | } |
2186 | 2186 | $dbw = wfGetDB( DB_MASTER ); |
2187 | 2187 | $success = $dbw->update( 'page', |
2188 | | - array( 'page_touched' => $dbw->timestamp() ), |
2189 | | - $this->pageCond(), |
| 2188 | + array( 'page_touched' => $dbw->timestamp() ), |
| 2189 | + $this->pageCond(), |
2190 | 2190 | __METHOD__ |
2191 | 2191 | ); |
2192 | 2192 | HTMLFileCache::clearFileCache( $this ); |
— | — | @@ -2210,7 +2210,7 @@ |
2211 | 2211 | } |
2212 | 2212 | return $p . $name; |
2213 | 2213 | } |
2214 | | - |
| 2214 | + |
2215 | 2215 | // Returns a simple regex that will match on characters and sequences invalid in titles. |
2216 | 2216 | // Note that this doesn't pick up many things that could be wrong with titles, but that |
2217 | 2217 | // replacing this regex with something valid will make many titles valid. |
— | — | @@ -2230,16 +2230,16 @@ |
2231 | 2231 | '|&#x[0-9A-Fa-f]+;' . |
2232 | 2232 | '/S'; |
2233 | 2233 | } |
2234 | | - |
| 2234 | + |
2235 | 2235 | return $rxTc; |
2236 | 2236 | } |
2237 | | - |
| 2237 | + |
2238 | 2238 | /** |
2239 | 2239 | * Capitalize a text if it belongs to a namespace that capitalizes |
2240 | 2240 | */ |
2241 | 2241 | public static function capitalize( $text, $ns = NS_MAIN ) { |
2242 | 2242 | global $wgContLang; |
2243 | | - |
| 2243 | + |
2244 | 2244 | if ( MWNamespace::isCapitalized( $ns ) ) |
2245 | 2245 | return $wgContLang->ucfirst( $text ); |
2246 | 2246 | else |
— | — | @@ -2457,7 +2457,7 @@ |
2458 | 2458 | |
2459 | 2459 | /** |
2460 | 2460 | * Set the fragment for this title. Removes the first character from the |
2461 | | - * specified fragment before setting, so it assumes you're passing it with |
| 2461 | + * specified fragment before setting, so it assumes you're passing it with |
2462 | 2462 | * an initial "#". |
2463 | 2463 | * |
2464 | 2464 | * Deprecated for public use, use Title::makeTitle() with fragment parameter. |
— | — | @@ -2569,8 +2569,8 @@ |
2570 | 2570 | ), |
2571 | 2571 | __METHOD__, array(), |
2572 | 2572 | array( |
2573 | | - 'page' => array( |
2574 | | - 'LEFT JOIN', |
| 2573 | + 'page' => array( |
| 2574 | + 'LEFT JOIN', |
2575 | 2575 | array( 'pl_namespace=page_namespace', 'pl_title=page_title' ) |
2576 | 2576 | ) |
2577 | 2577 | ) |
— | — | @@ -2635,14 +2635,14 @@ |
2636 | 2636 | * Returns true if ok, or a getUserPermissionsErrors()-like array otherwise |
2637 | 2637 | * @param &$nt \type{Title} the new title |
2638 | 2638 | * @param $auth \type{\bool} indicates whether $wgUser's permissions |
2639 | | - * should be checked |
| 2639 | + * should be checked |
2640 | 2640 | * @param $reason \type{\string} is the log summary of the move, used for spam checking |
2641 | 2641 | * @return \type{\mixed} True on success, getUserPermissionsErrors()-like array on failure |
2642 | 2642 | */ |
2643 | 2643 | public function isValidMoveOperation( &$nt, $auth = true, $reason = '' ) { |
2644 | 2644 | global $wgUser; |
2645 | 2645 | |
2646 | | - $errors = array(); |
| 2646 | + $errors = array(); |
2647 | 2647 | if( !$nt ) { |
2648 | 2648 | // Normally we'd add this to $errors, but we'll get |
2649 | 2649 | // lots of syntax errors if $nt is not an object |
— | — | @@ -2702,7 +2702,7 @@ |
2703 | 2703 | // This is kind of lame, won't display nice |
2704 | 2704 | $errors[] = array('spamprotectiontext'); |
2705 | 2705 | } |
2706 | | - |
| 2706 | + |
2707 | 2707 | $err = null; |
2708 | 2708 | if( !wfRunHooks( 'AbortMove', array( $this, $nt, $wgUser, &$err, $reason ) ) ) { |
2709 | 2709 | $errors[] = array('hookaborted', $err); |
— | — | @@ -2732,7 +2732,7 @@ |
2733 | 2733 | * Move a title to a new location |
2734 | 2734 | * @param &$nt \type{Title} the new title |
2735 | 2735 | * @param $auth \type{\bool} indicates whether $wgUser's permissions |
2736 | | - * should be checked |
| 2736 | + * should be checked |
2737 | 2737 | * @param $reason \type{\string} The reason for the move |
2738 | 2738 | * @param $createRedirect \type{\bool} Whether to create a redirect from the old title to the new title. |
2739 | 2739 | * Ignored if the user doesn't have the suppressredirect right. |
— | — | @@ -2794,7 +2794,7 @@ |
2795 | 2795 | if( $protected ) { |
2796 | 2796 | # Protect the redirect title as the title used to be... |
2797 | 2797 | $dbw->insertSelect( 'page_restrictions', 'page_restrictions', |
2798 | | - array( |
| 2798 | + array( |
2799 | 2799 | 'pr_page' => $redirid, |
2800 | 2800 | 'pr_type' => 'pr_type', |
2801 | 2801 | 'pr_level' => 'pr_level', |
— | — | @@ -2874,7 +2874,7 @@ |
2875 | 2875 | * source page |
2876 | 2876 | * |
2877 | 2877 | * @param &$nt \type{Title} the page to move to, which should currently |
2878 | | - * be a redirect |
| 2878 | + * be a redirect |
2879 | 2879 | * @param $reason \type{\string} The reason for the move |
2880 | 2880 | * @param $createRedirect \type{\bool} Whether to leave a redirect at the old title. |
2881 | 2881 | * Ignored if the user doesn't have the suppressredirect right |
— | — | @@ -2917,16 +2917,16 @@ |
2918 | 2918 | $dbw->delete( 'langlinks', array( 'll_from' => $newid ), __METHOD__ ); |
2919 | 2919 | $dbw->delete( 'redirect', array( 'rd_from' => $newid ), __METHOD__ ); |
2920 | 2920 | } |
2921 | | - // If the redirect was recently created, it may have an entry in recentchanges still |
2922 | | - $dbw->delete( 'recentchanges', |
2923 | | - array( 'rc_timestamp' => $rcts, 'rc_namespace' => $newns, 'rc_title' => $newdbk, 'rc_new' => 1 ), |
| 2921 | + // If the redirect was recently created, it may have an entry in recentchanges still |
| 2922 | + $dbw->delete( 'recentchanges', |
| 2923 | + array( 'rc_timestamp' => $rcts, 'rc_namespace' => $newns, 'rc_title' => $newdbk, 'rc_new' => 1 ), |
2924 | 2924 | __METHOD__ |
2925 | 2925 | ); |
2926 | 2926 | |
2927 | 2927 | # Save a null revision in the page's history notifying of the move |
2928 | 2928 | $nullRevision = Revision::newNullRevision( $dbw, $oldid, $comment, true ); |
2929 | 2929 | $nullRevId = $nullRevision->insertOn( $dbw ); |
2930 | | - |
| 2930 | + |
2931 | 2931 | $article = new Article( $this ); |
2932 | 2932 | wfRunHooks( 'NewRevisionFromEditComplete', array($article, $nullRevision, $latest, $wgUser) ); |
2933 | 2933 | |
— | — | @@ -2955,7 +2955,7 @@ |
2956 | 2956 | 'text' => $redirectText ) ); |
2957 | 2957 | $redirectRevision->insertOn( $dbw ); |
2958 | 2958 | $redirectArticle->updateRevisionOn( $dbw, $redirectRevision, 0 ); |
2959 | | - |
| 2959 | + |
2960 | 2960 | wfRunHooks( 'NewRevisionFromEditComplete', array($redirectArticle, $redirectRevision, false, $wgUser) ); |
2961 | 2961 | |
2962 | 2962 | # Now, we record the link from the redirect to the new title. |
— | — | @@ -2983,7 +2983,7 @@ |
2984 | 2984 | $u = new SquidUpdate( $urls ); |
2985 | 2985 | $u->doUpdate(); |
2986 | 2986 | } |
2987 | | - |
| 2987 | + |
2988 | 2988 | } |
2989 | 2989 | |
2990 | 2990 | /** |
— | — | @@ -3006,7 +3006,7 @@ |
3007 | 3007 | $newid = $nt->getArticleID(); |
3008 | 3008 | $oldid = $this->getArticleID(); |
3009 | 3009 | $latest = $this->getLatestRevId(); |
3010 | | - |
| 3010 | + |
3011 | 3011 | $dbw = wfGetDB( DB_MASTER ); |
3012 | 3012 | $now = $dbw->timestamp(); |
3013 | 3013 | |
— | — | @@ -3016,7 +3016,7 @@ |
3017 | 3017 | throw new MWException( 'No valid null revision produced in ' . __METHOD__ ); |
3018 | 3018 | } |
3019 | 3019 | $nullRevId = $nullRevision->insertOn( $dbw ); |
3020 | | - |
| 3020 | + |
3021 | 3021 | $article = new Article( $this ); |
3022 | 3022 | wfRunHooks( 'NewRevisionFromEditComplete', array($article, $nullRevision, $latest, $wgUser) ); |
3023 | 3023 | |
— | — | @@ -3045,7 +3045,7 @@ |
3046 | 3046 | 'text' => $redirectText ) ); |
3047 | 3047 | $redirectRevision->insertOn( $dbw ); |
3048 | 3048 | $redirectArticle->updateRevisionOn( $dbw, $redirectRevision, 0 ); |
3049 | | - |
| 3049 | + |
3050 | 3050 | wfRunHooks( 'NewRevisionFromEditComplete', array($redirectArticle, $redirectRevision, false, $wgUser) ); |
3051 | 3051 | |
3052 | 3052 | # Record the just-created redirect's linking to the page |
— | — | @@ -3071,9 +3071,9 @@ |
3072 | 3072 | # Purge old title from squid |
3073 | 3073 | # The new title, and links to the new title, are purged in Article::onArticleCreate() |
3074 | 3074 | $this->purgeSquid(); |
3075 | | - |
| 3075 | + |
3076 | 3076 | } |
3077 | | - |
| 3077 | + |
3078 | 3078 | /** |
3079 | 3079 | * Move this page's subpages to be subpages of $nt |
3080 | 3080 | * @param $nt Title Move target |
— | — | @@ -3139,7 +3139,7 @@ |
3140 | 3140 | } |
3141 | 3141 | return $retval; |
3142 | 3142 | } |
3143 | | - |
| 3143 | + |
3144 | 3144 | /** |
3145 | 3145 | * Checks if this page is just a one-rev redirect. |
3146 | 3146 | * Adds lock, so don't use just for light purposes. |
— | — | @@ -3169,7 +3169,7 @@ |
3170 | 3170 | 'page_title' => $this->getDBkey(), |
3171 | 3171 | 'page_id=rev_page', |
3172 | 3172 | 'page_latest != rev_id' |
3173 | | - ), |
| 3173 | + ), |
3174 | 3174 | __METHOD__, |
3175 | 3175 | array( 'FOR UPDATE' ) |
3176 | 3176 | ); |
— | — | @@ -3269,7 +3269,7 @@ |
3270 | 3270 | * @return \type{\array} Tree of parent categories |
3271 | 3271 | */ |
3272 | 3272 | public function getParentCategoryTree( $children = array() ) { |
3273 | | - $stack = array(); |
| 3273 | + $stack = array(); |
3274 | 3274 | $parents = $this->getParentCategories(); |
3275 | 3275 | |
3276 | 3276 | if( $parents ) { |
— | — | @@ -3343,7 +3343,7 @@ |
3344 | 3344 | array( 'ORDER BY' => 'rev_id' ) |
3345 | 3345 | ); |
3346 | 3346 | } |
3347 | | - |
| 3347 | + |
3348 | 3348 | /** |
3349 | 3349 | * Get the first revision of the page |
3350 | 3350 | * |
— | — | @@ -3365,7 +3365,7 @@ |
3366 | 3366 | return new Revision( $row ); |
3367 | 3367 | } |
3368 | 3368 | } |
3369 | | - |
| 3369 | + |
3370 | 3370 | /** |
3371 | 3371 | * Check if this is a new page |
3372 | 3372 | * |
— | — | @@ -3509,7 +3509,7 @@ |
3510 | 3510 | public function isKnown() { |
3511 | 3511 | return $this->exists() || $this->isAlwaysKnown(); |
3512 | 3512 | } |
3513 | | - |
| 3513 | + |
3514 | 3514 | /** |
3515 | 3515 | * Is this in a namespace that allows actual pages? |
3516 | 3516 | * |
— | — | @@ -3690,21 +3690,21 @@ |
3691 | 3691 | /** |
3692 | 3692 | * Get all extant redirects to this Title |
3693 | 3693 | * |
3694 | | - * @param $ns \twotypes{\int,\null} Single namespace to consider; |
| 3694 | + * @param $ns \twotypes{\int,\null} Single namespace to consider; |
3695 | 3695 | * NULL to consider all namespaces |
3696 | 3696 | * @return \type{\arrayof{Title}} Redirects to this title |
3697 | 3697 | */ |
3698 | 3698 | public function getRedirectsHere( $ns = null ) { |
3699 | 3699 | $redirs = array(); |
3700 | | - |
3701 | | - $dbr = wfGetDB( DB_SLAVE ); |
| 3700 | + |
| 3701 | + $dbr = wfGetDB( DB_SLAVE ); |
3702 | 3702 | $where = array( |
3703 | 3703 | 'rd_namespace' => $this->getNamespace(), |
3704 | 3704 | 'rd_title' => $this->getDBkey(), |
3705 | 3705 | 'rd_from = page_id' |
3706 | 3706 | ); |
3707 | 3707 | if ( !is_null($ns) ) $where['page_namespace'] = $ns; |
3708 | | - |
| 3708 | + |
3709 | 3709 | $res = $dbr->select( |
3710 | 3710 | array( 'redirect', 'page' ), |
3711 | 3711 | array( 'page_namespace', 'page_title' ), |
— | — | @@ -3718,7 +3718,7 @@ |
3719 | 3719 | } |
3720 | 3720 | return $redirs; |
3721 | 3721 | } |
3722 | | - |
| 3722 | + |
3723 | 3723 | /** |
3724 | 3724 | * Check if this Title is a valid redirect target |
3725 | 3725 | * |
— | — | @@ -3726,18 +3726,18 @@ |
3727 | 3727 | */ |
3728 | 3728 | public function isValidRedirectTarget() { |
3729 | 3729 | global $wgInvalidRedirectTargets; |
3730 | | - |
| 3730 | + |
3731 | 3731 | // invalid redirect targets are stored in a global array, but explicity disallow Userlogout here |
3732 | 3732 | if( $this->isSpecial( 'Userlogout' ) ) { |
3733 | 3733 | return false; |
3734 | 3734 | } |
3735 | | - |
| 3735 | + |
3736 | 3736 | foreach( $wgInvalidRedirectTargets as $target ) { |
3737 | 3737 | if( $this->isSpecial( $target ) ) { |
3738 | 3738 | return false; |
3739 | 3739 | } |
3740 | 3740 | } |
3741 | | - |
| 3741 | + |
3742 | 3742 | return true; |
3743 | 3743 | } |
3744 | 3744 | |
— | — | @@ -3767,17 +3767,17 @@ |
3768 | 3768 | return !in_array( $this->mNamespace, $bannedNamespaces ); |
3769 | 3769 | |
3770 | 3770 | } |
3771 | | - |
| 3771 | + |
3772 | 3772 | public function getRestrictionTypes() { |
3773 | 3773 | global $wgRestrictionTypes; |
3774 | 3774 | $types = $this->exists() ? $wgRestrictionTypes : array('create'); |
3775 | | - |
| 3775 | + |
3776 | 3776 | if ( $this->getNamespace() == NS_FILE ) { |
3777 | 3777 | $types[] = 'upload'; |
3778 | 3778 | } |
3779 | | - |
| 3779 | + |
3780 | 3780 | wfRunHooks( 'TitleGetRestrictionTypes', array( $this, &$types ) ); |
3781 | | - |
| 3781 | + |
3782 | 3782 | return $types; |
3783 | 3783 | } |
3784 | 3784 | } |