Http::getProxy() method to get proxy configuration
[lhc/web/wiklou.git] / includes / Revision.php
index 6584207..a498817 100644 (file)
@@ -223,7 +223,7 @@ class Revision implements IDBAccessObject {
         * Load a page revision from a given revision ID number.
         * Returns null if no such revision can be found.
         *
-        * @param DatabaseBase $db
+        * @param IDatabase $db
         * @param int $id
         * @return Revision|null
         */
@@ -236,7 +236,7 @@ class Revision implements IDBAccessObject {
         * that's attached to a given page. If not attached
         * to that page, will return null.
         *
-        * @param DatabaseBase $db
+        * @param IDatabase $db
         * @param int $pageid
         * @param int $id
         * @return Revision|null
@@ -256,7 +256,7 @@ class Revision implements IDBAccessObject {
         * that's attached to a given page. If not attached
         * to that page, will return null.
         *
-        * @param DatabaseBase $db
+        * @param IDatabase $db
         * @param Title $title
         * @param int $id
         * @return Revision|null
@@ -281,7 +281,7 @@ class Revision implements IDBAccessObject {
         * WARNING: Timestamps may in some circumstances not be unique,
         * so this isn't the best key to use.
         *
-        * @param DatabaseBase $db
+        * @param IDatabase $db
         * @param Title $title
         * @param string $timestamp
         * @return Revision|null
@@ -333,7 +333,7 @@ class Revision implements IDBAccessObject {
         * Given a set of conditions, fetch a revision from
         * the given database connection.
         *
-        * @param DatabaseBase $db
+        * @param IDatabase $db
         * @param array $conditions
         * @param int $flags (optional)
         * @return Revision|null
@@ -375,7 +375,7 @@ class Revision implements IDBAccessObject {
         * which will return matching database rows with the
         * fields necessary to build Revision objects.
         *
-        * @param DatabaseBase $db
+        * @param IDatabase $db
         * @param array $conditions
         * @param int $flags (optional)
         * @return ResultWrapper
@@ -519,7 +519,7 @@ class Revision implements IDBAccessObject {
 
        /**
         * Do a batched query to get the parent revision lengths
-        * @param DatabaseBase $db
+        * @param IDatabase $db
         * @param array $revIds
         * @return array
         */
@@ -948,18 +948,25 @@ class Revision implements IDBAccessObject {
        /**
         * Get the RC object belonging to the current revision, if there's one
         *
+        * @param int $flags (optional) $flags include:
+        *      Revision::READ_LATEST  : Select the data from the master
+        *
         * @since 1.22
         * @return RecentChange|null
         */
-       public function getRecentChange() {
+       public function getRecentChange( $flags = 0 ) {
                $dbr = wfGetDB( DB_SLAVE );
+
+               list( $dbType, ) = DBAccessObjectUtils::getDBOptions( $flags );
+
                return RecentChange::newFromConds(
                        array(
                                'rc_user_text' => $this->getUserText( Revision::RAW ),
                                'rc_timestamp' => $dbr->timestamp( $this->getTimestamp() ),
                                'rc_this_oldid' => $this->getId()
                        ),
-                       __METHOD__
+                       __METHOD__,
+                       $dbType
                );
        }
 
@@ -1199,7 +1206,7 @@ class Revision implements IDBAccessObject {
         * Get previous revision Id for this page_id
         * This is used to populate rev_parent_id on save
         *
-        * @param DatabaseBase $db
+        * @param IDatabase $db
         * @return int
         */
        private function getPreviousRevisionId( $db ) {
@@ -1352,7 +1359,7 @@ class Revision implements IDBAccessObject {
         * Insert a new revision into the database, returning the new revision ID
         * number on success and dies horribly on failure.
         *
-        * @param DatabaseBase $dbw (master connection)
+        * @param IDatabase $dbw (master connection)
         * @throws MWException
         * @return int
         */
@@ -1459,7 +1466,8 @@ class Revision implements IDBAccessObject {
        protected function checkContentModel() {
                global $wgContentHandlerUseDB;
 
-               $title = $this->getTitle(); // note: may return null for revisions that have not yet been inserted.
+               // Note: may return null for revisions that have not yet been inserted
+               $title = $this->getTitle();
 
                $model = $this->getContentModel();
                $format = $this->getContentFormat();
@@ -1522,12 +1530,13 @@ class Revision implements IDBAccessObject {
         */
        protected function loadText() {
                // Caching may be beneficial for massive use of external storage
-               global $wgRevisionCacheExpiry, $wgMemc;
+               global $wgRevisionCacheExpiry;
 
+               $cache = ObjectCache::getMainWANInstance();
                $textId = $this->getTextId();
                $key = wfMemcKey( 'revisiontext', 'textid', $textId );
                if ( $wgRevisionCacheExpiry ) {
-                       $text = $wgMemc->get( $key );
+                       $text = $cache->get( $key );
                        if ( is_string( $text ) ) {
                                wfDebug( __METHOD__ . ": got id $textId from cache\n" );
                                return $text;
@@ -1574,7 +1583,7 @@ class Revision implements IDBAccessObject {
 
                # No negative caching -- negative hits on text rows may be due to corrupted slave servers
                if ( $wgRevisionCacheExpiry && $text !== false ) {
-                       $wgMemc->set( $key, $text, $wgRevisionCacheExpiry );
+                       $cache->set( $key, $text, $wgRevisionCacheExpiry );
                }
 
                return $text;
@@ -1588,7 +1597,7 @@ class Revision implements IDBAccessObject {
         * Such revisions can for instance identify page rename
         * operations and other such meta-modifications.
         *
-        * @param DatabaseBase $dbw
+        * @param IDatabase $dbw
         * @param int $pageId ID number of the page to read from
         * @param string $summary Revision's summary
         * @param bool $minor Whether the revision should be considered as minor
@@ -1738,7 +1747,7 @@ class Revision implements IDBAccessObject {
        /**
         * Get count of revisions per page...not very efficient
         *
-        * @param DatabaseBase $db
+        * @param IDatabase $db
         * @param int $id Page id
         * @return int
         */
@@ -1754,7 +1763,7 @@ class Revision implements IDBAccessObject {
        /**
         * Get count of revisions per page...not very efficient
         *
-        * @param DatabaseBase $db
+        * @param IDatabase $db
         * @param Title $title
         * @return int
         */
@@ -1774,7 +1783,7 @@ class Revision implements IDBAccessObject {
         * @since 1.20
         * @deprecated since 1.24
         *
-        * @param DatabaseBase|int $db The Database to perform the check on. May be given as a
+        * @param IDatabase|int $db The Database to perform the check on. May be given as a
         *        Database object or a database identifier usable with wfGetDB.
         * @param int $pageId The ID of the page in question
         * @param int $userId The ID of the user in question