jenkins-bot has submitted this change and it was merged.

Change subject: Retry getting CatChange RC from master
......................................................................


Retry getting CatChange RC from master

This adds optional flags to Revision::getRecentChange
And uses them in CategoryMembershipChange

Bug: T109700
Change-Id: I197ebccf1f62cdcb03ce4daa2527b973e495236c
---
M includes/Revision.php
M includes/changes/CategoryMembershipChange.php
M includes/changes/RecentChange.php
3 files changed, 21 insertions(+), 6 deletions(-)

Approvals:
  Aaron Schulz: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/Revision.php b/includes/Revision.php
index 6584207..90d6265 100644
--- a/includes/Revision.php
+++ b/includes/Revision.php
@@ -948,18 +948,25 @@
        /**
         * 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
                );
        }
 
diff --git a/includes/changes/CategoryMembershipChange.php 
b/includes/changes/CategoryMembershipChange.php
index 2533a5b..a12a1d8 100644
--- a/includes/changes/CategoryMembershipChange.php
+++ b/includes/changes/CategoryMembershipChange.php
@@ -166,8 +166,10 @@
 
                # If no revision is given, the change was probably triggered by 
parser functions
                if ( $revision !== null ) {
-                       // TODO if no RC try again from the master DB?
                        $correspondingRc = $this->revision->getRecentChange();
+                       if ( $correspondingRc === null ) {
+                               $correspondingRc = 
$this->revision->getRecentChange( Revision::READ_LATEST );
+                       }
                        if ( $correspondingRc !== null ) {
                                $bot = $correspondingRc->getAttribute( 'rc_bot' 
) ?: 0;
                                $ip = $correspondingRc->getAttribute( 'rc_ip' ) 
?: '';
diff --git a/includes/changes/RecentChange.php 
b/includes/changes/RecentChange.php
index b681f7f..2ccc24b 100644
--- a/includes/changes/RecentChange.php
+++ b/includes/changes/RecentChange.php
@@ -173,11 +173,17 @@
         *
         * @param array $conds Array of conditions
         * @param mixed $fname Override the method name in profiling/logs
+        * @param int $dbType DB_* constant
+        *
         * @return RecentChange|null
         */
-       public static function newFromConds( $conds, $fname = __METHOD__ ) {
-               $dbr = wfGetDB( DB_SLAVE );
-               $row = $dbr->selectRow( 'recentchanges', self::selectFields(), 
$conds, $fname );
+       public static function newFromConds(
+               $conds,
+               $fname = __METHOD__,
+               $dbType = DB_SLAVE
+       ) {
+               $db = wfGetDB( $dbType );
+               $row = $db->selectRow( 'recentchanges', self::selectFields(), 
$conds, $fname );
                if ( $row !== false ) {
                        return self::newFromRow( $row );
                } else {

-- 
To view, visit https://gerrit.wikimedia.org/r/241730
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I197ebccf1f62cdcb03ce4daa2527b973e495236c
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to