Index: trunk/phase3/includes/WikiPage.php |
— | — | @@ -10,8 +10,6 @@ |
11 | 11 | * Some fields are public only for backwards-compatibility. Use accessors. |
12 | 12 | * In the past, this class was part of Article.php and everything was public. |
13 | 13 | * |
14 | | - * @TODO: dependency inject $wgUser as an argument to functions |
15 | | - * |
16 | 14 | * @internal documentation reviewed 15 Mar 2010 |
17 | 15 | */ |
18 | 16 | class WikiPage extends Page { |
— | — | @@ -48,6 +46,9 @@ |
49 | 47 | |
50 | 48 | /** |
51 | 49 | * Constructor from a page id |
| 50 | + * |
| 51 | + * Always override this for all subclasses (until we use PHP with LSB) |
| 52 | + * |
52 | 53 | * @param $id Int article ID to load |
53 | 54 | */ |
54 | 55 | public static function newFromID( $id ) { |
— | — | @@ -643,13 +644,14 @@ |
644 | 645 | /** |
645 | 646 | * Should the parser cache be used? |
646 | 647 | * |
| 648 | + * @param $user User The relevant user |
647 | 649 | * @return boolean |
648 | 650 | */ |
649 | | - public function useParserCache( $oldid ) { |
650 | | - global $wgUser, $wgEnableParserCache; |
| 651 | + public function isParserCacheUsed( User $user, $oldid ) { |
| 652 | + global $wgEnableParserCache; |
651 | 653 | |
652 | 654 | return $wgEnableParserCache |
653 | | - && $wgUser->getStubThreshold() == 0 |
| 655 | + && $user->getStubThreshold() == 0 |
654 | 656 | && $this->exists() |
655 | 657 | && empty( $oldid ) |
656 | 658 | && !$this->mTitle->isCssOrJsPage() |
— | — | @@ -923,8 +925,6 @@ |
924 | 926 | * Change an existing article or create a new article. Updates RC and all necessary caches, |
925 | 927 | * optionally via the deferred update array. |
926 | 928 | * |
927 | | - * $wgUser must be set before calling this function. |
928 | | - * |
929 | 929 | * @param $text String: new text |
930 | 930 | * @param $summary String: edit summary |
931 | 931 | * @param $flags Integer bitfield: |
— | — | @@ -950,7 +950,7 @@ |
951 | 951 | * auto-detection due to MediaWiki's performance-optimised locking strategy. |
952 | 952 | * |
953 | 953 | * @param $baseRevId the revision ID this edit was based off, if any |
954 | | - * @param $user User (optional), $wgUser will be used if not passed |
| 954 | + * @param $user User the user doing the edit |
955 | 955 | * |
956 | 956 | * @return Status object. Possible errors: |
957 | 957 | * edit-hook-aborted: The ArticleSave hook aborted the edit but didn't set the fatal flag of $status |
— | — | @@ -1119,7 +1119,7 @@ |
1120 | 1120 | # as a template. Partly deferred. |
1121 | 1121 | self::onArticleEdit( $this->mTitle ); |
1122 | 1122 | # Update links tables, site stats, etc. |
1123 | | - $this->editUpdates( $text, $summary, $isminor, $now, $revisionId, $changed, $user ); |
| 1123 | + $this->doEditUpdates( $text, $user, $summary, $isminor, $revisionId, $changed ); |
1124 | 1124 | } else { |
1125 | 1125 | # Create new article |
1126 | 1126 | $status->value['new'] = true; |
— | — | @@ -1180,7 +1180,7 @@ |
1181 | 1181 | $dbw->commit(); |
1182 | 1182 | |
1183 | 1183 | # Update links, etc. |
1184 | | - $this->editUpdates( $text, $summary, $isminor, $now, $revisionId, true, $user, true ); |
| 1184 | + $this->doEditUpdates( $text, $user, $summary, $isminor, $revisionId, true, true ); |
1185 | 1185 | |
1186 | 1186 | # Clear caches |
1187 | 1187 | self::onArticleCreate( $this->mTitle ); |
— | — | @@ -1214,10 +1214,14 @@ |
1215 | 1215 | * @param $reason String |
1216 | 1216 | * @param &$cascade Integer. Set to false if cascading protection isn't allowed. |
1217 | 1217 | * @param $expiry Array: per restriction type expiration |
| 1218 | + * @param $user User The user updating the restrictions |
1218 | 1219 | * @return bool true on success |
1219 | 1220 | */ |
1220 | | - public function updateRestrictions( $limit = array(), $reason = '', &$cascade = 0, $expiry = array() ) { |
| 1221 | + public function updateRestrictions( |
| 1222 | + $limit = array(), $reason = '', &$cascade = 0, $expiry = array(), User $user = null |
| 1223 | + ) { |
1221 | 1224 | global $wgUser, $wgContLang; |
| 1225 | + $user = is_null( $user ) ? $wgUser : $user; |
1222 | 1226 | |
1223 | 1227 | $restrictionTypes = $this->mTitle->getRestrictionTypes(); |
1224 | 1228 | |
— | — | @@ -1276,7 +1280,7 @@ |
1277 | 1281 | |
1278 | 1282 | # If nothing's changed, do nothing |
1279 | 1283 | if ( $changed ) { |
1280 | | - if ( wfRunHooks( 'ArticleProtect', array( &$this, &$wgUser, $limit, $reason ) ) ) { |
| 1284 | + if ( wfRunHooks( 'ArticleProtect', array( &$this, &$user, $limit, $reason ) ) ) { |
1281 | 1285 | $dbw = wfGetDB( DB_MASTER ); |
1282 | 1286 | |
1283 | 1287 | # Prepare a null revision to be added to the history |
— | — | @@ -1375,8 +1379,8 @@ |
1376 | 1380 | ), __METHOD__ |
1377 | 1381 | ); |
1378 | 1382 | |
1379 | | - wfRunHooks( 'NewRevisionFromEditComplete', array( $this, $nullRevision, $latest, $wgUser ) ); |
1380 | | - wfRunHooks( 'ArticleProtectComplete', array( &$this, &$wgUser, $limit, $reason ) ); |
| 1383 | + wfRunHooks( 'NewRevisionFromEditComplete', array( $this, $nullRevision, $latest, $user ) ); |
| 1384 | + wfRunHooks( 'ArticleProtectComplete', array( &$this, &$user, $limit, $reason ) ); |
1381 | 1385 | |
1382 | 1386 | # Update the protection log |
1383 | 1387 | $log = new LogPage( 'protect' ); |
— | — | @@ -1507,15 +1511,19 @@ |
1508 | 1512 | * Revision::DELETED_RESTRICTED |
1509 | 1513 | * @param $id int article ID |
1510 | 1514 | * @param $commit boolean defaults to true, triggers transaction end |
| 1515 | + * @param &$errors Array of errors to append to |
| 1516 | + * @param $user User The relevant user |
1511 | 1517 | * @return boolean true if successful |
1512 | 1518 | */ |
1513 | | - public function doDeleteArticle( $reason, $suppress = false, $id = 0, $commit = true, &$error = '' ) { |
1514 | | - global $wgDeferredUpdateList, $wgUseTrackbacks; |
1515 | | - global $wgUser; |
| 1519 | + public function doDeleteArticle( |
| 1520 | + $reason, $suppress = false, $id = 0, $commit = true, &$error = '', User $user = null |
| 1521 | + ) { |
| 1522 | + global $wgDeferredUpdateList, $wgUseTrackbacks, $wgUser; |
| 1523 | + $user = is_null( $user ) ? $wgUser : $user; |
1516 | 1524 | |
1517 | 1525 | wfDebug( __METHOD__ . "\n" ); |
1518 | 1526 | |
1519 | | - if ( ! wfRunHooks( 'ArticleDelete', array( &$this, &$wgUser, &$reason, &$error ) ) ) { |
| 1527 | + if ( ! wfRunHooks( 'ArticleDelete', array( &$this, &$user, &$reason, &$error ) ) ) { |
1520 | 1528 | return false; |
1521 | 1529 | } |
1522 | 1530 | $dbw = wfGetDB( DB_MASTER ); |
— | — | @@ -1644,7 +1652,7 @@ |
1645 | 1653 | $dbw->commit(); |
1646 | 1654 | } |
1647 | 1655 | |
1648 | | - wfRunHooks( 'ArticleDeleteComplete', array( &$this, &$wgUser, $reason, $id ) ); |
| 1656 | + wfRunHooks( 'ArticleDeleteComplete', array( &$this, &$user, $reason, $id ) ); |
1649 | 1657 | return true; |
1650 | 1658 | } |
1651 | 1659 | |
— | — | @@ -1652,7 +1660,7 @@ |
1653 | 1661 | * Roll back the most recent consecutive set of edits to a page |
1654 | 1662 | * from the same user; fails if there are no eligible edits to |
1655 | 1663 | * roll back to, e.g. user is the sole contributor. This function |
1656 | | - * performs permissions checks on $wgUser, then calls commitRollback() |
| 1664 | + * performs permissions checks on $user, then calls commitRollback() |
1657 | 1665 | * to do the dirty work |
1658 | 1666 | * |
1659 | 1667 | * @param $fromP String: Name of the user whose edits to rollback. |
— | — | @@ -1664,26 +1672,30 @@ |
1665 | 1673 | * 'alreadyrolled' : 'current' (rev) |
1666 | 1674 | * success : 'summary' (str), 'current' (rev), 'target' (rev) |
1667 | 1675 | * |
| 1676 | + * @param $user User The user performing the rollback |
1668 | 1677 | * @return array of errors, each error formatted as |
1669 | 1678 | * array(messagekey, param1, param2, ...). |
1670 | 1679 | * On success, the array is empty. This array can also be passed to |
1671 | 1680 | * OutputPage::showPermissionsErrorPage(). |
1672 | 1681 | */ |
1673 | | - public function doRollback( $fromP, $summary, $token, $bot, &$resultDetails ) { |
| 1682 | + public function doRollback( |
| 1683 | + $fromP, $summary, $token, $bot, &$resultDetails, User $user = null |
| 1684 | + ) { |
1674 | 1685 | global $wgUser; |
| 1686 | + $user = is_null( $user ) ? $wgUser : $user; |
1675 | 1687 | |
1676 | 1688 | $resultDetails = null; |
1677 | 1689 | |
1678 | 1690 | # Check permissions |
1679 | | - $editErrors = $this->mTitle->getUserPermissionsErrors( 'edit', $wgUser ); |
1680 | | - $rollbackErrors = $this->mTitle->getUserPermissionsErrors( 'rollback', $wgUser ); |
| 1691 | + $editErrors = $this->mTitle->getUserPermissionsErrors( 'edit', $user ); |
| 1692 | + $rollbackErrors = $this->mTitle->getUserPermissionsErrors( 'rollback', $user ); |
1681 | 1693 | $errors = array_merge( $editErrors, wfArrayDiff2( $rollbackErrors, $editErrors ) ); |
1682 | 1694 | |
1683 | | - if ( !$wgUser->matchEditToken( $token, array( $this->mTitle->getPrefixedText(), $fromP ) ) ) { |
| 1695 | + if ( !$user->matchEditToken( $token, array( $this->mTitle->getPrefixedText(), $fromP ) ) ) { |
1684 | 1696 | $errors[] = array( 'sessionfailure' ); |
1685 | 1697 | } |
1686 | 1698 | |
1687 | | - if ( $wgUser->pingLimiter( 'rollback' ) || $wgUser->pingLimiter() ) { |
| 1699 | + if ( $user->pingLimiter( 'rollback' ) || $user->pingLimiter() ) { |
1688 | 1700 | $errors[] = array( 'actionthrottledtext' ); |
1689 | 1701 | } |
1690 | 1702 | |
— | — | @@ -1692,7 +1704,7 @@ |
1693 | 1705 | return $errors; |
1694 | 1706 | } |
1695 | 1707 | |
1696 | | - return $this->commitRollback( $fromP, $summary, $bot, $resultDetails ); |
| 1708 | + return $this->commitRollback( $user, $fromP, $summary, $bot, $resultDetails ); |
1697 | 1709 | } |
1698 | 1710 | |
1699 | 1711 | /** |
— | — | @@ -1703,9 +1715,16 @@ |
1704 | 1716 | * rollback to the DB Therefore, you should only call this function direct- |
1705 | 1717 | * ly if you want to use custom permissions checks. If you don't, use |
1706 | 1718 | * doRollback() instead. |
| 1719 | + * @param $fromP String: Name of the user whose edits to rollback. |
| 1720 | + * @param $summary String: Custom summary. Set to default summary if empty. |
| 1721 | + * @param $bot Boolean: If true, mark all reverted edits as bot. |
| 1722 | + * |
| 1723 | + * @param $resultDetails Array: contains result-specific array of additional values |
| 1724 | + * @param $guser User The user performing the rollback |
1707 | 1725 | */ |
1708 | | - public function commitRollback( $fromP, $summary, $bot, &$resultDetails ) { |
| 1726 | + public function commitRollback( $fromP, $summary, $bot, &$resultDetails, User $guser = null ) { |
1709 | 1727 | global $wgUseRCPatrol, $wgUser, $wgContLang; |
| 1728 | + $guser = is_null( $guser ) ? $wgUser : $guser; |
1710 | 1729 | |
1711 | 1730 | $dbw = wfGetDB( DB_MASTER ); |
1712 | 1731 | |
— | — | @@ -1753,7 +1772,7 @@ |
1754 | 1773 | } |
1755 | 1774 | |
1756 | 1775 | $set = array(); |
1757 | | - if ( $bot && $wgUser->isAllowed( 'markbotedits' ) ) { |
| 1776 | + if ( $bot && $guser->isAllowed( 'markbotedits' ) ) { |
1758 | 1777 | # Mark all reverted edits as bot |
1759 | 1778 | $set['rc_bot'] = 1; |
1760 | 1779 | } |
— | — | @@ -1794,11 +1813,11 @@ |
1795 | 1814 | # Save |
1796 | 1815 | $flags = EDIT_UPDATE; |
1797 | 1816 | |
1798 | | - if ( $wgUser->isAllowed( 'minoredit' ) ) { |
| 1817 | + if ( $guser->isAllowed( 'minoredit' ) ) { |
1799 | 1818 | $flags |= EDIT_MINOR; |
1800 | 1819 | } |
1801 | 1820 | |
1802 | | - if ( $bot && ( $wgUser->isAllowedAny( 'markbotedits', 'bot' ) ) ) { |
| 1821 | + if ( $bot && ( $guser->isAllowedAny( 'markbotedits', 'bot' ) ) ) { |
1803 | 1822 | $flags |= EDIT_FORCE_BOT; |
1804 | 1823 | } |
1805 | 1824 | |
— | — | @@ -1810,7 +1829,7 @@ |
1811 | 1830 | $revId = false; |
1812 | 1831 | } |
1813 | 1832 | |
1814 | | - wfRunHooks( 'ArticleRollbackComplete', array( $this, $wgUser, $target, $current ) ); |
| 1833 | + wfRunHooks( 'ArticleRollbackComplete', array( $this, $guser, $target, $current ) ); |
1815 | 1834 | |
1816 | 1835 | $resultDetails = array( |
1817 | 1836 | 'summary' => $summary, |
— | — | @@ -1824,21 +1843,22 @@ |
1825 | 1844 | |
1826 | 1845 | /** |
1827 | 1846 | * Do standard deferred updates after page view |
| 1847 | + * @param $user User The relevant user |
1828 | 1848 | */ |
1829 | | - public function viewUpdates() { |
1830 | | - global $wgDeferredUpdateList, $wgDisableCounters, $wgUser; |
| 1849 | + public function doViewUpdates( User $user ) { |
| 1850 | + global $wgDeferredUpdateList, $wgDisableCounters; |
1831 | 1851 | if ( wfReadOnly() ) { |
1832 | 1852 | return; |
1833 | 1853 | } |
1834 | 1854 | |
1835 | 1855 | # Don't update page view counters on views from bot users (bug 14044) |
1836 | | - if ( !$wgDisableCounters && !$wgUser->isAllowed( 'bot' ) && $this->getID() ) { |
| 1856 | + if ( !$wgDisableCounters && !$user->isAllowed( 'bot' ) && $this->getID() ) { |
1837 | 1857 | $wgDeferredUpdateList[] = new ViewCountUpdate( $this->getID() ); |
1838 | 1858 | $wgDeferredUpdateList[] = new SiteStatsUpdate( 1, 0, 0 ); |
1839 | 1859 | } |
1840 | 1860 | |
1841 | 1861 | # Update newtalk / watchlist notification status |
1842 | | - $wgUser->clearNotification( $this->mTitle ); |
| 1862 | + $user->clearNotification( $this->mTitle ); |
1843 | 1863 | } |
1844 | 1864 | |
1845 | 1865 | /** |
— | — | @@ -1846,17 +1866,17 @@ |
1847 | 1867 | * Returns a stdclass with source, pst and output members |
1848 | 1868 | */ |
1849 | 1869 | public function prepareTextForEdit( $text, $revid = null, User $user = null ) { |
1850 | | - if ( $this->mPreparedEdit && $this->mPreparedEdit->newText == $text && $this->mPreparedEdit->revid == $revid ) { |
| 1870 | + global $wgParser, $wgUser; |
| 1871 | + $user = is_null( $user ) ? $wgUser : $user; |
| 1872 | + // @TODO fixme: check $user->getId() here??? |
| 1873 | + if ( $this->mPreparedEdit |
| 1874 | + && $this->mPreparedEdit->newText == $text |
| 1875 | + && $this->mPreparedEdit->revid == $revid |
| 1876 | + ) { |
1851 | 1877 | // Already prepared |
1852 | 1878 | return $this->mPreparedEdit; |
1853 | 1879 | } |
1854 | 1880 | |
1855 | | - global $wgParser; |
1856 | | - |
1857 | | - if( $user === null ) { |
1858 | | - global $wgUser; |
1859 | | - $user = $wgUser; |
1860 | | - } |
1861 | 1881 | $popts = ParserOptions::newFromUser( $user ); |
1862 | 1882 | wfRunHooks( 'ArticlePrepareTextForEdit', array( $this, $popts ) ); |
1863 | 1883 | |
— | — | @@ -1881,18 +1901,17 @@ |
1882 | 1902 | * |
1883 | 1903 | * @private |
1884 | 1904 | * @param $text String: New text of the article |
| 1905 | + * @param $user User object: User doing the edit |
1885 | 1906 | * @param $summary String: Edit summary |
1886 | 1907 | * @param $minoredit Boolean: Minor edit |
1887 | | - * @param $timestamp_of_pagechange String timestamp associated with the page change |
1888 | 1908 | * @param $newid Integer: rev_id value of the new revision |
1889 | 1909 | * @param $changed Boolean: Whether or not the content actually changed |
1890 | | - * @param $user User object: User doing the edit |
1891 | 1910 | * @param $created Boolean: Whether the edit created the page |
1892 | 1911 | */ |
1893 | | - public function editUpdates( $text, $summary, $minoredit, $timestamp_of_pagechange, $newid, |
1894 | | - $changed = true, User $user = null, $created = false ) |
1895 | | - { |
1896 | | - global $wgDeferredUpdateList, $wgUser, $wgEnableParserCache; |
| 1912 | + public function doEditUpdates( |
| 1913 | + $text, $user, $summary, $minoredit, $newid, $changed = true, $created = false |
| 1914 | + ) { |
| 1915 | + global $wgDeferredUpdateList, $wgEnableParserCache; |
1897 | 1916 | |
1898 | 1917 | wfProfileIn( __METHOD__ ); |
1899 | 1918 | |
— | — | @@ -1961,8 +1980,8 @@ |
1962 | 1981 | # Don't do this if $changed = false otherwise some idiot can null-edit a |
1963 | 1982 | # load of user talk pages and piss people off, nor if it's a minor edit |
1964 | 1983 | # by a properly-flagged bot. |
1965 | | - if ( $this->mTitle->getNamespace() == NS_USER_TALK && $shortTitle != $wgUser->getTitleKey() && $changed |
1966 | | - && !( $minoredit && $wgUser->isAllowed( 'nominornewtalk' ) ) |
| 1984 | + if ( $this->mTitle->getNamespace() == NS_USER_TALK && $shortTitle != $user->getTitleKey() && $changed |
| 1985 | + && !( $minoredit && $user->isAllowed( 'nominornewtalk' ) ) |
1967 | 1986 | ) { |
1968 | 1987 | if ( wfRunHooks( 'ArticleEditUpdateNewTalk', array( &$this ) ) ) { |
1969 | 1988 | $other = User::newFromName( $shortTitle, false ); |
— | — | @@ -1992,12 +2011,14 @@ |
1993 | 2012 | * @param $rev Revision object |
1994 | 2013 | * |
1995 | 2014 | * @todo This is a shitty interface function. Kill it and replace the |
1996 | | - * other shitty functions like editUpdates and such so it's not needed |
| 2015 | + * other shitty functions like doEditUpdates and such so it's not needed |
1997 | 2016 | * anymore. |
| 2017 | + * @deprecated since 1.19, use doEditUpdates() |
1998 | 2018 | */ |
1999 | 2019 | public function createUpdates( $rev ) { |
2000 | | - $this->editUpdates( $rev->getText(), $rev->getComment(), |
2001 | | - $rev->isMinor(), wfTimestamp(), $rev->getId(), true, null, true ); |
| 2020 | + global $wgUser; |
| 2021 | + $this->doEditUpdates( $rev->getText(), $wgUser, $rev->getComment(), |
| 2022 | + $rev->isMinor(), $rev->getId(), true, true ); |
2002 | 2023 | } |
2003 | 2024 | |
2004 | 2025 | /** |
— | — | @@ -2005,21 +2026,16 @@ |
2006 | 2027 | * so we can do things like signatures and links-in-context. |
2007 | 2028 | * |
2008 | 2029 | * @param $text String article contents |
2009 | | - * @param $user User object: user doing the edit, $wgUser will be used if |
2010 | | - * null is given |
| 2030 | + * @param $user User object: user doing the edit |
2011 | 2031 | * @param $popts ParserOptions object: parser options, default options for |
2012 | 2032 | * the user loaded if null given |
2013 | 2033 | * @return string article contents with altered wikitext markup (signatures |
2014 | 2034 | * converted, {{subst:}}, templates, etc.) |
2015 | 2035 | */ |
2016 | 2036 | public function preSaveTransform( $text, User $user = null, ParserOptions $popts = null ) { |
2017 | | - global $wgParser; |
| 2037 | + global $wgParser, $wgUser; |
| 2038 | + $user = is_null( $user ) ? $wgUser : $user; |
2018 | 2039 | |
2019 | | - if ( $user === null ) { |
2020 | | - global $wgUser; |
2021 | | - $user = $wgUser; |
2022 | | - } |
2023 | | - |
2024 | 2040 | if ( $popts === null ) { |
2025 | 2041 | $popts = ParserOptions::newFromUser( $user ); |
2026 | 2042 | } |
— | — | @@ -2069,10 +2085,11 @@ |
2070 | 2086 | * are not updated, caches are not flushed. |
2071 | 2087 | * |
2072 | 2088 | * @param $text String: text submitted |
| 2089 | + * @param $user User The relevant user |
2073 | 2090 | * @param $comment String: comment submitted |
2074 | 2091 | * @param $minor Boolean: whereas it's a minor modification |
2075 | 2092 | */ |
2076 | | - public function quickEdit( $text, $comment = '', $minor = 0 ) { |
| 2093 | + public function doQuickEdit( $text, User $user, $comment = '', $minor = 0 ) { |
2077 | 2094 | wfProfileIn( __METHOD__ ); |
2078 | 2095 | |
2079 | 2096 | $dbw = wfGetDB( DB_MASTER ); |
— | — | @@ -2081,12 +2098,11 @@ |
2082 | 2099 | 'text' => $text, |
2083 | 2100 | 'comment' => $comment, |
2084 | 2101 | 'minor_edit' => $minor ? 1 : 0, |
2085 | | - ) ); |
| 2102 | + ) ); |
2086 | 2103 | $revision->insertOn( $dbw ); |
2087 | 2104 | $this->updateRevisionOn( $dbw, $revision ); |
2088 | 2105 | |
2089 | | - global $wgUser; |
2090 | | - wfRunHooks( 'NewRevisionFromEditComplete', array( $this, $revision, false, $wgUser ) ); |
| 2106 | + wfRunHooks( 'NewRevisionFromEditComplete', array( $this, $revision, false, $user ) ); |
2091 | 2107 | |
2092 | 2108 | wfProfileOut( __METHOD__ ); |
2093 | 2109 | } |
— | — | @@ -2400,20 +2416,22 @@ |
2401 | 2417 | * @since 1.16 (r52326) for LiquidThreads |
2402 | 2418 | * |
2403 | 2419 | * @param $oldid mixed integer Revision ID or null |
| 2420 | + * @param $user User The relevant user |
2404 | 2421 | * @return ParserOutput or false if the given revsion ID is not found |
2405 | 2422 | */ |
2406 | | - public function getParserOutput( $oldid = null ) { |
| 2423 | + public function getParserOutput( $oldid = null, User $user = null ) { |
2407 | 2424 | global $wgEnableParserCache, $wgUser; |
| 2425 | + $user = is_null( $user ) ? $wgUser : $user; |
2408 | 2426 | |
2409 | 2427 | // Should the parser cache be used? |
2410 | 2428 | $useParserCache = $wgEnableParserCache && |
2411 | | - $wgUser->getStubThreshold() == 0 && |
| 2429 | + $user->getStubThreshold() == 0 && |
2412 | 2430 | $this->exists() && |
2413 | 2431 | $oldid === null; |
2414 | 2432 | |
2415 | 2433 | wfDebug( __METHOD__ . ': using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" ); |
2416 | 2434 | |
2417 | | - if ( $wgUser->getStubThreshold() ) { |
| 2435 | + if ( $user->getStubThreshold() ) { |
2418 | 2436 | wfIncrStats( 'pcache_miss_stub' ); |
2419 | 2437 | } |
2420 | 2438 | |
— | — | @@ -2437,4 +2455,39 @@ |
2438 | 2456 | |
2439 | 2457 | return $this->getOutputFromWikitext( $text, $useParserCache ); |
2440 | 2458 | } |
| 2459 | + |
| 2460 | + /* |
| 2461 | + * @deprecated since 1.19 |
| 2462 | + */ |
| 2463 | + public function quickEdit( $text, $comment = '', $minor = 0 ) { |
| 2464 | + global $wgUser; |
| 2465 | + return $this->doQuickEdit( $text, $wgUser, $comment, $minor ); |
| 2466 | + } |
| 2467 | + |
| 2468 | + /* |
| 2469 | + * @deprecated since 1.19 |
| 2470 | + */ |
| 2471 | + public function editUpdates( |
| 2472 | + $text, $summary, $minoredit, $timestamp_of_pagechange, $newid, |
| 2473 | + $changed = true, User $user = null, $created = false |
| 2474 | + ) { |
| 2475 | + global $wgUser; |
| 2476 | + return $this->doEditUpdates( $text, $wgUser, $summary, $minoredit, $newid, $changed, $created ); |
| 2477 | + } |
| 2478 | + |
| 2479 | + /* |
| 2480 | + * @deprecated since 1.19 |
| 2481 | + */ |
| 2482 | + public function viewUpdates() { |
| 2483 | + global $wgUser; |
| 2484 | + return $this->doViewUpdates( $wgUser ); |
| 2485 | + } |
| 2486 | + |
| 2487 | + /* |
| 2488 | + * @deprecated since 1.19 |
| 2489 | + */ |
| 2490 | + public function useParserCache( $oldid ) { |
| 2491 | + global $wgUser; |
| 2492 | + return $this->isParserCacheUsed( $wgUser, $oldid ); |
| 2493 | + } |
2441 | 2494 | } |